Skip to content

Partner API

The partner API lets your product use an AIR team as its engine. Your server creates the people you serve as contacts, tells AIR who they are through a care profile, assigns each one a colleague, and mints short-lived session tokens so their own device can chat with that colleague. What the team does — its conversations, memory, safeguarding and duty-of-care alerts — stays in AIR.

Three principles run through every route:

  • AIR is the source of truth. You don't keep copies of transcripts; an overseer reading a conversation reads it live from AIR.
  • Webhooks are delivery, not data. Webhooks tell you that something happened; this API is where you fetch it.
  • Everything is scoped by your credential, never by ids in the request. Your key reaches your team's door and nothing else.

All routes are under /v1/partner/, on the partner API base URL your AIR contact gives you (AIR_PARTNER_BASE_URL below). The JavaScript SDK's PartnerClient wraps almost every route.

Getting a key

A partner key belongs to a team's SDK door. Whoever administers the team in AIR opens the door and mints the key; it is shown once. The same door holds your webhook address, its signing secret and the event kinds you receive — see opening a front door.

Authentication

The partner key — your server only

Send it as a bearer token on every request:

Authorization: Bearer <AIR_PARTNER_KEY>
Status code Meaning
401 missing_key No key was sent
403 invalid_key AIR does not recognise the key

Never let the key reach a browser or an app

The key is root over your team's slice of AIR: it can read every contact, mint a session for anyone and erase people irreversibly. Keep it on your server. A device only ever holds a session token.

Rate limits are counted per key, not per IP address.

Session tokens — for one person's device

POST /v1/partner/sessions
{
  "subject": "participant",
  "contact_id": "a2a0…",
  "assertions": { "overseer_verified": true, "consents_current": true }
}
Field Notes
subject participant — someone you serve, for their own chat — or overseer — someone who looks after participants, to read what they are entitled to
contact_id The contact the token is for
assertions Facts you vouch for, which AIR cannot check itself. Both overseer_verified and consents_current must be true on every mint

Returns { "session_token": "…", "expires_at": 1760400000, "subject": "participant" }.

Tokens are opaque and expire after about 15 minutes; mint one per page load or reconnect, server-side, and hand only the token to the device. The thread and file routes take it alongside your partner key, so a request proves both which partner is asking and which person it is for.

Refusals carry a machine-readable code, so you can say it in your own words:

code Meaning
assertions_missing An assertion was missing or false; context.missing lists which
no_care_profile The participant has no care profile yet
no_colleague The participant has not been given a colleague yet
participant_is_overseer You asked for a participant token for someone who oversees others
overseer_required You asked for an overseer token for someone who oversees nobody
invalid_session_token (on later calls) the token is invalid or has expired — mint another

Errors

Errors carry a stable code you can branch on. Switch on code, never on message, which is written for people and may change.

{
  "detail": {
    "error": {
      "code": "no_thread",
      "message": "that person has no conversation with this colleague yet — …",
      "context": { "contact_id": "a2a0…" }
    }
  }
}

Your door

Route What it does
GET /v1/partner/door The configuration AIR holds for your door: status, webhook address, the signing secrets to accept, subscribed events, retention, and the last delivery
POST /v1/partner/door/webhook Register a new webhook address for yourself

Both are described on the webhooks page.

People

Groups and contacts

A group is the container — a family, a class, a caseload. A contact is one person in it.

POST /v1/partner/groups
{ "kind": "family", "label": "The Prices" }
POST /v1/partner/contacts
{
  "group_id": "…",
  "kind": "external_participant",
  "first_name": "Owain",
  "parent_id": "…",
  "oversight": false
}
Field Notes
kind external_participant (the default — someone you serve) or overseer (someone accountable for participants)
first_name A first name only. AIR does not need, and does not want, a surname
parent_id, oversight Optional. Makes another contact this person's overseer at creation
email Optional
Route What it does
DELETE /v1/partner/contacts/{id} Irreversible. Erases the contact and everything AIR holds about them — conversations, messages, what the colleague learned. Returns a receipt id
GET /v1/partner/contacts/{id}/overseers Who oversees this participant, owner first
POST /v1/partner/contacts/{id}/overseers Add an overseer: { "overseer_id": "…", "role": "observer", "oversight": true }. Idempotent
DELETE /v1/partner/contacts/{id}/overseers/{overseer_id} Remove one

A participant can have several overseers: an owner and any number of observers. Duty-of-care alerts reach every overseer who holds oversight.

The care profile

POST /v1/partner/contacts/{id}/care      (create or update)
GET  /v1/partner/contacts/{id}/care

The care profile is how a contact stops being a row and becomes someone the colleague knows how to talk to. AIR turns it into rules for that person's colleague.

{
  "age_band": "6-9",
  "pronouns": "he",
  "profile_data": {
    "register": "warm",
    "language": "Welsh",
    "brief": { "loves": ["dinosaurs"], "step_arounds": ["thunderstorms"] },
    "contact_hours": { "start": "07:30", "end": "20:00", "tz": "Europe/London" }
  }
}
Field Notes
age_band One of 6-9, 10-12, 13-17, 18+. The older bands (4-5, 6-8, 9-10, 11-13, 13+) are refused. Decides how carefully pictures are handled, and whether a parent may read the child's own words in AIR's team portal. A band only ever tightens what happens. Omit to leave unchanged; null clears it; anything else is a 422
pronouns she, he, or a set written out (they/them). A colleague uses a pronoun only when it has been told one; otherwise it uses the person's name. null clears it
profile_data Freeform, shallow-merged: a key you send replaces that key, null clears it, and a nested object is replaced whole

Three keys in profile_data are read by name:

Key Effect
register warm or plain — the colleague's voice
language What to speak to this person in, in any form a model understands ("Welsh", "cy"). It also reaches anything the colleague makes for them
contact_hours When messages may flow, in their own timezone. Outside them the colleague holds its reply until the window opens

The response includes the participant's colleague and its nickname.

Colleagues

Route What it does
GET /v1/partner/cast The team's colleagues that carry a nickname — the names your users see
POST /v1/partner/contacts/{id}/colleague Give a participant their colleague: { "bot_id": "…" }
PUT /v1/partner/colleagues/{bot_id}/hours A colleague's working hours: { "start": "09:00", "end": "17:00" }

Today, home and allowances

Route What it does
GET /v1/partner/contacts/{id}/today Today's counts for a chat surface: chats, pictures, mood, quotas
GET /v1/partner/contacts/{id}/home What a home screen shows before the chat opens — including a teaser that is a real message already in the thread
GET /v1/partner/allowances Which limits this team's work declares (key, name, period, range)
GET /v1/partner/contacts/{id}/allowances One person's limits, with how much has been used and when it resets
PUT /v1/partner/contacts/{id}/allowances Set limits by key: { "uploads_per_day": 5 }. null returns a key to the team's default; 0 is a real limit. An unknown key refuses the whole request

Read the allowance keys from GET /allowances rather than hard-coding them — they come from the work the team has installed, not from the API.

The chat

A participant's device talks to their colleague over a WebSocket, with these REST routes as the handshake and fallback. The JavaScript SDK's Thread client handles all of it; your server only needs to proxy the requests that need your key.

Route What it does
POST /v1/partner/threads/open Body { "token": "<session token>" }. Opens (or reopens) the participant's thread with their colleague: the conversation_id, recent history, the colleague, what the conversation is focused on, whether a reply is being held by quiet hours (parked), and the WebSocket address to use
POST /v1/partner/threads/{conversation_id}/messages Send a turn: { "token", "body", "file_ids", "client_message_id" }. The reply streams back as server-sent events (token … done). body may be empty when file_ids is not
GET /v1/partner/threads/{conversation_id}/events?token=…&since=… A long-lived event stream for things that arrive later — a picture being made, a check-in, a reply released after quiet hours. Pass since through on every reconnect, or anything that landed between reconnects is missed. A colleague's proactive frame, and a reply's done, carry the message's action_cards and, where it differs from content, typeset_content (the words as written); both are absent when there is nothing to carry
GET /v1/partner/threads/{conversation_id}/history?token=…&before=…&limit=… Older turns, for scrolling up
POST /v1/partner/messages/{message_id}/retract The sender takes back their own message, from what people see. The safeguarding record keeps it

Send a client_message_id with every turn. If a turn arrives twice under the same id — once over a socket that died, once here — AIR stores and answers it once.

The socket ends with its session token. When the token the socket opened on stops being accepted, AIR closes the socket with code 4401 (session_expired). The JavaScript SDK switches to a fresh token about 90 seconds before expiry, so a working chat never sees the close; only a client whose renewal was refused — a device its parent freed, say — does. If you write your own client, renew before the token runs out, and treat 4401 as signed out.

Every participant turn goes through the same inbound path as every other channel, so the team's safeguarding, quiet hours and routing apply in full.

Files

Route What it does
POST /v1/partner/files/upload A participant shares a picture: { "token", "content_b64", "filename", "content_type", "origin" }. Answers 202 with a pending file id
GET /v1/partner/threads/{conversation_id}/files/{file_id}/progress?token=… How far an upload has got. Poll it; ready is the gate and blocked is final
GET /v1/partner/files/{file_id}/download?token=… A short-lived download address — only for a file that has been checked and cleared
GET /v1/partner/threads/{conversation_id}/files?token=… Everything readable in a conversation, newest first
GET /v1/partner/me/files?token=… Everything this participant made, across every conversation

origin is colleague for a picture shared with the colleague, or peer for one shared with another participant (Care practice). JPEG, PNG, WebP and GIF are accepted, and location data is stripped before anything is stored.

An upload exists but is not usable until it has been checked. Nobody — the uploader included — can download it before then, and the colleague will not look at it. Send its id in a turn once progress says ready. A file that is still being checked, or was blocked, never appears in a listing.

Oversight

Route What it does
GET /v1/partner/oversight/{overseer_id}/threads The conversations this overseer's oversight reaches
GET /v1/partner/oversight/{overseer_id}/threads/{conversation_id} One of them, read live from AIR

An overseer token reads only conversations that overseer's oversight reaches. Duty-of-care alerts reach overseers whatever the participant's age, as the overseer.alert webhook.

Practice routes

A team that has applied a practice gains its routes, under /v1/partner/practices/<practice>/. A team without it gets a refusal with the code practice_disabled.

Care — peer relationships

Route What it does
POST /v1/partner/practices/care/relationships Seat two participants together, with one or two moderator colleagues: { "member_a", "member_b", "moderator_bot_ids" }. Create it only once the overseers have agreed — AIR holds no "pending" state
GET /v1/partner/practices/care/relationships List them
GET / DELETE /v1/partner/practices/care/relationships/{id} Read one, or revoke it
POST /v1/partner/practices/care/relationships/{id}/session A peer session token for one member: { "contact_id", "assertions" }
POST /v1/partner/practices/care/files/{file_id}/retract The sender withdraws a picture they shared: { "token" }

Every peer message is checked by a moderator colleague before it is delivered. No partner key, overseer or parent can read a peer conversation; overseers get the Care events instead. See Care.

Quizzes

Your team's published question sets can be launched for one of your contacts. The quiz runs as a conversation in the thread that contact already has with their colleague, so you start it here and find out how it went later, from the quiz.assignment.completed webhook.

For the colleague to run it, someone on the team must have taught a colleague Run a quiz, and the team must have applied the Assessment practice. See quizzes and assessments.

List the quizzes you can offer

GET /v1/partner/practices/assessment/quizzes

Returns the published sets your team can offer: the organisation's, and your team's own. Never another team's, and never a draft.

{
  "quizzes": [
    {
      "set_id": "5b0e…",
      "name": "Fire safety refresher",
      "stakes": "rehearsal",
      "questions": 10,
      "tags": []
    }
  ]
}
Field Type Notes
set_id uuid Pass this to the launch call
name string The set's name, as shown in AIR
stakes enum compliance | rehearsal | play
questions int How many questions are currently in the set
tags string[] May be empty

No question or answer is ever returned.

Launch a quiz for a contact

POST /v1/partner/practices/assessment/contacts/{contact_id}/quizzes/{set_id}

No body. Answers 202 Accepted: the quiz has been started, and the first question arrives in the contact's thread the way anything the colleague says does.

{
  "set": "Fire safety refresher",
  "contact_id": "a2a0…",
  "outcome": "started",
  "assignment_id": "91c4…",
  "conversation_id": "cdf9…"
}
Field Type Notes
set string The set's name
contact_id uuid Echoes the path
outcome enum started — a new quiz was started. already — this contact already has this set open; launching again is a nudge, not a second quiz
assignment_id uuid Matches assignment_id on the completion webhook
conversation_id uuid The thread the quiz runs in

The score is not in this response. A quiz finishes minutes or days after it is launched; subscribe your door to quiz.assignment.completed to be told.

Status code What it means What to do
404 contact_not_found No contact with that id. Check the id.
403 contact_not_owned The contact isn't in any of your groups. Only your own contacts can be launched for.
403 group_not_owned The contact's group belongs to another partner. As above.
404 set_not_available That set isn't one your team can offer — it doesn't exist, isn't published, or belongs to another team. Use a set_id from the list call.
409 no_runner No colleague on your team has been taught to run a quiz. Ask the team's manager to teach one Run a quiz.
409 no_thread The contact hasn't talked to their colleague yet. A quiz is never the thing that opens someone's first conversation. Launch it after they have.
409 set_not_launchable The set can't be given right now — for example, it stopped being published between listing and launching. List again and retry with a set that is offered.