{"openapi":"3.1.0","info":{"title":"Anotera Referral API","version":"1.0.0","description":"For insurers and other referrers: see a clinic's available times, refer a patient and book the first appointment. One API key per organisation, issued by Anotera; each clinic connects your organisation in its own settings. Guide: https://anotera.clinic/en/api/henvisere/","contact":{"name":"Anotera","email":"contact@anotera.clinic","url":"https://anotera.clinic/en/api/"}},"servers":[{"url":"https://anotera.clinic/api/referral/v1"}],"security":[{"bearer":[]}],"tags":[{"name":"Sign-up"},{"name":"Clinics"},{"name":"Applications"},{"name":"Referrals"},{"name":"Invoicing"},{"name":"Self-billing"},{"name":"Webhooks"},{"name":"Meta"}],"paths":{"/":{"get":{"operationId":"getRoot","tags":["Meta"],"summary":"Version and links","security":[],"responses":{"200":{"description":"Version and links.","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"version":{"type":"string"},"documentation":{"type":"string"},"openapi":{"type":"string"},"authentication":{"type":"string"},"test_clinic_id":{"type":"string"}}}}}}}}},"/openapi.json":{"get":{"operationId":"getOpenapi","tags":["Meta"],"summary":"This document","security":[],"responses":{"200":{"description":"The OpenAPI 3.1 description.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/clinics":{"get":{"operationId":"listClinics","tags":["Clinics"],"summary":"The clinics that have connected your organisation — or, with status=interested, the clinics that have applied to work with you","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["connected","interested"],"default":"connected"},"description":"\"interested\": clinics that have applied to work with your organisation and wait for your answer."}],"responses":{"200":{"description":"The clinics.","content":{"application/json":{"schema":{"type":"object","required":["clinics"],"properties":{"clinics":{"type":"array","items":{"$ref":"#/components/schemas/ClinicSummary"}},"test":{"type":"boolean"}}}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/clinics/{clinic_id}":{"get":{"operationId":"getClinic","tags":["Clinics"],"summary":"A clinic: practitioners, services and rules — only what the clinic has opened to you","description":"For a clinic that has applied to work with you (status \"interested\") the answer is the clinic's business profile instead (ClinicApplication): no ids to book with, and nothing about patients.","parameters":[{"name":"clinic_id","in":"path","required":true,"schema":{"type":"string","examples":["kl_testclinic01"]},"description":"The clinic's id (kl_ + 12 characters). The clinic gives it to you, or you find it with GET /clinics."}],"responses":{"200":{"description":"The clinic — or, for an applicant, its business profile.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Clinic"},{"$ref":"#/components/schemas/ClinicApplication"}]}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/signup":{"post":{"operationId":"signUp","tags":["Sign-up"],"summary":"Sign your organisation up — a test key at once, the live key after Anotera's approval","security":[],"description":"Creates your organisation as \"pending review\" and returns, ONCE, a test key (works immediately against the test clinic) and a claim code. When Anotera has approved the organisation, exchange the claim code for the live key with POST /signup/claim. If the organisation is already known (same registration number or same email domain) the answer is 202 without a key. At most 5 sign-ups per hour from one address.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignUp"}}}},"responses":{"201":{"description":"Created, waiting for review.","content":{"application/json":{"schema":{"type":"object","required":["status","organisation_id","test_key","claim_code"],"properties":{"status":{"type":"string","enum":["pending_review"]},"organisation_id":{"type":"string"},"name":{"type":"string"},"test_key":{"type":"string","description":"ah_test_… — shown once."},"claim_code":{"type":"string","description":"ac_… — shown once. Exchanges for the live key after approval."},"test_clinic_id":{"type":"string"},"claim_url":{"type":"string"},"documentation":{"type":"string"},"email_confirmation":{"type":"boolean","description":"Whether a confirmation email was sent. When false, Anotera contacts you by the email or phone you gave."},"note":{"type":"string"}}}}}},"202":{"description":"Received — no key. We will get back to you.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["received"]},"message":{"type":"string"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/signup/claim":{"post":{"operationId":"claimKey","tags":["Sign-up"],"summary":"Exchange the claim code for your live key — once","security":[],"description":"Approved: the live key is created and shown ONCE, and the claim code is used. Not approved yet: \"pending_review\", no key. A wrong code answers exactly like an unknown organisation. At most 5 attempts per hour per address and per organisation.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["organisation_id","claim_code"],"properties":{"organisation_id":{"type":"string","examples":["hv-0123456789ab"]},"claim_code":{"type":"string","writeOnly":true}}}}}},"responses":{"200":{"description":"The live key — or \"pending_review\".","content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["approved","pending_review"]},"organisation_id":{"type":"string"},"name":{"type":"string"},"api_key":{"type":"string","description":"ah_live_… — only when approved; shown once."},"message":{"type":"string"},"note":{"type":"string"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown organisation id or claim code, or the code is used. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The organisation already has two active live keys. Codes: key_limit_reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/applications/view":{"post":{"operationId":"viewApplication","tags":["Applications"],"summary":"What a link in an application email is about","security":[],"description":"Used by the page behind the Accept / Decline links in the email a clinic sends you. Changes nothing.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token"],"properties":{"token":{"type":"string","writeOnly":true}}}}}},"responses":{"200":{"description":"The application.","content":{"application/json":{"schema":{"type":"object","properties":{"organisation":{"type":"string"},"clinic":{"$ref":"#/components/schemas/ClinicApplication"},"expires_at":{"type":"string","format":"date-time"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The link is used, expired or withdrawn. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/applications/respond":{"post":{"operationId":"respondToApplication","tags":["Applications"],"summary":"Accept or decline with the one-time token from the email","security":[],"description":"The token works once and for 30 days. Accepting connects the clinic — which only gives access to whoever already holds your API key.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token","status"],"properties":{"token":{"type":"string","writeOnly":true},"status":{"type":"string","enum":["accepted","declined"]},"message":{"type":"string","maxLength":200}}}}}},"responses":{"200":{"description":"Answered.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["connected","declined"]},"organisation":{"type":"string"},"clinic_name":{"type":"string"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The link is used, expired or withdrawn. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/settings":{"get":{"operationId":"getSettings","tags":["Applications"],"summary":"Your settings for applications from clinics","responses":{"200":{"description":"The settings.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Settings"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"putSettings","tags":["Applications"],"summary":"Switch applications from clinics on or off, and say where the email about them goes","description":"Send only the fields you want to change. A test key validates the call and changes nothing.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"accepting_applications":{"type":"boolean"},"applications_email":{"type":["string","null"],"format":"email","description":"null removes the address: no email is sent, applications still show in the API."}}}}}},"responses":{"200":{"description":"The settings after the change.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Settings"}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was reused with another body. Codes: idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/clinics/{clinic_id}/availability":{"get":{"operationId":"getAvailability","tags":["Clinics"],"summary":"Available times","description":"Never who is booked, and never why a time is unavailable. At most 31 days per call.","parameters":[{"name":"clinic_id","in":"path","required":true,"schema":{"type":"string","examples":["kl_testclinic01"]},"description":"The clinic's id (kl_ + 12 characters). The clinic gives it to you, or you find it with GET /clinics."},{"name":"service_id","in":"query","required":true,"schema":{"type":"string"},"description":"A service id from GET /clinics/{clinic_id}."},{"name":"from","in":"query","schema":{"type":"string","format":"date"},"description":"First day (default: today)."},{"name":"to","in":"query","schema":{"type":"string","format":"date"},"description":"Last day (default: from + 13 days; at most from + 30)."},{"name":"practitioner_id","in":"query","schema":{"type":"string"},"description":"Only this practitioner."}],"responses":{"200":{"description":"The available times.","content":{"application/json":{"schema":{"type":"object","required":["slots"],"properties":{"clinic_id":{"type":"string"},"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"},"time_zone":{"type":"string"},"slots":{"type":"array","items":{"$ref":"#/components/schemas/Slot"}},"test":{"type":"boolean"}}}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/clinics/{clinic_id}/referrals":{"post":{"operationId":"createReferral","tags":["Referrals"],"summary":"Refer a patient — and optionally book the first appointment","description":"Without \"appointment\" the patient is invited to book a time themselves. With it, the time is booked; if it was taken in the meantime: 409 slot_taken with five alternatives. The response never reveals whether the person was already a patient of the clinic.","parameters":[{"name":"clinic_id","in":"path","required":true,"schema":{"type":"string","examples":["kl_testclinic01"]},"description":"The clinic's id (kl_ + 12 characters). The clinic gives it to you, or you find it with GET /clinics."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReferralCreate"}}}},"responses":{"201":{"description":"The referral was created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Referral"}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The clinic has not given you permission to refer. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The time was taken (with \"alternatives\"), the external_id was already used (with \"referral_id\"), the Idempotency-Key was reused with another body, or the clinic has no practitioner open to you. Codes: slot_taken, duplicate_external_id, idempotency_conflict, not_bookable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/clinics/{clinic_id}/connection":{"get":{"operationId":"getConnection","tags":["Clinics"],"summary":"Is the clinic connected?","description":"\"none\" is also the answer for an id that does not exist and for a clinic that has said no. \"interested\": the clinic has applied to work with you and waits for your answer.","parameters":[{"name":"clinic_id","in":"path","required":true,"schema":{"type":"string","examples":["kl_testclinic01"]},"description":"The clinic's id (kl_ + 12 characters). The clinic gives it to you, or you find it with GET /clinics."}],"responses":{"200":{"description":"The state of the connection.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["none","requested","interested","connected"]},"test":{"type":"boolean"}}}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"answerApplication","tags":["Applications"],"summary":"Accept or decline a clinic's application","description":"Only for a clinic with status \"interested\". \"accepted\" connects the clinic at once, with the choices it made when it applied. Without an application the answer is the same 404 as for an id that does not exist.","parameters":[{"name":"clinic_id","in":"path","required":true,"schema":{"type":"string","examples":["kl_testclinic01"]},"description":"The clinic's id (kl_ + 12 characters). The clinic gives it to you, or you find it with GET /clinics."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["accepted","declined"]},"message":{"type":"string","maxLength":200,"description":"With \"declined\": a short line the clinic sees, as plain text."}}}}}},"responses":{"200":{"description":"Answered.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["connected","declined"]},"test":{"type":"boolean"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The clinic is already connected (and you sent \"declined\"), or the Idempotency-Key was reused with another body. Codes: already_connected, idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"requestConnection","tags":["Clinics"],"summary":"Ask a clinic to connect your organisation","description":"Always answers 202, whether or not the id exists. The clinic's administrator sees the request and says yes or no. At most 50 requests per day, and one per clinic every 30 days after a no.","parameters":[{"name":"clinic_id","in":"path","required":true,"schema":{"type":"string","examples":["kl_testclinic01"]},"description":"The clinic's id (kl_ + 12 characters). The clinic gives it to you, or you find it with GET /clinics."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","maxLength":200,"description":"Shown to the clinic as plain text."}}}}}},"responses":{"202":{"description":"Received.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["requested"]},"test":{"type":"boolean"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was reused with another body. Codes: idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/referrals":{"get":{"operationId":"listReferrals","tags":["Referrals"],"summary":"Your own referrals, across your clinics","parameters":[{"name":"clinic_id","in":"query","schema":{"type":"string"},"description":"Only this clinic."},{"name":"status","in":"query","schema":{"type":"string","enum":["invited","booked","pending_approval","cancelled","closed"]}},{"name":"updated_since","in":"query","schema":{"type":"string","format":"date-time"},"description":"Only referrals changed at or after this time."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"\"next_cursor\" from the previous page."}],"responses":{"200":{"description":"A page of referrals, oldest first.","content":{"application/json":{"schema":{"type":"object","required":["referrals"],"properties":{"referrals":{"type":"array","items":{"$ref":"#/components/schemas/Referral"}},"next_cursor":{"type":["string","null"]},"test":{"type":"boolean"}}}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/referrals/{referral_id}/appointment":{"put":{"operationId":"putAppointment","tags":["Referrals"],"summary":"Book or move the first appointment","parameters":[{"name":"referral_id","in":"path","required":true,"schema":{"type":"string"},"description":"The referral id (ref_…) returned when the referral was created."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentRequest"}}}},"responses":{"200":{"description":"The referral with the new appointment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Referral"}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No permission to book. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The time was taken, the patient has booked themselves, it is too close to the appointment, or the referral cannot be booked. Codes: slot_taken, already_booked, cancellation_window_passed, pending_approval, referral_closed, not_bookable, idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteAppointment","tags":["Referrals"],"summary":"Cancel the appointment you booked","description":"The clinic's cancellation notice applies (cancellation_notice_hours on the clinic); inside it the answer is 409 cancellation_window_passed.","parameters":[{"name":"referral_id","in":"path","required":true,"schema":{"type":"string"},"description":"The referral id (ref_…) returned when the referral was created."}],"responses":{"200":{"description":"The referral, now cancelled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Referral"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No permission to book. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Too close to the appointment, or there is no appointment booked by you. Codes: cancellation_window_passed, not_bookable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/referrals/{referral_id}/extend":{"post":{"operationId":"extendReferral","tags":["Referrals"],"summary":"More sessions granted","description":"Updates the grant at the clinic and tells the psychologist — it is the message she is otherwise waiting for.","parameters":[{"name":"referral_id","in":"path","required":true,"schema":{"type":"string"},"description":"The referral id (ref_…) returned when the referral was created."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["sessions_granted"],"properties":{"sessions_granted":{"type":"integer","minimum":1,"maximum":200,"description":"The new TOTAL number of sessions granted (not the number added)."},"valid_until":{"type":"string","format":"date"},"invoice_reference":{"type":"string","maxLength":60}}}}}},"responses":{"200":{"description":"The referral.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Referral"}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No permission to refer. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The referral is closed. Codes: referral_closed, idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/settings/invoicing":{"get":{"operationId":"getInvoicingTerms","tags":["Invoicing"],"summary":"Your invoicing terms — how clinics should invoice your organisation","responses":{"200":{"description":"The terms (version 0: none set yet).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoicingTerms"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"putInvoicingTerms","tags":["Invoicing"],"summary":"Set your invoicing terms","description":"Send only the fields you want to change; null resets a field. \"delivery\" and \"bill_to\" are replaced as a whole. The version counts up only when something actually changed. Your terms never change a clinic's invoicing by themselves: each clinic has said yes to one version, and a new version waits for the clinic's administrator, who chooses \"use the new terms\" or \"keep mine\". The PRICE is the clinic's own — it cannot be set through the API. A test key validates the call and changes nothing.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoicingTermsUpdate"}}}},"responses":{"200":{"description":"The terms after the change.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoicingTerms"}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was reused with another body. Codes: idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/referrals/{referral_id}":{"get":{"operationId":"getReferral","tags":["Referrals"],"summary":"One referral","parameters":[{"name":"referral_id","in":"path","required":true,"schema":{"type":"string"},"description":"The referral id (ref_…) returned when the referral was created."}],"responses":{"200":{"description":"The referral.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Referral"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The clinic has not given you permission to see status. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"patchReferral","tags":["Referrals"],"summary":"Correct the cap and the case id on a referral","description":"Send only what changes. \"sessions_granted\" is the highest number of sessions; fewer than already used answers 409 sessions_below_used with \"used\". The case number and the invoice reference are printed on the invoice when the clinic's rule for you has those fields. null clears a text, and removes the end date.","parameters":[{"name":"referral_id","in":"path","required":true,"schema":{"type":"string"},"description":"The referral id (ref_…) returned when the referral was created."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","minProperties":1,"properties":{"case_number":{"type":["string","null"],"maxLength":60},"invoice_reference":{"type":["string","null"],"maxLength":60},"sessions_granted":{"type":"integer","minimum":1,"maximum":200},"valid_until":{"type":["string","null"],"format":"date"}}}}}},"responses":{"200":{"description":"The referral.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Referral"}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No permission to refer. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Fewer sessions than already used (with \"used\"), or the referral is closed. Codes: sessions_below_used, referral_closed, idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/referrals/{referral_id}/sessions":{"get":{"operationId":"listSessions","tags":["Self-billing"],"summary":"Self-billing: the held sessions on a referral that the clinic has reported","description":"Only sessions on your own referral, only date and status — never content, never other appointments. Available when the clinic has accepted your self-billing terms.","parameters":[{"name":"referral_id","in":"path","required":true,"schema":{"type":"string"},"description":"The referral id (ref_…) returned when the referral was created."}],"responses":{"200":{"description":"The reported sessions, oldest first.","content":{"application/json":{"schema":{"type":"object","required":["sessions"],"properties":{"referral_id":{"type":"string"},"sessions":{"type":"array","items":{"$ref":"#/components/schemas/Session"}},"test":{"type":"boolean"}}}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The clinic has not accepted self-billing terms from you, or has not given the status permission. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/invoices":{"get":{"operationId":"listInvoices","tags":["Invoicing"],"summary":"The invoices clinics have issued to your organisation","description":"Only issued (booked) invoices and credit notes addressed to your organisation by clinics connected to you, issued after the connection. A clinic that disconnects issues no new ones here, but those already issued stay available for 5 years.","parameters":[{"name":"clinic_id","in":"query","schema":{"type":"string"},"description":"Only this clinic."},{"name":"issued_since","in":"query","schema":{"type":"string","format":"date-time"},"description":"Only invoices issued at or after this time."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"\"next_cursor\" from the previous page."}],"responses":{"200":{"description":"A page of invoices, oldest first.","content":{"application/json":{"schema":{"type":"object","required":["invoices"],"properties":{"invoices":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceSummary"}},"next_cursor":{"type":["string","null"]},"test":{"type":"boolean"}}}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/invoices/{invoice_id}":{"get":{"operationId":"getInvoice","tags":["Invoicing"],"summary":"One invoice or credit note, with its lines","description":"The lines carry only what the clinic's rule for your organisation allows: case number, your invoice reference, date — the patient's name, policy number, date of birth or national id only when the rule has them.","parameters":[{"name":"invoice_id","in":"path","required":true,"schema":{"type":"string"},"description":"The invoice id (inv_…) from GET /invoices or from the invoice.issued event."}],"responses":{"200":{"description":"The invoice.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/invoices/{invoice_id}/pdf":{"get":{"operationId":"getInvoicePdf","tags":["Invoicing"],"summary":"The invoice as PDF — the same document the clinic sends","parameters":[{"name":"invoice_id","in":"path","required":true,"schema":{"type":"string"},"description":"The invoice id (inv_…) from GET /invoices or from the invoice.issued event."}],"responses":{"200":{"description":"The PDF.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/invoices/{invoice_id}/oioubl":{"get":{"operationId":"getInvoiceOioubl","tags":["Invoicing"],"summary":"The invoice as OIOUBL (XML) — Danish clinics","description":"Your invoice reference is the order reference; the case number is an additional document reference. 404 when the clinic's country does not use the format.","parameters":[{"name":"invoice_id","in":"path","required":true,"schema":{"type":"string"},"description":"The invoice id (inv_…) from GET /invoices or from the invoice.issued event."}],"responses":{"200":{"description":"The OIOUBL document.","content":{"application/xml":{"schema":{"type":"string"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/invoices/{invoice_id}/payment-notice":{"post":{"operationId":"postPaymentNotice","tags":["Invoicing"],"summary":"Tell the clinic that an invoice has been paid","description":"A NOTICE the clinic sees. It does not record the payment — unless the clinic has switched on «trust this organisation's payment notices» for you (off by default); \"recorded\" says which.","parameters":[{"name":"invoice_id","in":"path","required":true,"schema":{"type":"string"},"description":"The invoice id (inv_…) from GET /invoices or from the invoice.issued event."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["paid_on","amount"],"properties":{"paid_on":{"type":"string","format":"date"},"amount":{"type":"number","description":"In the invoice's currency, at most two decimals."},"reference":{"type":"string","maxLength":80}}}}}},"responses":{"201":{"description":"Received.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["received"]},"invoice_id":{"type":"string"},"recorded":{"type":"boolean"},"note":{"type":"string"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was reused with another body, or the invoice is a credit note or has been credited. Codes: idempotency_conflict, not_bookable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/clinics/{clinic_id}/self-billing-invoices":{"post":{"operationId":"createSelfBillingInvoice","tags":["Self-billing"],"summary":"Self-billing: send the settlement document you have issued yourself","description":"For organisations that bill themselves (\"billing\": \"self_billing\" in your invoicing terms, accepted by the clinic). The clinic makes no invoice for sessions on your referrals; you send the document, and each line is matched to a held session (by \"session_id\", otherwise by date). The lines must add up to \"total\" (plus VAT, when not exempt) — otherwise 422 total_mismatch with the difference. The PDF must be a PDF, at most 5 MB. \"currency\" must be the clinic's own. Line amounts are never negative — except on a credit: \"credit_of\" (the id of a document, never of another credit) with negative amounts; a credit line with the credited line's amount and the opposite sign makes the session stand as not settled again, any other amount is reported as amount_differs.","parameters":[{"name":"clinic_id","in":"path","required":true,"schema":{"type":"string","examples":["kl_testclinic01"]},"description":"The clinic's id (kl_ + 12 characters). The clinic gives it to you, or you find it with GET /clinics."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SelfBillingInvoiceCreate"}}}},"responses":{"201":{"description":"Received and matched.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SelfBillingInvoice"}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The clinic has not accepted self-billing from you, you have already sent a document with this number to this clinic (with \"self_billing_invoice_id\"), or the Idempotency-Key was reused with another body. Codes: self_billing_not_enabled, duplicate_number, idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The PDF is over 5 MB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. total_mismatch carries \"lines_sum\", \"total\" and \"difference\". Codes: validation_failed, total_mismatch.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/self-billing-invoices":{"get":{"operationId":"listSelfBillingInvoices","tags":["Self-billing"],"summary":"The self-billing invoices you have sent","parameters":[{"name":"clinic_id","in":"query","schema":{"type":"string"},"description":"Only this clinic."},{"name":"since","in":"query","schema":{"type":"string","format":"date-time"},"description":"Only documents received at or after this time."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"A page, oldest first.","content":{"application/json":{"schema":{"type":"object","required":["self_billing_invoices"],"properties":{"self_billing_invoices":{"type":"array","items":{"$ref":"#/components/schemas/SelfBillingInvoice"}},"next_cursor":{"type":["string","null"]},"test":{"type":"boolean"}}}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/self-billing-invoices/{self_billing_invoice_id}":{"get":{"operationId":"getSelfBillingInvoice","tags":["Self-billing"],"summary":"One self-billing invoice: its status at the clinic","parameters":[{"name":"self_billing_invoice_id","in":"path","required":true,"schema":{"type":"string"},"description":"The id (sbi_…) returned when you sent the document."}],"responses":{"200":{"description":"The document.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SelfBillingInvoice"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The id does not exist — or the clinic has not connected your organisation. The two cannot be told apart. Codes: not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook":{"get":{"operationId":"getWebhook","tags":["Webhooks"],"summary":"Your webhook","responses":{"200":{"description":"The webhook (url null when none is set).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"operationId":"putWebhook","tags":["Webhooks"],"summary":"Set the webhook address — returns a new signing secret, once","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri","description":"https only; addresses on internal networks are refused."},"events":{"type":"array","items":{"type":"string","enum":["referral.booked","referral.patient_completed","referral.appointment_moved","referral.appointment_cancelled","referral.approved","referral.declined","referral.sessions_low","clinic.connected","clinic.disconnected","clinic.interested","clinic.application_withdrawn","referral.extension_requested","invoice.issued","credit_note.issued","session.completed","session.no_show","self_billing_invoice.disputed"]},"description":"Leave out to receive all events."}}}}}},"responses":{"200":{"description":"The webhook and its secret.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Webhook"},{"type":"object","properties":{"secret":{"type":"string","description":"whsec_… — shown once."},"note":{"type":"string"}}}]}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"A test key cannot replace a webhook that was set with a live key. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was reused with another body. Codes: idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteWebhook","tags":["Webhooks"],"summary":"Remove the webhook","responses":{"200":{"description":"Removed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"A test key cannot remove a webhook that was set with a live key. Codes: forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook/test":{"post":{"operationId":"testWebhook","tags":["Webhooks"],"summary":"Send a signed \"ping\" event to your webhook now","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":128},"description":"Any unique string per logical request. The same key with the same body returns the first response again; with a different body: 409 idempotency_conflict. Kept for 24 hours."}],"responses":{"200":{"description":"Whether your server answered 2xx.","content":{"application/json":{"schema":{"type":"object","properties":{"delivered":{"type":"boolean"},"status":{"type":["integer","null"]},"event_id":{"type":"string"}}}}}},"400":{"description":"The body is not valid JSON. Codes: malformed_json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The key is missing, unknown or revoked. Codes: unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was reused with another body. Codes: idempotency_conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is over 64 kB. Codes: payload_too_large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The request is not valid; \"field\" names the field. Codes: validation_failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Too many requests; see Retry-After. Codes: rate_limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{"referral.booked":{"post":{"summary":"A first appointment exists for the referral (booked by you or by the patient).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"referral.patient_completed":{"post":{"summary":"The patient has filled in their own details with the clinic.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"referral.appointment_moved":{"post":{"summary":"The appointment you booked was moved.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"referral.appointment_cancelled":{"post":{"summary":"The appointment you booked was cancelled.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"referral.approved":{"post":{"summary":"The clinic approved a referral that was pending approval.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"referral.declined":{"post":{"summary":"The clinic declined a referral that was pending approval.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"referral.sessions_low":{"post":{"summary":"Two or fewer granted sessions remain (only with the sessions permission).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"clinic.connected":{"post":{"summary":"A clinic connected your organisation.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"clinic.disconnected":{"post":{"summary":"A clinic disconnected your organisation.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"clinic.interested":{"post":{"summary":"A clinic has applied to work with your organisation and waits for your answer.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"clinic.application_withdrawn":{"post":{"summary":"A clinic withdrew its application before you answered.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"referral.extension_requested":{"post":{"summary":"The clinic asks for more sessions on a referral: a session has been held beyond what is granted (data.sessions, data.note).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"invoice.issued":{"post":{"summary":"The clinic has issued an invoice to your organisation (data.invoice_id).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"credit_note.issued":{"post":{"summary":"The clinic has issued a credit note for one of your invoices (data.invoice_id, data.credit_of).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"session.completed":{"post":{"summary":"Self-billing: a session on one of your referrals has been held (data.session_id, data.date).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"session.no_show":{"post":{"summary":"Self-billing: the client did not attend, and the grant covers no-shows (data.session_id, data.date).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"self_billing_invoice.disputed":{"post":{"summary":"The clinic disputes a self-billing invoice you sent (data.self_billing_invoice_id, data.note).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}},"ping":{"post":{"summary":"Sent by POST /webhook/test.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"responses":{"200":{"description":"Answer 2xx within 8 seconds."}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"ah_live_… (issued by Anotera) or ah_test_… (the test clinic only)."}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["unauthorized","forbidden","not_found","method_not_allowed","validation_failed","malformed_json","slot_taken","idempotency_conflict","duplicate_external_id","already_booked","cancellation_window_passed","not_bookable","pending_approval","referral_closed","rate_limited","payload_too_large","already_connected","key_limit_reached","sessions_below_used","self_billing_not_enabled","duplicate_number","total_mismatch","server_error","unavailable"]},"message":{"type":"string"},"field":{"type":"string"},"alternatives":{"type":"array","items":{"$ref":"#/components/schemas/Slot"}},"referral_id":{"type":"string"},"cancellation_notice_hours":{"type":"integer"},"used":{"type":"integer","description":"With sessions_below_used: the number of sessions already used."},"self_billing_invoice_id":{"type":"string","description":"With duplicate_number."},"lines_sum":{"type":"number"},"total":{"type":"number"},"difference":{"type":"number","description":"With total_mismatch."}}}}},"ClinicSummary":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"address":{"type":"string"},"time_zone":{"type":"string","examples":["Europe/Copenhagen"]},"api_base":{"type":"string","description":"Where to call this clinic. Today always this server."},"status":{"type":"string","enum":["interested"],"description":"Only in the list of applicants (status=interested)."},"applied_at":{"type":"string","format":"date-time","description":"Only for applicants."},"first_available_in_days":{"type":["integer","null"],"description":"Only for applicants: days until the clinic's first available time, worked out at the moment you ask. null: none within 60 days."}}},"ClinicApplication":{"type":"object","required":["id","name","status"],"description":"A clinic that has applied to work with your organisation: its own business details — never anything about patients. Exactly what the clinic saw in its preview before it sent the application.","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["interested"]},"applied_at":{"type":"string","format":"date-time"},"message":{"type":["string","null"],"description":"A short greeting from the clinic (≤ 600 characters), plain text."},"vat_number":{"type":["string","null"]},"address":{"type":["string","null"]},"website":{"type":["string","null"]},"time_zone":{"type":"string"},"api_base":{"type":"string"},"contact":{"type":"object","properties":{"name":{"type":["string","null"]},"phone":{"type":["string","null"]},"email":{"type":["string","null"]}}},"practitioners":{"type":"array","description":"Only the practitioners the clinic chose to include.","items":{"type":"object","properties":{"name":{"type":"string"},"title":{"type":["string","null"]},"authorised":{"type":"boolean"},"authorisation_id":{"type":["string","null"],"description":"When the practitioner's profile has it."},"languages":{"type":"array","items":{"type":"string"}},"methods":{"type":"array","items":{"type":"string"}},"modes":{"type":"array","items":{"type":"string","enum":["in_person","video"]}}}}},"first_available_in_days":{"type":["integer","null"]}}},"Settings":{"type":"object","properties":{"accepting_applications":{"type":"boolean","description":"false: clinics see «not accepting applications through Anotera right now». You can still ask a clinic yourself."},"applications_email":{"type":["string","null"],"description":"Where the email about a clinic's application is sent. null: no email — applications still show in the API."},"test":{"type":"boolean"}}},"SignUp":{"type":"object","required":["organisation_name","vat_number","country","website","contact_name","email","phone","accept_terms"],"properties":{"organisation_name":{"type":"string","maxLength":80},"vat_number":{"type":"string","maxLength":24,"description":"Company registration or VAT number."},"country":{"type":"string","minLength":2,"maxLength":2,"examples":["DK"]},"website":{"type":"string","maxLength":200},"contact_name":{"type":"string","maxLength":80},"email":{"type":"string","format":"email","description":"A work address at your organisation's own domain."},"phone":{"type":"string","examples":["+4533123456"]},"purpose":{"type":"string","maxLength":500},"applications_email":{"type":"string","format":"email","description":"Optional: where clinics' applications to work with you are sent."},"accept_terms":{"type":"boolean","enum":[true],"description":"The clinic is the data controller, and access to a clinic requires the clinic's own yes."},"language":{"type":"string","enum":["da","en","it"]}}},"Clinic":{"allOf":[{"$ref":"#/components/schemas/ClinicSummary"},{"type":"object","properties":{"practitioners":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"title":{"type":"string"},"languages":{"type":"array","items":{"type":"string"}}}}},"services":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"duration_minutes":{"type":"integer"},"mode":{"type":"string","enum":["in_person","video","in_person_or_video"]}}}},"cancellation_notice_hours":{"type":"integer"},"booking":{"type":"string","enum":["immediate","requires_approval"]},"booking_horizon_days":{"type":"integer"},"permissions":{"type":"array","items":{"type":"string","enum":["refer","status","sessions"]}},"test":{"type":"boolean"}}}]},"Slot":{"type":"object","required":["start","end","practitioner_id","service_id"],"properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"},"practitioner_id":{"type":"string"},"service_id":{"type":"string"},"mode":{"type":"string","enum":["in_person","video","in_person_or_video"]}}},"AppointmentRequest":{"type":"object","required":["start"],"properties":{"start":{"type":"string","format":"date-time","description":"A \"start\" from availability, with offset."},"practitioner_id":{"type":"string"},"service_id":{"type":"string"},"mode":{"type":"string","enum":["in_person","video"]}}},"ReferralCreate":{"type":"object","required":["external_id","patient"],"properties":{"external_id":{"type":"string","maxLength":80,"description":"Your own id for the referral. Unique per clinic."},"patient":{"type":"object","required":["first_name"],"description":"At least a phone or an email.","properties":{"first_name":{"type":"string","maxLength":60},"last_name":{"type":"string","maxLength":60},"phone":{"type":"string","examples":["+4520123456"]},"email":{"type":"string","format":"email"},"date_of_birth":{"type":"string","format":"date"},"national_id":{"type":"string","writeOnly":true,"description":"CPR number etc. Stored on the patient's card at the clinic and NEVER returned."}}},"case_number":{"type":"string","maxLength":60},"invoice_reference":{"type":"string","maxLength":60,"description":"Your own text for the invoice."},"sessions_granted":{"type":"integer","minimum":1,"maximum":200},"valid_until":{"type":"string","format":"date"},"note_to_clinic":{"type":"string","maxLength":2000,"writeOnly":true,"description":"Confidential text for the psychologist. Never returned."},"appointment":{"$ref":"#/components/schemas/AppointmentRequest"},"practitioner_id":{"type":"string","description":"Without \"appointment\": the practitioner the patient is invited to."},"service_id":{"type":"string","description":"Without \"appointment\": the service the patient is invited to book."},"notify_patient":{"type":"boolean","default":true,"description":"Send the clinic's invitation to the patient."}}},"Referral":{"type":"object","required":["id","clinic_id","status"],"properties":{"id":{"type":"string"},"clinic_id":{"type":"string"},"external_id":{"type":["string","null"]},"status":{"type":"string","enum":["invited","booked","pending_approval","cancelled","closed"]},"appointment":{"oneOf":[{"type":"null"},{"allOf":[{"$ref":"#/components/schemas/Slot"},{"type":"object","properties":{"booked_by":{"type":"string","enum":["referrer"]}}}]}],"description":"Only an appointment YOU booked. A time the patient booked is never shown."},"first_appointment_booked":{"type":"boolean","description":"True when a first appointment exists — booked by you or by the patient."},"patient_invited":{"type":"boolean"},"patient_completed":{"type":"boolean"},"case_number":{"type":["string","null"]},"invoice_reference":{"type":["string","null"]},"sessions":{"type":"object","description":"Only when the clinic has given the \"sessions\" permission.","properties":{"granted":{"type":"integer"},"used":{"type":"integer"},"remaining":{"type":"integer"},"valid_until":{"type":["string","null"],"format":"date"}}},"extension_request":{"type":"object","description":"The clinic asks for more sessions: a session has been held beyond the cap, and you are never invoiced beyond it by itself. Answer with POST /referrals/{referral_id}/extend.","properties":{"sessions":{"type":"integer","description":"How many more sessions the clinic asks for."},"requested_at":{"type":"string","format":"date-time"},"note":{"type":"string","description":"A short line from the clinic — never health information."}}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"test":{"type":"boolean"}}},"InvoicingTermsUpdate":{"type":"object","properties":{"billing":{"type":["string","null"],"enum":["clinic_invoices","self_billing",null],"description":"\"self_billing\": you issue the settlement document yourself; the clinic makes no invoice."},"schedule":{"type":["string","null"],"enum":["per_session","monthly",null]},"invoice_day":{"type":["integer","null"],"minimum":1,"maximum":28,"description":"With \"monthly\": the day of the month on which the previous month is invoiced. Default 1."},"grouping":{"type":["string","null"],"enum":["per_patient","combined","statement_only",null],"description":"\"combined\": one invoice with every patient's sessions. \"statement_only\": no invoice, a statement. Both need \"monthly\"."},"required_references":{"type":["array","null"],"items":{"type":"string","enum":["case_number","invoice_reference","policy_number","date_of_birth","session_times","national_id"]},"description":"What must be printed on the invoice. \"national_id\" is only printed when the clinic ticks it off explicitly."},"delivery":{"type":["object","null"],"required":["method"],"properties":{"method":{"type":"string","enum":["email","ean","api"],"description":"\"api\": no email — you collect the invoices with GET /invoices."},"email":{"type":"string","format":"email"},"ean":{"type":"string","description":"13 digits."}}},"payment_terms_days":{"type":["integer","null"],"minimum":1,"maximum":180},"bill_to":{"type":["object","null"],"required":["name"],"properties":{"name":{"type":"string","maxLength":80},"vat_number":{"type":"string","maxLength":20},"address":{"type":"string","maxLength":120},"postal_code":{"type":"string","maxLength":12},"city":{"type":"string","maxLength":60},"country":{"type":"string","minLength":2,"maxLength":2},"attention":{"type":"string","maxLength":80}}},"note":{"type":["string","null"],"maxLength":300,"description":"Shown to the clinic as plain text."}}},"InvoicingTerms":{"type":"object","required":["version"],"properties":{"version":{"type":"integer","description":"0: no terms set. Counts up each time the terms change."},"updated_at":{"type":["string","null"],"format":"date-time"},"billing":{"type":"string","enum":["clinic_invoices","self_billing"]},"schedule":{"type":"string","enum":["per_session","monthly"]},"invoice_day":{"type":["integer","null"]},"grouping":{"type":"string","enum":["per_patient","combined","statement_only"]},"required_references":{"type":"array","items":{"type":"string","enum":["case_number","invoice_reference","policy_number","date_of_birth","session_times","national_id"]}},"delivery":{"type":"object","properties":{"method":{"type":"string","enum":["email","ean","api"]},"email":{"type":["string","null"]},"ean":{"type":["string","null"]}}},"payment_terms_days":{"type":"integer"},"bill_to":{"type":["object","null"],"properties":{"name":{"type":"string"},"vat_number":{"type":["string","null"]},"address":{"type":["string","null"]},"postal_code":{"type":["string","null"]},"city":{"type":["string","null"]},"country":{"type":["string","null"]},"attention":{"type":["string","null"]}}},"note":{"type":["string","null"]},"test":{"type":"boolean"}}},"InvoiceSummary":{"type":"object","required":["id","clinic_id","type","number"],"properties":{"id":{"type":"string"},"clinic_id":{"type":"string"},"type":{"type":"string","enum":["invoice","credit_note"]},"number":{"type":"string","description":"The clinic's own invoice number."},"issue_date":{"type":"string","format":"date"},"due_date":{"type":["string","null"],"format":"date"},"currency":{"type":"string"},"total":{"type":"number","description":"Including VAT. Negative on a credit note."},"status":{"type":"string","enum":["issued","partly_paid","paid","credited"]},"credit_of":{"type":["string","null"],"description":"On a credit note: the id of the invoice it credits."},"issued_at":{"type":"string","format":"date-time"}}},"Invoice":{"allOf":[{"$ref":"#/components/schemas/InvoiceSummary"},{"type":"object","properties":{"seller":{"type":"object","properties":{"name":{"type":["string","null"]},"vat_number":{"type":["string","null"]},"address":{"type":["string","null"]},"bank":{"type":["object","null"],"properties":{"name":{"type":["string","null"]},"registration_number":{"type":["string","null"]},"account_number":{"type":["string","null"]},"iban":{"type":["string","null"]},"bic":{"type":["string","null"]}}}}},"buyer":{"type":"object","properties":{"name":{"type":["string","null"]},"vat_number":{"type":["string","null"]},"address":{"type":["string","null"]},"ean":{"type":["string","null"]}}},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string"},"date":{"type":["string","null"],"format":"date"},"time":{"type":"string"},"case_number":{"type":"string"},"invoice_reference":{"type":"string"},"patient_name":{"type":"string","description":"Only when the clinic's rule has it."},"policy_number":{"type":"string"},"date_of_birth":{"type":"string","format":"date"},"national_id":{"type":"string","description":"Only when the clinic has ticked it off explicitly."},"quantity":{"type":"number"},"unit_price":{"type":"number"},"amount":{"type":"number","description":"Excluding VAT."},"vat":{"oneOf":[{"type":"object","properties":{"exempt":{"type":"boolean","enum":[true]}}},{"type":"object","properties":{"rate":{"type":"number"},"amount":{"type":"number"}}}]}}}},"subtotal":{"type":"number"},"vat_total":{"type":"number"},"amount_paid":{"type":"number"},"amount_due":{"type":"number"},"payment_notices":{"type":"array","items":{"type":"object","properties":{"paid_on":{"type":"string","format":"date"},"amount":{"type":"number"},"reference":{"type":["string","null"]},"received_at":{"type":"string","format":"date-time"},"recorded":{"type":"boolean"}}}},"pdf_url":{"type":"string"},"oioubl_url":{"type":["string","null"]}}}]},"Session":{"type":"object","required":["id","date","status"],"properties":{"id":{"type":"string"},"date":{"type":"string","format":"date"},"status":{"type":"string","enum":["completed","no_show"],"description":"\"no_show\" only when the grant covers no-shows."},"service_id":{"type":["string","null"]},"reported_at":{"type":["string","null"],"format":"date-time"},"settled_by":{"type":"string","description":"The number of the self-billing invoice that settled the session."}}},"SelfBillingInvoiceCreate":{"type":"object","required":["number","issue_date","currency","lines","total","vat","pdf"],"properties":{"number":{"type":"string","maxLength":40,"description":"YOUR document number. Unique per clinic."},"issue_date":{"type":"string","format":"date"},"period":{"type":"object","properties":{"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"}}},"currency":{"type":"string","examples":["DKK"]},"lines":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","required":["referral_id","amount"],"properties":{"referral_id":{"type":"string"},"session_id":{"type":"string","description":"From GET /referrals/{referral_id}/sessions or the session.completed event. Preferred."},"session_date":{"type":"string","format":"date","description":"Used when there is no session_id."},"case_number":{"type":"string","maxLength":60},"description":{"type":"string","maxLength":120},"amount":{"type":"number","description":"Excluding VAT, at most two decimals. Negative on a credit."}}}},"total":{"type":"number","description":"The lines plus the VAT."},"vat":{"oneOf":[{"type":"object","required":["exempt"],"properties":{"exempt":{"type":"boolean","enum":[true]}}},{"type":"object","required":["rate","amount"],"properties":{"rate":{"type":"number"},"amount":{"type":"number"}}}]},"payment":{"type":"object","properties":{"date":{"type":"string","format":"date"},"reference":{"type":"string","maxLength":80}}},"pdf":{"type":"string","contentEncoding":"base64","contentMediaType":"application/pdf","writeOnly":true,"description":"The document itself, base64, at most 5 MB. Must be a PDF."},"credit_of":{"type":"string","description":"For a credit: the id (sbi_…) of the document it credits."}}},"SelfBillingInvoice":{"type":"object","required":["id","status"],"properties":{"id":{"type":"string"},"clinic_id":{"type":"string"},"number":{"type":"string"},"issue_date":{"type":"string","format":"date"},"period":{"type":["object","null"],"properties":{"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"}}},"currency":{"type":"string"},"total":{"type":"number"},"status":{"type":"string","enum":["received","matched","disputed"],"description":"\"matched\": every line met a held session at the clinic's own amount (or the clinic approved it anyway). \"received\": the clinic is looking at the lines in \"unmatched\". \"disputed\": the clinic objects — see \"dispute\"."},"credit_of":{"type":["string","null"]},"received_at":{"type":"string","format":"date-time"},"matched":{"type":"integer","description":"Lines matched to a held session."},"unmatched":{"type":"array","items":{"type":"object","properties":{"line":{"type":"integer","description":"Index into \"lines\", from 0."},"referral_id":{"type":"string"},"reason":{"type":"string","enum":["unknown_session","amount_differs","already_invoiced","already_settled"]},"clinic_amount":{"type":"number","description":"With amount_differs: the clinic's own amount for the session."}}}},"dispute":{"type":"object","properties":{"note":{"type":["string","null"]},"at":{"type":"string","format":"date-time"}}},"test":{"type":"boolean"}}},"Webhook":{"type":"object","properties":{"url":{"type":["string","null"]},"events":{"type":"array","items":{"type":"string"}},"active":{"type":"boolean"},"failures":{"type":"integer"},"set_with":{"type":["string","null"],"enum":["live","test",null],"description":"The kind of key the address was set with. A webhook set with a test key only receives test events, and a test key cannot replace or remove one set with a live key."}}},"Event":{"type":"object","required":["id","type","created"],"properties":{"id":{"type":"string"},"type":{"type":"string","enum":["referral.booked","referral.patient_completed","referral.appointment_moved","referral.appointment_cancelled","referral.approved","referral.declined","referral.sessions_low","clinic.connected","clinic.disconnected","clinic.interested","clinic.application_withdrawn","referral.extension_requested","invoice.issued","credit_note.issued","session.completed","session.no_show","self_billing_invoice.disputed","ping"]},"created":{"type":"string","format":"date-time"},"clinic_id":{"type":["string","null"]},"referral_id":{"type":"string"},"external_id":{"type":["string","null"]},"test":{"type":"boolean"},"data":{"type":"object"}}}}}}