The agent's API
The Personal Agent's own HTTP API, for building a client of it: a phone app, a messaging channel, anything that isn't the playground's page. Every client, the page too, works in the same conversations, so what one does, the others see.
What it is for
HTTP API for building clients on top of the Personal Agent over Personal Agent Protocol (Poppy 1.0): multi-company conversations, quick replies, Operations v3 approval workflows, Company OAuth sign-in, real-time SSE events, and passkey-backed multi-device accounts. Browser clients authenticate via same-origin cookies; native apps send no Origin header and authenticate with Authorization: Bearer <accessToken>.
Everything is under https://poppylab.dev/api/v1, and every body is JSON except the event stream's. The version is in the path: v1 is still changing, and a member or a route can still be added, renamed or removed until it is frozen. Until then, a client ignores a member it doesn't know, and reads the document again when it is updated.
This page is built from the same document the API serves at /api/v1/openapi.json, so every operation and type on it is the document's. To build an app on it step by step, read Build a native client.
Authentication
A request is a browser's or a client app's, and the two prove who they are differently.
- A browser on the playground's own origin uses cookies: the visitor's, which needs no account, or
__Host-poppy_accountonce it signs in to an agent account. A request that changes anything must come from the playground's origin; one from another origin is refused with 403 before its body is read. - A client app sends no
Origin. It creates an account or signs in with a passkey, in two requests each: the WebAuthn options (POST /accounts/optionsorPOST /sessions/options), then the authenticator's answer to them (POST /accountsorPOST /sessions). The answer carries the device'stokens: an access token, sent asAuthorization: Bearer, which lasts 15 minutes, and a refresh token, exchanged atPOST /sessions/refreshfor a new pair. Each refresh token works once; one used twice ends the session on every device that holds it.
Passkeys are for poppylab.dev, discoverable, with user verification and no attestation, so signing in needs no username. An account has no email, password or name. A session unused for 30 days ends, and every session ends after a year.
apiSessionhttp,bearerShort-lived access token from
SessionTokens(Authorization: Bearer <accessToken>). Browser clients on the playground's origin authenticate withHttpOnlycookies instead.
Errors
A refusal has a status and an Error body, { code, error }. error is written for the person and can be shown as it is; code is what a client acts on. Each operation below lists the statuses it answers. These are the codes a client most needs to tell apart:
invalid_token401Access token expired, rotated, or invalid. Call
POST /api/v1/sessions/refreshand retry.session_revoked401Device session ended (signed out, passkey removed, or refresh token reused). Sign in again with a passkey.
not_signed_in401Endpoint requires an authenticated agent account.
passkey_not_verified400WebAuthn verification failed. Returned uniformly whether the account or passkey exists.
ceremony_expired400WebAuthn ceremony expired (5-minute TTL) or was already consumed. Request fresh options.
rate_limited429Rate limit exceeded. Wait the number of seconds given in the
Retry-Afterheader.too_many_streams429Open SSE stream limit reached (10 concurrent streams per signed-in account, or 4 per anonymous visitor).
last_passkey409Cannot delete the only remaining passkey on an account.
company_not_connected400The conversation does not have a Company connected at that origin.
conversation_ended410The conversation has ended and is read-only.
Conversations
Create and interact with conversations across up to three connected Companies. Each turn returns newly added messages alongside the updated ConversationState.
POST /api/v1/conversations
Start a conversation
Creates an empty conversation, or connects an initial Company signed out when company is provided.
Request body object
companystringoptionalOptional Company origin URL to discover and connect immediately.
Responses
201ConversationStateConversation created.
400ErrorInvalid request payload or precondition failed.
403ErrorCross-origin browser request rejected.
404ErrorConversation not found for this caller.
409ErrorConversation is busy with another request, or the Company cannot be added.
410ErrorConversation has ended and is now read-only.
422ErrorCompany discovery failed.
Example request & response
POST /api/v1/conversations
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Content-Type: application/json
{
"company": "https://food-demo.poppylab.dev"
}
HTTP/1.1 201
Content-Type: application/json
{
"id": "hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j",
"active": true,
"companies": [
{
"origin": "https://food-demo.poppylab.dev",
"name": "Lantern Noodle Bar",
"url": "https://food-demo.poppylab.dev/",
"signedIn": false,
"signingIn": false,
"consentVersion": 0,
"accessLost": false,
"direct": {
"open": false,
"invitation": null
}
}
],
"removed": [],
"messages": [],
"proposals": []
}
GET /api/v1/conversations/{id}
Retrieve a conversation
Returns the current ConversationState, including connected Companies, transcript messages, and all proposals.
Parameters
idstring, path requiredConversation ID.
Responses
200ConversationStateCurrent conversation state.
404ErrorConversation not found for this caller.
POST /api/v1/conversations/{id}/messages
Send a message
Submits a user message and runs one agent turn. If company is omitted in a multi-company conversation, the agent routes automatically or replies with disambiguation choices.
Parameters
idstring, path requiredConversation ID.
Request body object
textstringrequiredUser message text.
companystringoptionalOptional target Company origin URL to scope this turn.
modelModelChoiceoptionalModel configuration for this turn. Defaults to
demo.
Responses
200TurnResultTurn completed. As JSON, the
TurnResult. WithAccept: text/event-stream, Server-Sent Events (TurnEvent): onemessage.deltaper sentence of the agent's as it is written, thenturnwith the same result, orerror. A request refused before anything was said is answered as without the header, with its status and anError.400ErrorInvalid request payload or precondition failed.
403ErrorCross-origin browser request rejected.
404ErrorConversation not found for this caller.
409ErrorConversation is busy with another request, or the Company cannot be added.
410ErrorConversation has ended and is now read-only.
Example request & response
POST /api/v1/conversations/hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j/messages
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Content-Type: application/json
{
"text": "What can you do?"
}
HTTP/1.1 200
Content-Type: application/json
{
"conversation": "hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j",
"messages": [
{
"from": "user",
"text": "What can you do?"
},
{
"from": "agent",
"text": "Demo mode runs the examples below, without a model. To ask anything in your own words, press “Use your own model”.",
"spoken": "Demo mode runs the examples below, without a model. To ask anything in your own words, press “Use your own model”.",
"choices": [
{
"label": "What’s on the menu?",
"answer": {
"message": "What’s on the menu?"
}
}
]
}
],
"replaced": false,
"state": {
"id": "hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j",
"active": true,
"companies": [
{
"origin": "https://food-demo.poppylab.dev",
"name": "Lantern Noodle Bar",
"url": "https://food-demo.poppylab.dev/",
"signedIn": false,
"signingIn": false,
"consentVersion": 0,
"accessLost": false,
"direct": {
"open": false,
"invitation": null
}
}
],
"removed": [],
"messages": [
"…"
],
"proposals": []
}
}
POST /api/v1/conversations/{id}/answers
Submit a quick-reply answer
Submits the structured answer payload from a previous message's Choice without free-text parsing.
Parameters
idstring, path requiredConversation ID.
Request body object
answerAnswerrequiredExact
answerobject from aChoice.modelModelChoiceoptionalModel configuration if the choice triggers a turn.
Responses
200TurnResultAnswer applied. As JSON, the
TurnResult. WithAccept: text/event-stream, Server-Sent Events (TurnEvent): onemessage.deltaper sentence of the agent's as it is written, thenturnwith the same result, orerror. A request refused before anything was said is answered as without the header, with its status and anError.400ErrorInvalid request payload or precondition failed.
403ErrorCross-origin browser request rejected.
404ErrorConversation not found for this caller.
409ErrorConversation is busy with another request, or the Company cannot be added.
410ErrorConversation has ended and is now read-only.
Example request & response
POST /api/v1/conversations/hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j/answers
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Content-Type: application/json
{
"answer": {
"message": "What’s on the menu?"
}
}
POST /api/v1/conversations/{id}/proposals/{proposal}/decision
Approve or decline a proposal
Approves or declines a pending Operations v3 proposal. Approvals bind strictly to revision and execute at most once; if the Company's terms changed, the proposal transitions to superseded.
Parameters
idstring, path requiredConversation ID.
proposalstring, path requiredProposal (operation) ID.
Request body object
companystringrequiredOrigin URL of the Company holding the proposal.
revisionstringrequiredExact
revisiontoken from the proposal shown to the user.decision"approve"|"decline"requiredUser decision (
approveordecline).
Responses
200DecisionDecision recorded.
400ErrorInvalid request payload or precondition failed.
403ErrorCross-origin browser request rejected.
404ErrorConversation not found for this caller.
409ErrorConversation is busy with another request, or the Company cannot be added.
410ErrorConversation has ended and is now read-only.
Example request & response
POST /api/v1/conversations/hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j/proposals/op_4UNgDhnV1Y8lgsDmZCAV2pt3/decision
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Content-Type: application/json
{
"company": "https://food-demo.poppylab.dev",
"revision": "1795772788-peanO34panWBIb-5",
"decision": "approve"
}
HTTP/1.1 200
Content-Type: application/json
{
"proposal": {
"id": "op_4UNgDhnV1Y8lgsDmZCAV2pt3",
"company": {
"origin": "https://food-demo.poppylab.dev",
"name": "Lantern Noodle Bar"
},
"revision": "1795772788-peanO34panWBIb-5",
"summary": "Change order ord_LNB1001 for Elena Maren. Delivery stays Friday 18:30–19:00. New dishes: 2 × Shoyu ramen, 1 × Salted edamame, 1 × Matcha ice cream. New total USD 43.00 (was USD 37.00; USD 6.00 more, charged — simulated, no real payment).",
"terms": {
"order_id": "ord_LNB1001",
"order_version": 1,
"lines": {
"shoyu-ramen": 2,
"edamame": 1,
"matcha-ice": 1
},
"before_total_cents": 3700,
"new_total_cents": 4300,
"currency": "USD"
},
"state": "succeeded",
"expiresAt": "2026-11-27T09:56:28.685Z",
"spoken": "Lantern Noodle Bar wants to change your order, for a new total of 43 dollars, 6 more."
},
"state": {
"id": "hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j",
"active": true,
"companies": [
{
"origin": "https://food-demo.poppylab.dev",
"name": "Lantern Noodle Bar",
"url": "https://food-demo.poppylab.dev/",
"signedIn": true,
"scopes": "orders:read orders:write",
"signingIn": false,
"consentVersion": 1,
"accessLost": false,
"direct": {
"open": false,
"invitation": null
}
}
],
"removed": [],
"messages": [
"…"
],
"proposals": [
"…"
]
}
}
The answer as it is written
With Accept: text/event-stream, POST …/messages and POST …/answers answer Server-Sent Events: a message.delta for each of the agent's sentences as soon as the model has written it, then turn with the same TurnResult as the JSON answer, or error. Each agent message of the result carries as id the ID its sentences came under; drop shown sentences whose ID no message carries. Demo mode and the agent's own lines come as sentences too, all together before turn, so a client has one path. A Company's own words never come as sentences: they are in the result, as the Company's message.
A voice client says each sentence's spoken as it arrives and doesn't say the message's spoken again. A request refused before anything was said is answered as without the header, with its status and an Error. The sentences go only to the request that sent the message; the event stream below carries the message whole, as message, to the account's other devices.
POST /api/v1/conversations/hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j/messages
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Accept: text/event-stream
Content-Type: application/json
{
"text": "What's on the menu tonight?",
"model": {
"provider": "free",
"turnstile": "0.Kx3…"
}
}
HTTP/1.1 200
Content-Type: text/event-stream
event: message.delta
data: {"type":"message.delta","message":"q7Vb2YxkS1mR0cJtE4uWnA","index":0,"text":"Lantern Noodle Bar has shoyu ramen for $14.00 and salted edamame for $5.50 tonight. ","spoken":"Lantern Noodle Bar has shoyu ramen for 14 dollars and salted edamame for 5 dollars 50 tonight."}
event: message.delta
data: {"type":"message.delta","message":"q7Vb2YxkS1mR0cJtE4uWnA","index":1,"text":"The matcha ice cream is back too. ","spoken":"The matcha ice cream is back too."}
event: message.delta
data: {"type":"message.delta","message":"q7Vb2YxkS1mR0cJtE4uWnA","index":2,"text":"Shall I add anything to your order?\n\n","spoken":"Shall I add anything to your order?"}
event: turn
data: {"type":"turn","result":{"conversation":"hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j","messages":[{"from":"user",…},{"id":"q7Vb2YxkS1mR0cJtE4uWnA","from":"agent","text":"Lantern Noodle Bar has shoyu ramen…",…}],…}}
Company sign-ins
Authenticate a user directly on a Company's own consent page without exposing credentials to the agent. Final outcomes arrive over the SSE event stream.
POST /api/v1/conversations/{id}/sign-ins
Start a Company sign-in
Initiates Direct Sign-In (§4.2) at a connected Company. Browser callers receive the Company's consent URL; bearer-authenticated apps receive a single-use agent link (SignIn.url) to open in an in-app browser session. Completion emits signin.completed or signin.failed on the event stream.
Parameters
idstring, path requiredConversation ID.
Request body object
companystringrequiredOrigin URL of the connected Company.
access"read"|"write"optionalPermission tier to request (
readdefault, orwriteto propose changes).
Responses
200SignInSign-in launch details.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
404ErrorConversation not found for this caller.
409ErrorConversation is busy with another request, or the Company cannot be added.
410ErrorConversation has ended and is now read-only.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
POST /api/v1/conversations/hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j/sign-ins
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Content-Type: application/json
{
"company": "https://food-demo.poppylab.dev",
"access": "write"
}
HTTP/1.1 200
Content-Type: application/json
{
"url": "https://poppylab.dev/api/v1/sign-ins/Wq3v0mA4…",
"expiresAt": 1795772968698,
"endUrl": "https://poppylab.dev/playground/sign-in/app"
}
GET /api/v1/sign-ins/{ticket}
Open an app sign-in link
Opened by a native app's browser (SignIn.url). Consumes the one-time 3-minute ticket, binds the OAuth state to that browser via cookie, and redirects to the Company's consent page. Expired, reused, revoked-session, or mismatched-account tickets redirect to endUrl?result=failed.
Parameters
ticketstring, path requiredOne-time ticket from
SignIn.url.
Responses
303no body ·LocationRedirects to the Company's consent page, or to
endUrl?result=failed.
Events
Real-time Server-Sent Events stream delivering sign-in outcomes, proposal updates, cross-device activity, and Direct Conversation messages.
GET /api/v1/conversations/{id}/events
Stream conversation events
Opens a Server-Sent Events stream starting with state, followed by incremental changes polled every 2 seconds. Closes automatically after 5 minutes or when the conversation ends; reconnect and resync from state. Signed-in streams emit session.ended if the session or access token becomes invalid. Concurrency is capped at 10 open streams per account (4 per anonymous visitor, too_many_streams).
Parameters
idstring, path requiredConversation ID.
Responses
200AgentEventastext/event-streamSSE stream (
text/event-stream); eachdatapayload is anAgentEvent.404ErrorConversation not found for this caller.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
GET /api/v1/conversations/hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j/events
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Accept: text/event-stream
HTTP/1.1 200
Content-Type: text/event-stream
retry: 3000
event: state
data: {"type":"state","state":{"id":"hKhgaC-veINpeBH3fJQO4-ewBMbIdw9j","active":true,…}}
: read
event: signin.completed
data: {"type":"signin.completed","company":{"origin":"https://food-demo.poppylab.dev","name":"Lantern Noodle Bar"}}
event: proposal.created
data: {"type":"proposal.created","proposal":{"id":"op_4UNgDhnV1Y8lgsDmZCAV2pt3",…}}
The stream and its events
The stream sends retry: 3000, then each event with its type as the SSE event name and the whole AgentEvent as its data, and a comment after every reading of the conversation. It reads the stored conversation every two seconds, so it learns of what another device or the browser did without being told. It closes after five minutes or when the conversation ends: open it again and start from the new state.
statewithstateInitial snapshot emitted when the stream opens. Every subsequent event describes a delta from this state.
messagewithmessageA new message appended by the user, agent, or Company.
messages.replacedwithstateEarlier messages were withdrawn (for example, after losing access or disconnecting a Company). Replace your local transcript with
state.messages.signin.completedwithcompanyThe user completed OAuth consent at the Company.
signin.failedwithcompanyA pending Company sign-in was declined, failed, or expired after 5 minutes. No grant changed.
access.lostwithcompanyThe Company rejected or revoked the stored grant. Prompt the user to sign in again.
signoutwithcompanyThe user signed out of the Company in this conversation.
proposal.createdwithproposalA Company returned a new Operations v3 proposal awaiting user approval.
proposal.expiredwithproposalThe proposal passed
expiresAtwithout approval. Nothing was executed.proposal.replacedwithproposalThe Company returned a fresh
revisionwith updated terms that require new approval.proposal.updatedwithproposalThe proposal moved to a terminal state (
succeeded,declined,refused, oruncertain).company.addedwithcompanyA Company was connected to the conversation.
company.removedwithcompanyA Company was disconnected from the conversation.
conversation.endedwithkeptUntilThe conversation is now read-only and will be purged at
keptUntil. The stream closes.session.endedwithcodeThe caller's session is no longer valid and the stream closed. On
invalid_token, refresh the access token and reconnect; onsession_revoked, sign in again.
Accounts
Create passwordless, passkey-backed agent accounts and inspect or claim conversations across devices.
POST /api/v1/accounts/options
Create registration options
Starts passkey account creation. Returns WebAuthn options (discoverable, user verification required, no attestation) and a single-use ceremony ID valid for 5 minutes.
Request body object
labelstringoptionalOptional user-chosen display label for the account.
Responses
200CreationOptionsWebAuthn creation options and ceremony ID.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
POST /api/v1/accounts/options
Content-Type: application/json
{
"label": "Home"
}
HTTP/1.1 200
Content-Type: application/json
{
"ceremony": "DMz80NY0PzjiwanwGamYKA",
"options": {
"challenge": "U3l0bkxYSjE4cU9jT2xqVDFPaTNTMUpRbXM2RTdVdU04andPa3d1cC1kbw",
"rp": {
"name": "poppylab.dev",
"id": "poppylab.dev"
},
"user": {
"id": "c0rOAOzr0jtlGGeGpluvjQ",
"name": "Home",
"displayName": "Home"
},
"pubKeyCredParams": [
{
"alg": -7,
"type": "public-key"
},
{
"alg": -257,
"type": "public-key"
}
],
"timeout": 300000,
"attestation": "none",
"excludeCredentials": [],
"authenticatorSelection": {
"residentKey": "required",
"userVerification": "required",
"requireResidentKey": true
},
"extensions": {
"credProps": true
},
"hints": []
}
}
POST /api/v1/accounts
Create an account
Verifies the passkey registration response, creates the account, and starts a signed-in session for the calling device.
Request body PasskeyAnswer
Responses
201SignedInAccount created and signed in.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
POST /api/v1/accounts
Content-Type: application/json
{
"ceremony": "DMz80NY0PzjiwanwGamYKA",
"credential": {
"id": "dwA7sfRJQDk5IN4eJgtesA",
"rawId": "dwA7sfRJQDk5IN4eJgtesA",
"type": "public-key",
"response": {
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoi…",
"attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YViU…",
"transports": [
"internal",
"hybrid"
]
},
"clientExtensionResults": {}
},
"device": "iPhone"
}
HTTP/1.1 201
Content-Type: application/json
{
"account": {
"id": "c0rOAOzr0jtlGGeGpluvjQ",
"label": "Home",
"created": 1795772788698,
"passkeys": [
{
"id": "dwA7sfRJQDk5IN4eJgtesA",
"name": "iPhone",
"created": 1795772788698,
"synced": true
}
],
"channels": [],
"session": "nsDf4rxOjzq3NFKVJdG2AQ"
},
"tokens": {
"session": "nsDf4rxOjzq3NFKVJdG2AQ",
"accessToken": "poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo",
"accessTokenExpiresAt": 1795773688698,
"refreshToken": "poppy_rt.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.65P8qaJ8Pl2zhzDf8eD1JXRCBGpxYiJhI3aokMn9hhE",
"refreshTokenExpiresAt": 1798364788698
}
}
GET /api/v1/account
Retrieve the current account
Returns the account, passkeys, linked channels, and current session ID for the authenticated device.
Responses
POST /api/v1/account/claim
Claim browser conversations
Browser-only. Moves anonymous pre-sign-in conversations from the visitor cookie into the signed-in account so they sync across devices. Busy conversations stay behind and are counted in skipped.
Request body object
An empty object, {}.
Responses
200objectMigration counts and updated account.
movedintegerrequiredNumber of conversations moved into the account.
skippedintegerrequiredNumber of busy conversations left unclaimed.
accountAccountrequiredUpdated account state.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Sessions
Authenticate devices with discoverable WebAuthn passkeys and rotate short-lived bearer and refresh tokens.
POST /api/v1/sessions/options
Create sign-in options
Starts usernameless passkey sign-in. Returns WebAuthn request options and a single-use ceremony ID valid for 5 minutes.
Request body object
An empty object, {}.
Responses
200RequestOptionsWebAuthn request options and ceremony ID.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
POST /api/v1/sessions/options
Content-Type: application/json
{}
HTTP/1.1 200
Content-Type: application/json
{
"ceremony": "wCo3tWEijhywKSPwr2Ko-g",
"options": {
"rpId": "poppylab.dev",
"challenge": "SEROTUthMEJBYzQ0Qy10aWNhc2Z5OFBkMElHcjB5VGpBOHVaaGtwZlozZw",
"timeout": 300000,
"userVerification": "required"
}
}
POST /api/v1/sessions
Sign in with a passkey
Verifies a passkey assertion and starts a new device session. Returns SessionTokens to native apps or sets an HttpOnly cookie for browsers.
Request body PasskeyAnswer
Responses
201SignedInSigned in.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
POST /api/v1/sessions
Content-Type: application/json
{
"ceremony": "wCo3tWEijhywKSPwr2Ko-g",
"credential": {
"id": "dwA7sfRJQDk5IN4eJgtesA",
"rawId": "dwA7sfRJQDk5IN4eJgtesA",
"type": "public-key",
"response": {
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoi…",
"authenticatorData": "SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2MFAAAAAA",
"signature": "MEUCIQDMwoQt0_I1bv5nZsegi8Rr5lxSIXVLj5vKbUN5x3Du_QIg…",
"userHandle": "c0rOAOzr0jtlGGeGpluvjQ"
},
"clientExtensionResults": {}
},
"device": "iPad"
}
HTTP/1.1 201
Content-Type: application/json
{
"account": {
"id": "c0rOAOzr0jtlGGeGpluvjQ",
"label": "Home",
"created": 1795772788698,
"passkeys": [
{
"id": "dwA7sfRJQDk5IN4eJgtesA",
"name": "iPhone",
"created": 1795772788698,
"synced": true
}
],
"channels": [],
"session": "nsDf4rxOjzq3NFKVJdG2AQ"
},
"tokens": {
"session": "nsDf4rxOjzq3NFKVJdG2AQ",
"accessToken": "poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo",
"accessTokenExpiresAt": 1795773688698,
"refreshToken": "poppy_rt.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.65P8qaJ8Pl2zhzDf8eD1JXRCBGpxYiJhI3aokMn9hhE",
"refreshTokenExpiresAt": 1798364788698
}
}
POST /api/v1/sessions/refresh
Refresh session tokens
Exchanges a native app's refresh token for a fresh access and refresh token pair. Each refresh token is single-use; replaying a spent token revokes the entire session (session_revoked).
Request body object
refreshTokenstringrequiredCurrent refresh token from
SessionTokens.
Responses
200SessionTokensRotated token pair.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
POST /api/v1/sessions/refresh
Content-Type: application/json
{
"refreshToken": "poppy_rt.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.65P8qaJ8Pl2zhzDf8eD1JXRCBGpxYiJhI3aokMn9hhE"
}
HTTP/1.1 200
Content-Type: application/json
{
"session": "nsDf4rxOjzq3NFKVJdG2AQ",
"accessToken": "poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.naUO0cj7F9IBYr8d8ezzoJiKRwUtyk5VVmN5V1BHADk",
"accessTokenExpiresAt": 1795774588698,
"refreshToken": "poppy_rt.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.bo44NTfc5jOxs2-yDukmbRzcI2rgfPBV8j9g8y9FzRc",
"refreshTokenExpiresAt": 1798364788698
}
Passkeys
Register additional WebAuthn passkeys on an account or remove compromised ones (ending every session they started).
POST /api/v1/account/passkeys/options
Create passkey options
Starts adding a new passkey to the authenticated account. Accounts hold up to 10 passkeys.
Request body object
An empty object, {}.
Responses
200CreationOptionsWebAuthn creation options and ceremony ID.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
409ErrorAccount already holds the maximum number of passkeys.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
POST /api/v1/account/passkeys
Add a passkey
Verifies the WebAuthn registration response and attaches the new passkey to the account.
Request body PasskeyAnswer
Responses
201objectPasskey registered.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
409ErrorPasskey is already registered on this account.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
DELETE /api/v1/account/passkeys/{passkey}
Remove a passkey
Deletes a passkey and immediately revokes every session started with it (including the current one). Fails with 409 last_passkey if it is the account's only remaining passkey.
Parameters
passkeystring, path requiredPasskey ID from
Account.passkeys.
Responses
200AccountPasskey removed.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
404ErrorPasskey not found on this account.
409ErrorCannot remove the account's last remaining passkey.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Devices
List active browser and app sessions (up to 25 per account) and revoke one or all devices.
GET /api/v1/account/sessions
List active sessions
Returns all active device sessions ordered by most recently used. Accounts keep up to 25 sessions; signing in on a 26th device evicts the least recently used session.
Responses
DELETE /api/v1/account/sessions
Revoke all sessions
Signs out every device on the account, including the device making this request.
Responses
200objectAll sessions revoked.
revokedintegerrequiredNumber of sessions revoked.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
DELETE /api/v1/account/sessions/{session}
Revoke a session
Signs out a single device session without affecting other signed-in devices.
Parameters
sessionstring, path requiredDevice session ID from
GET /api/v1/account/sessions.
Responses
200objectSession revoked.
revokedintegerrequiredNumber of sessions revoked.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
404ErrorSession not found on this account.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
POST /api/v1/account/sign-out
Sign out the current device
Revokes the calling device's session (and clears the browser cookie) while leaving other devices signed in.
Request body object
An empty object, {}.
Responses
200objectCurrent device signed out.
revokedintegerrequiredNumber of sessions revoked.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Example request & response
POST /api/v1/account/sign-out
Authorization: Bearer poppy_at.c0rOAOzr0jtlGGeGpluvjQ.nsDf4rxOjzq3NFKVJdG2AQ.KNGQT617OSA3c-i9As0a4HxastNzn0rb3CX977GSDSo
Content-Type: application/json
{}
HTTP/1.1 200
Content-Type: application/json
{
"revoked": 1
}
Channels
Link external messaging channels to an account using short-lived, single-use codes.
POST /api/v1/account/link-codes
Create a channel link code
Issues an 8-character single-use code valid for 5 minutes. Entering it in a supported channel links that channel user to this account.
Request body object
An empty object, {}.
Responses
POST /api/v1/link-codes/redeem
Redeem a channel link code
Called by a configured external channel backend (using its channel authentication) to redeem a user's one-time code and link the channel user ID to the account.
Request body object
channelstringrequiredConfigured external channel identifier.
userstringrequiredUser identifier within that channel.
codestringrequired8-character one-time link code provided by the user.
Responses
200objectChannel linked.
accountstringrequiredLinked agent account ID.
linkedbooleanrequiredAlways
trueon success.
400ErrorInvalid request payload or precondition failed.
401ErrorAuthentication required, or the access token has expired or been revoked.
403ErrorCross-origin browser request rejected.
429Error·Retry-AfterRate limit exceeded. Retry after the
Retry-Afterdelay.
Schema
Machine-readable OpenAPI 3.1 contract for /api/v1.
GET /api/v1/openapi.json
Retrieve the OpenAPI schema
Returns this OpenAPI 3.1.0 specification as JSON.
Responses
200objectOpenAPI 3.1.0 document.
Types
The named types of the document, which the operations above link to. A member marked optional can be absent; a client ignores members it doesn't know.
CompanyRef
Identifies a Company by its origin and display name.
originstringrequiredCompany origin URL, such as
https://food-demo.poppylab.dev.namestringrequiredHuman-readable company name for display.
ProposalRef
References a specific proposal at an exact revision. Approvals bind strictly to revision.
companystringrequiredOrigin URL of the Company holding the proposal.
proposalstringrequiredUnique proposal ID issued by the Company.
revisionstringrequiredExact revision token shown to the user for approval.
Answer
Structured payload carried by a quick-reply Choice. Must contain exactly one member; Companies are referenced by origin and values are never parsed as free text. approve and decline decide a proposal at its exact revision; signin tells the client to call POST /api/v1/conversations/{id}/sign-ins; signout signs out of that Company; resume retries the request that waited for sign-in; invitation accepts or declines a Direct Conversation.
Exactly one of these shapes:
companystringrequiredSelects an already-connected Company by origin.
connectstringrequiredConnects a new Company by origin URL.
removearray ofstringrequiredDisconnects the listed Company origins.
keeparray ofstringrequiredKeeps only the listed Company origins when replacing a full conversation.
messagestringrequiredSends a scripted prompt text as the user's turn.
approveProposalRefrequiredApproves the referenced proposal.
declineProposalRefrequiredDeclines the referenced proposal.
signinobjectrequiredPrompts the client to start a Company sign-in flow.
companystringrequiredOrigin URL of the Company to sign in to.
access"read"|"write"requiredPermission level to request (
readorwrite).
signoutstringrequiredOrigin URL of the Company to sign out from.
resumestringrequiredOrigin URL of the Company whose pending request should resume after sign-in.
invitationobjectrequiredResponds to a Company's invitation to speak directly with the user.
companystringrequiredOrigin URL of the Company that sent the invitation.
acceptbooleanrequiredtrueto open a Direct Conversation;falseto decline.
Choice
A quick-reply button attached to an agent message. Render label and submit answer verbatim; users may also reply in free text.
labelstringrequiredShort button label to display to the user.
answerAnswerrequiredStructured payload to submit to
POST /api/v1/conversations/{id}/answerswhen chosen.
AgentStep
One protocol action taken during a turn, shown in the activity trace.
textstringrequiredPlain-language summary of what the agent did.
how"API"|"Company's agent"|"sign-in"|"setup"requiredChannel or phase used for this step.
access"view"|"view and change"|nullrequiredAccess level used for this step, or
nullfor signed-out calls.state"done"|"failed"|"waiting"requiredOutcome of this step.
companystringoptionalOrigin URL of the Company involved, when applicable.
argsstringoptionalSanitized JSON summary of arguments sent to the Company.
AgentMessage
A single message in the conversation transcript.
idstringoptionalOnly in a turn streamed with
Accept: text/event-stream, on each of the agent's messages: the ID itsmessage.deltaevents named. Match it to the sentences shown, and drop shown sentences whose ID no message carries.from"user"|"agent"|"company"requiredSpeaker role.
agentwithoutcompanyis the agent's own system voice;companyis untrusted Company content.textstringrequiredMessage body in plain text or light Markdown.
spokenstringoptionalVoice-ready version of
text(one or two short sentences, no Markdown or IDs, spoken currency). Generated deterministically, never by a model.companyCompanyRefoptionalCompany this message is from or about.
usingarray ofCompanyRefoptionalCompanies consulted while producing this reply.
authorstringoptionalCompany-provided author label, such as a support agent.
directbooleanoptionaltruewhen sent inside a Direct Conversation (§8.10).choicesarray ofChoiceoptionalQuick-reply actions for the user.
linksarray ofstringoptionalSafe HTTPS links surfaced by the turn.
stepsarray ofAgentStepoptionalProtocol steps executed during this turn.
datastringoptionalPretty-printed structured payload attached to a message.
CompanyState
Connection, authentication, and Direct Conversation state for one Company.
originstringrequiredCompany origin URL.
namestringrequiredCompany display name.
urlstringrequiredCompany homepage URL.
signedInbooleanrequiredtruewhen the user has an active OAuth grant.scopesstringoptionalSpace-separated OAuth scopes currently granted.
signingInbooleanrequiredtruewhile a sign-in flow is in progress.consentVersionintegerrequiredMonotonic counter incremented each time consent is granted or upgraded.
accessLostbooleanrequiredtruewhen the Company revoked or rejected the stored grant.directobjectrequiredDirect Conversation status for this Company.
openbooleanrequiredtruewhile a Direct Conversation is active.invitationstringornullrequiredReason text for a pending Direct Conversation invitation, or
null.
Proposal
A state-changing operation held by a Company for explicit user approval (Operations v3). Nothing executes until approved.
idstringrequiredOperation ID issued by the Company.
companyCompanyRefrequiredCompany holding the pending change.
revisionstringrequiredExact revision token required when approving. Changes if terms shift.
summarystringoptionalCompany-authored plain-text summary of the change.
termsobjectrequiredAuthoritative structured terms computed by the Company (amounts, dates, balances).
state"proposed"|"succeeded"|"declined"|"refused"|"expired"|"superseded"|"uncertain"requiredCurrent lifecycle state of the operation.
expiresAtstringrequiredISO 8601 timestamp after which the proposal cannot be approved.
resultstringoptionalOutcome message or refusal reason once resolved.
spokenstringrequiredAgent-generated spoken description derived from
terms(never the Company's summary).
ConversationState
Complete snapshot of a conversation, its connected Companies, transcript, and proposals.
idstringrequiredUnique conversation identifier.
activebooleanrequiredtruewhile open;falseonce ended and read-only.keptUntilintegeroptionalUnix timestamp (ms) when an ended conversation is purged from storage.
companiesarray ofCompanyStaterequiredCurrently connected Companies (up to 3).
removedarray ofCompanyRefrequiredCompanies previously disconnected from this conversation.
messagesarray ofAgentMessagerequiredOrdered conversation transcript.
proposalsarray ofProposalrequiredAll proposals raised in this conversation.
TurnResult
Result of a completed message or quick-reply turn.
conversationstringrequiredConversation ID.
messagesarray ofAgentMessagerequiredMessages added during this turn (or the full list when
replacedistrue).replacedbooleanrequiredtruewhen earlier messages were withdrawn (for example after losing access or disconnecting a Company).stateConversationStaterequiredFull updated conversation state.
MessageDelta
One sentence of one of the agent's messages, sent as soon as it is written. A voice client speaks spoken as each one arrives.
type"message.delta"requiredAlways
message.delta; also the SSE event name.messagestringrequiredID of the agent message this sentence belongs to; the
turnevent's message with thisidholds the whole text.indexintegerrequiredPosition of the sentence within its message, from 0.
textstringrequiredThe sentence as written, with the whitespace around it, so the texts of one message joined are its text. Ends at a stop, a line's end, or a clause or space before about 220 characters; never inside a word.
spokenstringrequiredThe sentence to read aloud, made by the same fixed rules as a message's
spoken. Empty when it holds nothing to say, such as a table row or a link.
TurnEvent
One Server-Sent Event of a turn streamed with Accept: text/event-stream; type matches the SSE event: field. message.delta events come first, one per sentence, then exactly one turn or error. Only the agent's words come as sentences: Company content comes whole in the result as its own message (§10.1). Demo-mode answers and the agent's own lines, which are ready at once, come as sentences too, all together just before turn.
Exactly one of these shapes:
type"turn"requiredAlways
turn; the last event of a turn that ended.resultTurnResultrequiredThe same result as the JSON answer; each agent message carries the
idits sentences named.
type"error"requiredAlways
error; the last event of a turn that failed after it began.statusintegerrequiredThe HTTP status the JSON answer would have had.
codestringoptionalMachine-readable error code, when there is one.
errorstringrequiredUser-facing explanation that can be shown as is.
ModelChoice
Selects which model handles a turn. Defaults to demo when omitted.
provider"demo"|"free"|"openai-compatible"|"anthropic"requiredModel backend:
demo(scripted examples, no LLM),free(deployment's Workers AI model), or bring-your-own-key (openai-compatible,anthropic).apiKeystringoptionalProvider API key for
openai-compatibleoranthropic. Sent per request and never stored.modelstringoptionalOptional model identifier for bring-your-own-key providers.
turnstilestringoptionalSingle-use Cloudflare Turnstile token required for
freeturns. Missing, invalid, or over-quota turns fall back todemowith an explanatory note.
Decision
Outcome of approving or declining a proposal.
proposalProposalrequiredUpdated proposal after applying the decision.
stateConversationStaterequiredFull updated conversation state.
SignIn
Details for launching a Company OAuth sign-in flow. The agent never sees the user's password; final status arrives on the SSE event stream.
urlstringrequiredURL to open for consent. For browsers: the Company's consent page. For apps: a single-use agent link to open in
ASWebAuthenticationSession(or equivalent).expiresAtintegeroptionalUnix timestamp (ms) when an app sign-in link expires (3 minutes).
endUrlstringoptionalFixed callback completion URL an app watches for (
?result=doneor?result=failed).
AgentEvent
One Server-Sent Event payload. type matches the SSE event: field; the initial event is always state.
type"state"|"message"|"messages.replaced"|"signin.completed"|"signin.failed"|"access.lost"|"signout"|"proposal.created"|"proposal.expired"|"proposal.replaced"|"proposal.updated"|"company.added"|"company.removed"|"conversation.ended"|"session.ended"requiredEvent type and SSE event name.
stateConversationStateoptionalPresent on
stateandmessages.replaced.messageAgentMessageoptionalPresent on
message.companyCompanyRefoptionalPresent on
signin.*,access.lost,signout, andcompany.*.proposalProposaloptionalPresent on
proposal.*.keptUntilintegeroptionalUnix timestamp (ms) until an ended conversation is purged. Present on
conversation.ended.code"invalid_token"|"session_revoked"optionalPresent on
session.ended:invalid_tokenmeans refresh the access token and reconnect;session_revokedmeans sign in again.
Error
Standard error envelope returned on 4xx and 5xx responses.
codestringoptionalStable machine-readable error code for programmatic handling.
errorstringrequiredPlain-language error message safe to show to the user.
Passkey
Metadata for a WebAuthn passkey registered on an account. Public keys are never returned.
idstringrequiredUnique passkey identifier within the account.
namestringrequiredDevice description captured when the passkey was registered.
createdintegerrequiredUnix timestamp (ms) when the passkey was added.
lastUsedintegeroptionalUnix timestamp (ms) when the passkey was last used to sign in.
syncedbooleanrequiredtruewhen the authenticator reports multi-device passkey backup.
Account
An anonymous passkey-backed agent account. Holds no email or password.
idstringrequiredOpaque account identifier.
labelstringoptionalOptional user-chosen label for the account.
createdintegerrequiredUnix timestamp (ms) when the account was created.
passkeysarray ofPasskeyrequiredPasskeys registered on this account.
channelsarray ofobjectrequiredExternal channels linked via one-time link codes.
channelstringrequiredLinked external channel name.
linkedintegerrequiredUnix timestamp (ms) when the channel was linked.
sessionstringrequiredSession ID authenticating the current request.
unclaimedintegeroptionalBrowser-only count of anonymous pre-sign-in conversations available to claim.
SessionTokens
Bearer and rotating refresh tokens issued to native client apps. Store in the OS keychain; never log or place in URLs.
sessionstringrequiredDevice session identifier.
accessTokenstringrequiredShort-lived bearer token (~15 min). Send in
Authorization: Bearer <token>.accessTokenExpiresAtintegerrequiredUnix timestamp (ms) when
accessTokenexpires.refreshTokenstringrequiredSingle-use rotating refresh token. Reusing a spent token revokes the entire session.
refreshTokenExpiresAtintegerrequiredUnix timestamp (ms) when
refreshTokenexpires.
SignedIn
Returned after creating an account or signing in with a passkey.
accountAccountrequiredThe authenticated account.
tokensSessionTokensoptionalReturned only to native apps (requests without an
Originheader); browsers receive anHttpOnlycookie.
CreationOptions
Challenge and WebAuthn creation options for registering a new passkey.
ceremonystringrequiredOpaque single-use ceremony ID to echo back within 5 minutes.
optionsobjectrequiredWebAuthn
PublicKeyCredentialCreationOptionsJSONfornavigator.credentials.create.
RequestOptions
Challenge and WebAuthn request options for usernameless passkey sign-in.
ceremonystringrequiredOpaque single-use ceremony ID to echo back within 5 minutes.
optionsobjectrequiredDiscoverable WebAuthn
PublicKeyCredentialRequestOptionsJSONfornavigator.credentials.get.
PasskeyAnswer
Completes a passkey registration or sign-in ceremony.
ceremonystringrequiredCeremony ID received from the corresponding
/optionscall.credentialobjectrequiredAuthenticator response (
RegistrationResponseJSONorAuthenticationResponseJSON).devicestringoptionalOptional device label shown in the sessions list (e.g. "iPhone" or "Chrome on macOS").
Session
An active device session signed in to an account.
idstringrequiredUnique device session identifier.
kind"browser"|"app"requiredbrowser(cookie-backed) orapp(token-backed).devicestringrequiredDevice description recorded at sign-in.
createdintegerrequiredUnix timestamp (ms) when the session started.
lastUsedintegerrequiredUnix timestamp (ms) of the last authenticated request.
expiresintegerrequiredUnix timestamp (ms) when the session expires.
currentbooleanrequiredtruefor the session authenticating this request.
LinkCode
Single-use code linking an external messaging channel to an account.
codestringrequiredFormatted 8-character one-time code to enter in the channel.
expiresAtintegerrequiredUnix timestamp (ms) when the code expires (5 minutes).