Quickstart
Prepare an API key (backend only), a viewer id from your own system, and the origin that hosts the page. PRAXIS_API_BASE defaults to https://api.deepraxis.com.
export PRAXIS_API_BASE=https://api.deepraxis.comexport PRAXIS_API_KEY=...CUSTOMER_ID=student-1001ORIGIN=https://learn.example.com1. The backend issues a grant code
The code is single-use and short-lived, and carries the resources this sign-in may use. The viewer field is exactly customer_id (your own id); customer, external_id, external_user_id and subject are each refused as Unsupported field.
curl -s -X POST "$PRAXIS_API_BASE/customer/v1/grant_codes" \ -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" \ -d "{\"customer_id\":\"$CUSTOMER_ID\",\"origin\":\"$ORIGIN\",\"resources\":[\"content:cnt_REPLACE_ME:play\"]}" \ | jq '{code,expires_at}'Each resources entry is agent:<id>:chat, content:<id>:play or application:<id>:visit, and * may stand in the id position. Write origin as an https origin (http://localhost for development), and it must equal its own URL origin (scheme://host[:port], no path, query or trailing slash); once bound, the code can only be exchanged from that origin. Omit origin to leave it unbound.
2. The browser exchanges it for an access token
Give either grant_code or publishable_key, never both; the browser sends the Origin header itself, and it cannot be faked.
curl -s -X POST "$PRAXIS_API_BASE/customer/v1/access_tokens" \ -H "Content-Type: application/json" -H "Origin: $ORIGIN" \ -d '{"grant_code":"cgc_REPLACE_ME"}' \ | jq '{access_token,expires_at,session_expires_at,sign_in_id,customer}'The answer carries access_token, expires_at (token expiry), session_expires_at (sign-in expiry), sign_in_id and customer (id, type). The token lives at most an hour and never beyond the sign-in’s expiry.
3. Use the token on a resource
Put the token in the Authorization header and call the product you need. For a play:
curl -s -X POST "$PRAXIS_API_BASE/content/v1/playback/sessions" \ -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -H "Origin: $ORIGIN" \ -d '{"content_id":"cnt_REPLACE_ME"}' | jq '{manifest_url,expire_time}'A token whose grant does not cover the resource answers RESOURCE_NOT_GRANTED; a mismatched origin answers ORIGIN_NOT_ALLOWED.
4. Renew
Renew before the token expires: while the sign-in is live you get a fresh token; an expired or revoked sign-in fails.
curl -s -X POST "$PRAXIS_API_BASE/customer/v1/access_tokens/renew" \ -H "Authorization: Bearer $ACCESS_TOKEN" | jq '{access_token,expires_at}'5. Sign out
Signing out revokes this sign-in and every token under it:
curl -s -X DELETE "$PRAXIS_API_BASE/customer/v1/access_tokens/current" \ -H "Authorization: Bearer $ACCESS_TOKEN"The page does not have to do this by hand
With <praxis-video> or <praxis-agent> the page calls configure once, and the page session does the exchange, the renewal and the sign-out:
<script type="module"> import { configure } from "https://cdn.deepraxis.com/v1/praxis-session.js"; // grantCode is minted by the backend for the signed-in viewer; anonymous visitors use publishableKey instead. configure({ api: { url: "https://api.deepraxis.com", grantCode: "cgc_REPLACE_ME" } });</script>The page session renews the token before expiry until the sign-in expires or is revoked; signOut() ends it.
Next steps
- Player: use the viewer token to play a video.
- Customer directory: the block, revoke and usage operations on the directory.
- Limits and errors: the error codes when a grant code or token fails.