PlaySpace

Error reference

Every failure is an RFC 9457 problem document served as application/problem+json.

{
  "type": "https://api.playspace.health/problems/forbidden",
  "title": "Insufficient scope",
  "status": 403,
  "detail": "The presented token does not grant every scope this endpoint requires.",
  "required_scopes": ["patients:write"],
  "granted_scopes": ["patients:read", "appointments:read"]
}

type, title and status are always present. detail explains this occurrence, and problem-specific extension fields are spread onto the top level of the same object rather than nested.

Branch on type. It is a stable identifier: the set only grows, and an existing slug never changes meaning. title and detail are prose for a human reading a log and may be reworded at any time.

Log X-Request-Id on every failure. It is on every response, success or error, and quoting one to PlaySpace addresses a single request in our audit history.

The type is an absolute URI under https://api.playspace.health/problems/. It identifies the problem class and is deliberately not something you fetch — do not resolve it at runtime.


The catalogue

Slugs are relative to https://api.playspace.health/problems/.

unauthorized — 401

Missing, malformed or expired credentials.

Check that you sent Authorization: Bearer <token> with the literal Bearer prefix, that the token has not expired, and that it was issued for the audience PlaySpace gave you. An organisation whose access has been revoked also lands here, and re-fetching the token will not clear it.

forbidden — 403

Authenticated, but this credential may not do this.

On a scope failure, extensions required_scopes and granted_scopes carry both lists verbatim — the whole granted list, not just the missing subset — so the diagnosis is in the response. Minting a sign-in code without sessions:write lands here, and so does changing settings without practitioners:write. GET /v1/partner/events needs the read scope of at least one event type; with none it answers here with required_scopes_any_of in place of required_scopes.

partner-suspended — 403

Your organisation's account is suspended. Every request fails until it is restored. Contact PlaySpace; this is never a code problem.

delegation-not-enabled — 403

The token names a practitioner. The Partner API accepts only your organisation's token, so a token requested with a practitioner_id is refused on every operation, and detail does not echo the practitioner. Request the token without practitioner_id; to act as one clinician, sign them in to the frame with a sign-in code. A suspended organisation answers partner-suspended instead.

not-found — 404

The resource is absent, deleted, or belongs to another organisation.

These are deliberately indistinguishable, and detail never echoes the identifier you supplied. Distinguishing them is exactly the signal an enumeration attack needs. A repeated DELETE also lands here: only an idempotency replay of the original delete observes the prior success. A sign-in code for a practitioner who is not yours, or was deleted, is this 404 too, and so are session links for an appointment that was cancelled, because a cancelled appointment reads as deleted.

idempotency-conflict — 409

A request with this Idempotency-Key is still in flight. Retry in a few seconds; do not change the key.

A crashed original is treated as retriable after sixty seconds, so this clears itself.

partner-email-conflict — 409

The email supplied to POST /v1/partner/practitioners is already in use by an existing practitioner. Choose another.

clinic-name-conflict — 409

The clinic name supplied to POST /v1/partner/clinics is already held by another clinic in your organisation. Comparison is case-insensitive and scoped to you: the same name may legitimately exist under a different partner.

external-id-conflict — 409

The external_id on a clinic, practitioner or patient create or PATCH is already held by another record of the same kind in your organisation that is not deleted. Comparison is exact and case-sensitive. Not retriable with the same value: look the existing record up with GET ?external_id= and update it, or send a different value. The problem carries no detail about the record it collided with.

clinic-not-empty — 409

DELETE /v1/partner/clinics/{id} was called on a clinic that still has dependents. Extensions practitioner_count, patient_count and appointment_count carry the counts, so you can render an actionable message without a second round-trip.

Clear or reassign the dependents first. The delete is not retriable until the clinic is empty.

practitioner-unavailable — 409

POST /v1/partner/practitioners/{id}/sign-in-codes was called for a practitioner who cannot sign in: they are disabled, or they have not finished being set up. Set status back to active with PATCH /v1/partner/practitioners/{id} for a disabled one. Not retriable as it stands.

frame-origins-not-set — 409

POST /v1/partner/practitioners/{id}/sign-in-codes was called while your organisation has no frame_origins. Set at least one with PATCH /v1/partner/settings, then mint again.

video-configuration-changed — 409

Supplied video changed while your request was being saved, and nothing in the request was applied. Returned by PATCH /v1/partner/settings, and by an appointment write that carries supplied video. Read the current settings, check your request against them, and retry with a new Idempotency-Key.

webhook-endpoint-limit — 409

POST /v1/partner/webhook-endpoints was called while your organisation already has the most webhook endpoints it may register. Delete one with DELETE /v1/partner/webhook-endpoints/{id}, then create again. Not retriable as it stands. (The same 409 status is also idempotency-conflict while a request with that key is in flight; branch on type.)

validation-error — 422

Well-formed, but the contents are not acceptable.

Unknown request fields are rejected here rather than ignored, so a misspelled firstName where the API expects first_name fails immediately. Malformed values land here too: a frame origin that is not a lower-case https origin, a sign-in code path that is not relative, an enabled_features key PlaySpace does not recognise, supplied video switched on without an approved origin, and a webhook endpoint url PlaySpace will not call, where fields[0].code names why: not_https, credentials, unresolvable, blocked_address or invalid_url.

idempotency-key-mismatch — 422

This Idempotency-Key was used with a different payload, or a write was sent without one.

Almost always a bug in key generation — a key reused across two logically different calls. Keys are scoped to your organisation and live 24 hours.

same-clinic-mismatch — 422

An appointment must link a practitioner and a patient who belong to the same clinic as the appointment itself. One of the three does not match.

rate-limited — 429

Too many requests. Carries Retry-After in seconds, plus the remaining counts and reset times for both windows.

Honour Retry-After. A request that fails authentication does not consume budget, so an unauthenticated caller cannot deplete your quota.

internal-error — 500

Our fault. Retry once with the same idempotency key; if it persists, open a ticket quoting the X-Request-Id.

Every one of these is captured on our side against the same identifier, so a report is actionable immediately.


Failures inside the frame

The frame reports two things to your page rather than through the API. @playspace-health/embed passes them on as callbacks:

  • onSignedOut — the session ended: after your page called signOut(), after a limit was reached and no code arrived, or because you disabled or deleted the practitioner.
  • onFrameUnsupported(reason) — cookie when the browser refused the framed session and PlaySpace is offering its own window, browser when PlaySpace is showing a "Chrome is recommended" warning.

When your getCode throws or returns nothing, the package does not retry: the frame stays blank on mount, or shows its reconnect page later. Report the failure from your own getCode, where you have the status and X-Request-Id of the sign-in code call.


Retry guidance

Condition Retry How
500 Yes Exponential backoff, same idempotency key
429 Yes After Retry-After
409 idempotency-conflict Yes A few seconds later, same key
409 video-configuration-changed Yes Read the settings, then a new key
409 frame-origins-not-set After a fix Set frame_origins, then mint again
409 practitioner-unavailable, clinic-not-empty, webhook-endpoint-limit, and the two name conflicts No Change the request or the record
401 Once Re-fetch the access token first
403, 404, 422 No Fix the request, the token, or the configuration

Retrying a write is safe when the idempotency key is unchanged: a repeat replays the original response rather than performing the work twice. Minting a sign-in code takes no key, so a retry simply mints a new code.