Create a request
POST /v1/scheduling/requests asks Sunny to book a visit for one patient. It answers 201 at once with the request’s id; the booking happens in the background.
curl https://api-staging.sunnyhealthai.com/v1/scheduling/requests \ -H "Authorization: Bearer $SUNNY_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "patient": { "first_name": "Alex", "last_name": "Sample", "date_of_birth": "1984-03-09", "sex": "female", "phone": "+14155550123", "email": "alex.sample@example.com", "address": { "line1": "1 Example St", "city": "San Francisco", "state": "CA", "zip": "94110" } }, "insurance": { "payer_name": "Example Health Plan", "member_id": "XYZ123456789" }, "visit": { "reason": "Follow-up on thyroid lab results" }, "search_area": { "zip": "94110", "radius_miles": 15 }, "preferences": { "provider_preference": "Dr. Sam Example at Example Endocrine Associates, if possible", "earliest": "2026-12-01", "latest": "2026-12-18" }, "consent": { "obtained_at": "2026-11-19T17:00:00Z" }, "reference_id": "your-own-id-123" }'Fields
Section titled “Fields”| Field | Required | Notes |
|---|---|---|
patient |
yes | first_name, last_name, date_of_birth, sex, phone, email and address. The patient must be 18 or older. The email is the patient’s own. |
insurance |
one of | payer_name (passed to the office as written), member_id, and optionally group_number and plan_type. |
self_pay |
one of | true. Send exactly one of insurance and self_pay. |
visit.reason |
yes | Up to 500 characters. Told to the office. It also decides which kind of office Sunny contacts. |
visit.lab_results_files[] |
no | Up to 5 files, faxed to the office that books. See Lab results. |
search_area.zip |
yes | A five-digit US ZIP. |
search_area.radius_miles |
no | 1 to 100. Default 25. Sunny never contacts an office outside it. |
preferences.provider_preference |
no | Up to 500 characters, in the member’s own words: a provider or office they have in mind, or what they want in one. See Which office Sunny contacts. |
preferences.earliest, preferences.latest |
no | The dates the visit may fall on. Default: from tomorrow, for 60 days. The window may be at most 180 days. |
preferences.in_network_required |
no | Default true with insurance. Must be false or absent with self_pay. |
consent.obtained_at |
yes | When the patient agreed to Sunny contacting offices on their behalf. Not in the future. |
reference_id |
no | Your own id for the request. It comes back on the request and on every webhook. |
simulate |
no | Sandbox keys only. See Sandbox. |
The API reference has every field’s exact type and limits.
Things to know
Section titled “Things to know”- Send
Idempotency-Keyon everyPOST. If your call times out, repeat it with the same key and body: you get the first response back, withIdempotent-Replayed: true, and no second request is made. Without a key, a repeat creates a second request. Details are in Errors and limits. - Unknown fields are rejected with
422. - A
422lists every invalid field inerror.errors[], with the first also at the top level. Error messages never repeat what you sent. - Sunny never contacts the member. You tell the member what was booked.
- A patient may have several requests at once. There is no duplicate guard beyond the idempotency key.
What comes back
Section titled “What comes back”{ "id": "req_8f2c1d", "status": "received", "created_at": "2026-11-19T17:02:12Z", "reference_id": "your-own-id-123", "sandbox": false }Keep the id. Then follow the request.