PlaySpace

Guide: Testing, then going live


Two environments, and no sandbox

There is no PlaySpace sandbox. No permanently addressable synthetic tenant, no stable fixture caseload, no weekly reset, no captured-message mailbox, and no self-serve key. If you have read about one, it did not ship.

What exists is a development environment and a production environment, both of them the real platform.

Development Production
Partner API and frame origin https://agentic-ps-dev.playspace.health https://agentic-ps.playspace.health
Credentials Apply on that host, issued on approval Apply on that host, issued on approval
Authentication Real machine-to-machine client credentials Real machine-to-machine client credentials
Rate limits, tenancy, row-level security Enforced identically Enforced identically
Generation inside the dashboard Real, and it really costs money Real
Data Whatever you create; it persists Real clinical data

A credential is bound to its environment. A development credential is refused by production and a production credential is refused by development, so there is no configuration in which a test run reaches real clinical data. Settings are per environment too: list your development page origins in development and your production origins in production.

Both hosts serve an interactive console at /docs, alongside the API itself. Unlike the reference on this documentation site, that one issues real requests. Mint the token in a terminal and paste it into the console's Bearer Token field; its Authorize button cannot mint one for you. Full steps: trying a call before you write code.

You build your own fixtures. Development starts empty for you. Create your clinics, practitioners and patients through the API in a setup step, and either tear them down or reuse them: nothing resets them for you, and nothing will delete them out from under a test run either.

Nothing captures outbound messages. There is no endpoint that lets you read what the platform sent. Keep patient_contact_enabled off in development unless you are testing patient email, and then use addresses you actually control.


Getting credentials

Apply through the registration form on the environment you want: /partner-register on the host above. The whole path is get your credentials. Every access level above Read-only includes sessions:write, which the frame needs.

Scopes are fixed on the credential at approval. To change them, ask: PlaySpace edits the grant on your credential, and the change takes effect on your next token rather than on the token you are holding.


Testing your own code

There is no published test double. @playspace-health/embed ships no mock, so a unit test that "uses PlaySpace" is a unit test of your own code with the network stubbed. Write it that way deliberately:

  • Test your sign-in code route's authorisation with no PlaySpace involved at all. This is the whole security boundary of the integration: PlaySpace checks that the practitioner is yours, and cannot check that this browser should be them. Assert that the route refuses a request with no session, that it ignores any practitioner identifier in the request body, and that it returns only { code } with Cache-Control: no-store.
  • Test the failure branches. Construct the problem documents for 404, 409 practitioner-unavailable and 409 frame-origins-not-set and assert your code branches on status and type rather than on a message string.
  • Test your getCode. It must return a string, reject on failure, and answer within 10 seconds.

Integration tests against development

Run the paths a stub cannot prove: real authentication, real settings, real codes.

Good candidates, each of which catches a real class of integration defect:

  • A code needs your origins. With frame_origins empty, a sign-in code request answers 409 frame-origins-not-set. Set it, and the same request answers 201.
  • A malformed origin is refused. https://App.example.com, https://app.example.com/ and https://*.example.com each answer 422, rather than being stored and producing an empty frame later.
  • A disabled practitioner cannot sign in. Set status to disabled and assert 409 practitioner-unavailable; set it back to active and assert 201.
  • A repeated Idempotency-Key replays. Create a patient twice with the same key and assert you got the same patient back, not two.
  • Another organisation's id answers 404, not 403. Absent, deleted and belonging to somebody else are deliberately indistinguishable.
  • Rate-limit headers move. Read them on a normal response so your client knows where they are before it needs them.
  • A webhook endpoint verifies and answers. Register your development URL, which must be public HTTPS (put a tunnel in front of your machine), and read the webhook.test delivery in GET /v1/partner/webhook-endpoints/{id}/deliveries. Then change a patient in the frame and confirm the event arrives signed. Webhooks and events covers the rest.

Browser tests

The dashboard renders in a cross-origin iframe, which shapes what a test can see.

Drive the frame as a user would, and assert on what crosses the boundary on your side. A browser automation tool can reach inside a cross-origin frame, but the dashboard's markup is PlaySpace's and changes without notice, so keep in-frame assertions to the obvious ones: the dashboard loaded, the clinician's name is shown. Assert your own reactions to onSignedOut and onFrameUnsupported on your own page.

Tests worth having:

  • The frame signs in. Load your page as a signed-in user and assert the frame reaches the dashboard. Run it in Chrome and in Safari 26.2 or later.
  • The origin is right. Serve the same page from an origin that is not in frame_origins and assert the frame stays empty. This is the test that catches a preview deployment nobody listed.
  • Sign-out reaches PlaySpace. Sign out of your product and assert onSignedOut fired and the frame shows the signed-out page.
  • A suspended clinician is signed out. Disable the practitioner through the API, reload the dashboard inside the frame, and assert your page heard onSignedOut. Re-enable them and assert the next frame load signs in again.
  • Reconnect calls your route. A session lasts 24 hours and idles out after 1, which no test can wait for, and the package acts only on messages from its own PlaySpace frame, so a test cannot fake the request. Test the part that is yours: call your getCode twice in a row and assert each call returns a new code within 10 seconds.
  • The patient joins. Book a virtual appointment, request its patient link, open it in a second browser context, and start the session from the clinician's frame.

Going live

Credentials

  • Production credentials issued and stored in a secret manager, not in an environment file that travels with a repository.
  • No PlaySpace secret appears in any browser bundle. Search your built assets and confirm zero hits.
  • You know who to contact for a rotation.

Settings

  • Every production origin listed in production frame_origins, exactly: lower case, scheme and host, no trailing slash, no path.
  • Preview and staging origins handled deliberately: either listed, or the frame is disabled outside production. A page on an origin nobody listed renders an empty frame.
  • enabled_features reviewed: every area you do not want your clinicians to see is set to false.
  • patient_contact_enabled decided. Off means you deliver every patient message, including the join link.
  • A production webhook endpoint registered, if you use events, with its secret in your secret manager and a rehearsed rotation. Development and production keep separate endpoints, as they keep separate credentials.
  • recording_enabled reviewed. It starts on; switch it off if your consent process requires, and have your own consent process if you leave it on.

Your page

  • Your Content Security Policy's frame-src allows the PlaySpace origin you pass as ehrOrigin.
  • If your page or a proxy sends a Permissions-Policy header, it allows camera, microphone, display-capture and fullscreen for the PlaySpace origin.
  • The container has a real height, and the frame stays mounted for the life of the page.
  • onFrameUnsupported explains the window fallback and the browser warning in your own words, or at least reaches your analytics.

The sign-in code route

  • Authorises the caller against your own session before minting. This is the entire security boundary.
  • Derives the practitioner from your own record of who is signed in, never from a client-supplied parameter.
  • Returns only the code, with Cache-Control: no-store, and never logs it.
  • Rate-limited on your side.
  • Answers within 10 seconds under load, because reconnect waits no longer.

People

  • await frame.signOut() runs when your user signs out. Destroying the frame does not sign out.
  • A clinician who leaves is disabled or deleted through the API the same day.

Failure handling

  • Every failure logs the X-Request-Id and no client name.
  • A failed sign-in code request alerts somebody: it means your route or your credential is down, and every framed clinician is locked out.
  • Problem documents handled by type and status, not by matching on text.

Data handling

  • No client name and no free-text search term in any URL your application constructs.
  • Patient links delivered over a secure channel, never logged, never sent through email click tracking.
  • PlaySpace identifiers, or your external_id, stored against your own records, because they are the only join between the two systems.

Rolling out

Start with one clinic. Not one feature: one clinic, with everything you intend to ship. Feedback on a therapeutic product is qualitative and arrives in conversation rather than in a metric, and you want that conversation with ten clinicians before it is with a thousand.

Watch three things in the first month. Sign-in code failures by status, which catch integration defects. onFrameUnsupported by reason, which tells you how many of your clinicians are on a browser the frame does not suit. And the ratio of appointments booked to sessions actually started, which catches an entry point nobody can find.


Getting help

Partner engineering: techstack@playspace.health.

Include the X-Request-Id from the failing response and the diagnosis is usually the same day. Include a client's name and we will ask you to redact it and resend.