Quickstart
From a fresh credential to a clinician signed in to the PlaySpace dashboard inside your own page. Every request below runs against the development host, https://agentic-ps-dev.playspace.health; production is the same with agentic-ps.playspace.health.
You need:
- a development credential with the
sessions:writescope. Every access level on the application form above Read-only includes it; - a page served over
httpsfrom an origin you control. PlaySpace frames only intohttpsorigins, so for local work serve your page overhttps, for examplehttps://localhost:3000; - a backend that can make HTTPS calls and keep a secret.
1. Get an access token
Exchange the client credentials for an access token on the development authorisation server. This happens on your backend only.
curl --request POST \
--url "https://dev-hcp1velit44csg3n.us.auth0.com/oauth/token" \
--header 'content-type: application/json' \
--data '{
"grant_type": "client_credentials",
"client_id": "<client id>",
"client_secret": "<client secret>",
"audience": "https://playspace-ehr-api"
}'
Take access_token from the response and send it as Authorization: Bearer <access token> on every Partner API call. It lives 24 hours, so cache it and reuse it rather than minting one per request.
2. Check the token
GET /v1/partner/health HTTP/1.1
Host: agentic-ps-dev.playspace.health
Authorization: Bearer <access token>
{
"data": {
"status": "ok",
"partner_organization_id": "a1b2c3d4-e5f6-7890-abcd-ef0123456789",
"checked_at": "2026-10-22T15:30:00.000Z"
}
}
This call needs no scope and answers 200 whenever the token is accepted, so it separates "my credential is wrong" from "my request is wrong".
3. Allow your page's origin
PlaySpace renders only inside pages served from origins your organisation has listed, and refuses to mint a sign-in code until at least one is set. Set the origin your page is served from:
PATCH /v1/partner/settings HTTP/1.1
Host: agentic-ps-dev.playspace.health
Authorization: Bearer <access token>
Idempotency-Key: 3e9a51c2-6b0f-4d8e-a7c4-2f1b9d0e5a63
Content-Type: application/json
{
"frame_origins": ["https://localhost:3000"]
}
An origin is https, lower case, the scheme and host with an optional port, and nothing after it: no path, no trailing slash, no wildcard. The list is replaced whole on every PATCH, so send every origin you still want, at most 10. The response is your organisation's settings as they now stand; Settings describes every field.
4. Create a clinic
Every write carries an Idempotency-Key, so a timeout is a safe retry rather than a duplicate.
POST /v1/partner/clinics HTTP/1.1
Host: agentic-ps-dev.playspace.health
Authorization: Bearer <access token>
Idempotency-Key: 4f1c1aa7-9e3c-4f9b-9d4f-8e2c8b6a1c3d
Content-Type: application/json
{
"name": "Northgate Family Practice",
"timezone": "America/Toronto"
}
Keep data.id. It is the clinic identifier the next step names.
5. Create a practitioner
A practitioner is a clinician in one of your clinics, and the person a sign-in code signs in. No PlaySpace login or password is created for them.
POST /v1/partner/practitioners HTTP/1.1
Host: agentic-ps-dev.playspace.health
Authorization: Bearer <access token>
Idempotency-Key: 6a2d3f88-4b71-4c02-8e5a-1f9b7c0d3e42
Content-Type: application/json
{
"first_name": "Dana",
"last_name": "Okafor",
"email": "dana.okafor@example-practice.com",
"partner_clinic_id": "<clinic id from step 4>",
"role": "member",
"country": "US"
}
country is an uppercase ISO 3166-1 alpha-2 code. It is optional, but some PlaySpace features are offered only in certain countries, and a practitioner without one is treated as outside all of them. An email already in use answers 409 rather than creating a second record.
Keep data.id: store it against the clinician's record in your own system. It is what your sign-in code route will look up.
6. Add a sign-in code route to your backend
This route is the whole server half. It works out which clinician is signed in to your product, asks PlaySpace for a code for them, and returns only the code.
// POST /playspace/sign-in-code — server only.
const PLAYSPACE = 'https://agentic-ps-dev.playspace.health'
export async function POST(request: Request): Promise<Response> {
// From your own session. Never from anything the browser sends.
const practitionerId = await currentPlaySpacePractitionerId(request)
if (!practitionerId) return new Response('Not signed in', { status: 401 })
const { path } = (await request.json().catch(() => ({}))) as { path?: string }
const response = await fetch(
`${PLAYSPACE}/v1/partner/practitioners/${practitionerId}/sign-in-codes`,
{
method: 'POST',
headers: {
authorization: `Bearer ${await cachedAccessToken()}`,
'content-type': 'application/json',
},
body: JSON.stringify(path ? { path } : {}),
},
)
if (!response.ok) {
// Log the status and X-Request-Id, never the body of a success.
return new Response('PlaySpace sign-in unavailable', { status: 502 })
}
const { data } = (await response.json()) as { data: { code: string } }
return Response.json({ code: data.code }, { headers: { 'cache-control': 'no-store' } })
}
currentPlaySpacePractitionerId and cachedAccessToken are yours: the first reads your own session and returns the practitioner id you stored in step 5, the second caches the token from step 1.
The call needs no Idempotency-Key; every call mints a new code. A code works once and stops working 60 seconds after it was minted, so mint one each time the page asks and never cache it. When the call fails, the problem type says why: 404 for a practitioner that is not yours or was deleted, 409 practitioner-unavailable for one who is disabled or cannot sign in, and 409 frame-origins-not-set when step 3 has not happened.
7. Mount the frame in your page
npm install @playspace-health/embed
import { mount } from '@playspace-health/embed'
const frame = mount({
container: document.getElementById('playspace')!,
ehrOrigin: 'https://agentic-ps-dev.playspace.health',
getCode: async ({ path }) => {
const response = await fetch('/playspace/sign-in-code', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ path }),
})
if (!response.ok) throw new Error(`sign-in code request failed: ${response.status}`)
return ((await response.json()) as { code: string }).code
},
path: '/dashboard',
onSignedOut: () => console.info('PlaySpace signed out'),
onFrameUnsupported: (reason) => console.info('PlaySpace frame unsupported:', reason),
})
<div id="playspace" style="height: 820px"></div>
ehrOrigin is the host you call the Partner API on. Give the container a height; the frame fills it. Without a bundler, load the same module from a CDN, as in other languages.
8. Open your page
Load the page in Chrome while signed in to your own product as the clinician from step 5. The frame calls your route, loads /frame/start with the code, and lands on the PlaySpace dashboard signed in as Dana Okafor, with no PlaySpace login in between.
If the frame stays blank, check in this order: your route returned a code (your server log), the page's origin is exactly the one you set in step 3, and your page's own Content Security Policy allows framing the PlaySpace origin. Things that will bite you covers the rest.
What you just built
The complete sign-in path. Your credential never left your server, the browser held a code for less than a minute, and the clinician is in the same PlaySpace product a direct clinician uses, with the same permissions.
When that session reaches its limit, the frame asks your page for another code through getCode and carries on; your route already handles it. When your own user signs out, call await frame.signOut().
Where to go next
- Framing in depth: Frame the PlaySpace dashboard covers settings, browsers, the window fallback, session limits and what the frame hides.
- Patients and appointments: The Partner API creates them and hands the patient their join link.
- The ideas underneath: core concepts.