Create a patient

POSThttps://zwhwryofdsgmzgqbcghl.supabase.co/functions/v1/api/v1/patients

Requires the patients:write scope. See keys and scopes.

Try it

10 requests a minute

Kept in this tab only (sessionStorage), never saved to disk and never put in the code sample. It is sent to CuspFlow's own proxy on this domain, not to a third party.

Confirm the clinic id (optional)

Fill this in and the request is refused unless the key really belongs to that clinic. It guards against pasting the wrong key, not against an attacker: the clinic is already in the key and anyone holding it can read it from whoami.

Headers (1)
curl --request POST \
  --url 'https://zwhwryofdsgmzgqbcghl.supabase.co/functions/v1/api/v1/patients' \
  --header 'Authorization: Bearer '"$CUSPFLOW_API_KEY" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{ "first_name": "", "last_name": "" }'
Paste a key to run this.

Headers

Idempotency-Key
string
Replay protection. Resending the SAME key with the SAME body returns the first response instead of acting twice; the same key with a DIFFERENT body is rejected with 422. The window is 24 hours.

Body

2 required fields, 31 optional.

branch_id
string<uuid>
—
family_id
string<uuid>
—
first_name
string
required
—
last_name
string
required
—
dob
string<date>
—
age_group
string
—
gender
string
—
phone
string
—
email
string
—
address
string
—
location
string
—
allergies
string
—
current_medications
string
—
medical_history_notes
string
—
dental_history_notes
string
—
patient_since
string<date-time>
—
is_active
boolean
—
is_head_of_family
boolean
—
emergency_contact_name
string
—
emergency_contact_relationship
string
—
emergency_contact_phone
string
—
emergency_contact_email
string
—
emergency_contact_location
string
—
insurance_carrier_id
string<uuid>
—
insurance_provider
string
—
insurance_policy_number
string
—
insurance_group_number
string
—
insurance_holder_name
string
—
whatsapp_number
string
—
whatsapp_opted_in
boolean
—
whatsapp_consent_at
string<date-time>
—
reminders_email_opted_out
boolean
—
reminders_whatsapp_opted_out
boolean
—

Responses

201Created. The new row, under `data`.
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "clinic_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "branch_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "family_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "patient_code": "string",
    "first_name": "Amina",
    "last_name": "Okello",
    "dob": "2026-11-05",
    "...": "…"
  }
}
400Body is not JSON, or names a field that cannot be written. See `errors[]`; values are never echoed back.
401Missing, malformed, revoked or expired key.
403Key lacks `patients:write`, the bound role may not write this, the branch is not allowed, or the clinic is read-only.
409An identical Idempotency-Key is still in flight.
422A required field is missing. See `errors[]`. Note that a field which simply cannot be written is a 400 `unknown_field`, not a 422.
429Rate limited.

Every error is application/problem+json and carries a code you can branch on. The full catalogue is in error codes.