Registers a new patient in your organization. The patient is created inactive and scoped to your organization. Staff or administrator accounts cannot be created through this endpoint. Duplicate registrations (same email, or same name and date of birth) are rejected. Requires an API key with the write scope; keys issued before write access existed are read-only and must be regenerated by an administrator.
Code samples
Node.js
const fetch = require('node-fetch');
async function callApi() {
const apiKey = 'YOUR_API_KEY';
const url = `https://account.lunahealth.app/api/patients`;
const requestBody = {
// Add your request body data here
};
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error('Error calling API:', error);
throw error;
}
}
callApi();
Python
import requests
def call_api():
api_key = 'YOUR_API_KEY'
url = 'https://account.lunahealth.app/api/patients'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
params = {
}
# Add your request body data here
request_body = {}
try:
response = requests.post(
url,
headers=headers,
params=params,
json=request_body
)
response.raise_for_status()
data = response.json()
print(data)
return data
except requests.exceptions.RequestException as e:
print(f'Error calling API: {e}')
raise
call_api()