PlaySpace

Core concepts

The ideas the rest of this site assumes. If you understand these, everything else is reference material you can look up when you need it.


The organisation is the tenancy boundary

Your credentials are issued to one partner organisation, and every request is scoped to it. You never send an organisation identifier: it is read from the token.

The consequence is that another organisation's data is not merely refused, it is unaddressable. An identifier belonging to someone else behaves exactly like an identifier that never existed, and both answer 404. There is no configuration, no scope and no parameter that widens the view past your own organisation.

A patient created by your organisation is yours alone. The same child may exist independently under another organisation, and the two records never meet.


The clinic is the partition inside it

Everything else hangs off a clinic. A practitioner belongs to exactly one clinic; a patient names the clinic it belongs to and the practitioner who created it; an appointment links one practitioner and one patient who belong to the same clinic.

That is the whole hierarchy. There is nothing above the clinic and nothing beside the patient, because caregiver and dependent links are internal to PlaySpace and have no partner surface.

Deleting is soft and constrained. A clinic that still holds active practitioners, patients or appointments answers 409 with problem type clinic-not-empty and the counts of what is blocking it, so you clear or reassign before you retire.


Two credentials, and only one reaches a browser

Your client credentials are an OAuth2 client-credentials pair. Your backend exchanges them for an access token that lives 24 hours and carries your organisation's whole grant. Neither the pair nor the token ever belongs in a browser.

A sign-in code is what the browser holds instead. Your backend mints one for a single practitioner with POST /v1/partner/practitioners/{id}/sign-in-codes, and it is worth very little to anyone who intercepts it: it works once, stops working 60 seconds after it was minted, signs in only that practitioner, and opens PlaySpace only inside the origins your organisation listed. It goes to exactly one place, the frame's first address or one message addressed to the PlaySpace origin, and @playspace-health/embed puts it there for you.

The decision a sign-in code carries, this browser belongs to this clinician, is made by your backend. PlaySpace checks that the practitioner is yours and able to sign in; it cannot check that the person in front of the browser is them. That check is your sign-in code route's whole job.


A framed clinician is a PlaySpace clinician

Once a code is exchanged, the frame holds an ordinary PlaySpace session for that practitioner. Every page and every request inside it passes the same permission checks, the same row-level data rules and the same feature entitlements as a clinician who signs in to PlaySpace directly. Nothing in the frame is a partner copy of a feature.

Sessions have the same limits as a direct clinician's: 24 hours from sign-in, and 1 hour without activity. When either is reached, the frame asks your page for a fresh code and reconnects without a page load where it can. With @playspace-health/embed this is one more call to your getCode, which must answer within 10 seconds.

A session ends when your page calls signOut(), when a limit is reached and no code arrives, or when you disable the practitioner (PATCH /v1/partner/practitioners/{id} with status: "disabled") or delete them. Disabling or deleting ends their open session the next time the dashboard checks who is signed in, and no new code can be minted for them until you set status back to active. The frame then shows a signed-out page and tells your page with onSignedOut.

The session cookies are set inside your page's frame only (SameSite=None; Secure; Partitioned), so a PlaySpace session in your product never mixes with a PlaySpace tab the same person might have open elsewhere.


Settings belong to the organisation

One settings object, read with GET /v1/partner/settings and changed with PATCH, applies to every clinician in your organisation: the origins allowed to frame PlaySpace, the feature areas you switch off, whether PlaySpace contacts your patients, whether sessions may be recorded, and supplied video. Nothing in it waits on PlaySpace to open it up. Settings is the field reference.


Scopes are one per resource and verb

Your granted scopes are fixed on the credential at approval and travel inside the token; you never send them. There is a read, write and delete scope for each of clinics, practitioners, patients and appointments, plus sessions:write, which mints sign-in codes. Reading your settings needs practitioners:read, and changing them needs practitioners:write.

A call outside your grant returns 403 with problem type forbidden, carrying both required_scopes and granted_scopes in full. The table is on authentication.


Every write carries an idempotency key

POST, PATCH and DELETE require an Idempotency-Key header: an opaque string of your choosing, unique to one logical operation. The one exception is minting a sign-in code, which takes no key because every call must mint a new code.

Situation Result
Same key, same payload, within 24 hours The original response is replayed and the operation is not performed twice
Same key, different payload 422 with problem type idempotency-key-mismatch
Same key while the original is still in flight 409 with problem type idempotency-conflict. Retry once it settles

Keys live 24 hours, after which the same string starts a fresh operation. A missing key on a write is a 422, not a warning.

The reason it is required rather than optional: a network timeout on a create leaves you unable to tell whether the record exists. With a key, the retry is safe and the answer is definitive.


Lists are cursor-paginated

Pass limit to set the page size. It defaults to 25 and is capped at 100. To fetch the next page, pass the cursor value from meta.pagination.next_cursor; next_cursor is null when the list is fully consumed.

GET /v1/partner/patients?limit=50 HTTP/1.1
GET /v1/partner/patients?limit=50&cursor=<next_cursor> HTTP/1.1

Treat a cursor as opaque and never construct one. Offsets are not supported and will not be added: they produce duplicates and gaps when a list changes mid-walk, which for a caseload is not hypothetical.

Filters are applied before pagination, so they hold consistently across pages. Every filter on this API is an identifier, an enumerated value or a timestamp. There is no free-text search parameter anywhere on it, deliberately, because a platform's own request logs record the query string of every request before anything at the application layer can act on it.


Rate limits are two windows

Limits apply per organisation across a per-minute and a per-hour window, and the more restrictive one governs. Every response carries the remaining count and the refill time for both:

X-RateLimit-Minute-Remaining, X-RateLimit-Minute-Reset
X-RateLimit-Hour-Remaining,   X-RateLimit-Hour-Reset

Exceeding either returns 429 with Retry-After. Honour it. The most common way to hit a limit that has nothing to do with your real traffic is minting a fresh access token per request instead of caching one.


Every failure is a problem document

Non-2xx responses are RFC 9457 problem documents served as application/problem+json, carrying type, title, status and detail, plus extension members specific to the problem, such as required_scopes on a 403 or dependent counts on a 409.

{
  "type": "https://api.playspace.health/problems/frame-origins-not-set",
  "title": "Frame origins not set",
  "status": 409,
  "detail": "Set frame_origins with PATCH /v1/partner/settings before minting a sign-in code."
}

Branch on type, never on title or detail, which are prose for a human reading a log and may be reworded. The problem-type identifiers are stable and deliberately not dereferenceable. The full catalogue is in the error reference.

Every response, success or failure, carries an X-Request-Id header. Log it, and quote it when you contact us: it addresses one request in our audit history.


Deletion is soft, and 404 is one answer to three questions

Deletes de-list rather than destroy. A deleted resource answers 404 on a read and is omitted from lists, unless the list offers include_deleted=true and you ask for it.

A nonexistent identifier, another organisation's identifier and a deleted identifier all return one identical 404, and its detail never echoes the identifier you sent. Distinguishing them is exactly the signal an enumeration attack needs. Repeating a DELETE returns that same 404, and only an idempotency-key replay of the original observes the prior success.

Appointments have no delete. Retire one by setting status to cancelled.


Identifiers and payload shape

Identifiers are version-4 UUIDs assigned by PlaySpace. Store the identifier each create returns; it is what every path takes. To find a clinic, practitioner or patient by your own identifier instead, set its external_id, below.

Every success response is an envelope of data and meta, where meta carries the request identifier and, on a list, meta.pagination. Wire format is snake_case throughout. Timestamps are ISO-8601 with an explicit offset; a date of birth is YYYY-MM-DD and unzoned.

The conventions that hold across the whole API are in API conventions.


Your own identifiers: external_id

Clinics, practitioners and patients each carry an optional external_id: your system's identifier for the same record, such as a medical record number. Appointments do not.

  • Set it on POST or PATCH. On a PATCH, a new value re-points it, null clears it, and leaving the field out leaves it unchanged.
  • Find by it with GET /v1/partner/clinics?external_id=… (and the same filter on /practitioners and /patients). The match is exact and case-sensitive, and the answer is an ordinary list holding at most one record that is not deleted.
  • Format: 1 to 128 printable ASCII characters, space through ~, so FHIR-style values such as urn:oid:1.2.3|MRN-0042 and paths with / fit. Anything else is a 422.
  • Unique per organisation, per resource, among records that are not deleted. Deleting a record frees its external_id for a new record; the deleted one is not revived.
  • A duplicate is a 409 with problem type external-id-conflict on the create or PATCH that would introduce it. There is no upsert: on a 409, look the record up by external_id and PATCH it.

Treat the value as protected health information. A medical record number identifies a patient. PlaySpace keeps it out of its own logs, error tracking and audit identifiers; keep it out of yours, and out of any URL you log. It is sent in a query string only on the lookup, where PlaySpace redacts it.