API reference

Base URL https://api.parleyai.app. JSON in and out. The SDKs wrap the client endpoints; your backend uses the server endpoints.

Authentication#

NameTypeDescription
X-Parley-App-Key: pk_…app keyIdentifies the application environment. Public.
Authorization: Bearer ps_…sessionCustomer session token from POST /v1/sessions. Expires after 90 days of inactivity.
Authorization: Bearer sk_…secret keyServer API. Never use in clients.

Browser requests must come from an allowed origin. Production keys return 402 plan_required without an active subscription.

Client endpoints#

NameTypeDescription
GET /v1/configapp keyBranding, strings, AI name and invitations.
POST /v1/sessionsapp keyCreate or resume an anonymous session. Body: { platform, anonymousId?, appVersion?, locale?, device? }.
POST /v1/identifysession{ userId, userHash?, email?, name?, avatarUrl?, attributes? }
POST /v1/logoutsessionRevoke the session.
GET /v1/customer · PATCH /v1/customersessionRead or update the current customer.
GET /v1/conversationssessionThe customer's conversations.
POST /v1/conversationssession{ subject?, message?: { body, attachmentIds?, idempotencyKey } }
GET /v1/conversations/:idsessionConversation with the latest 50 messages. ?before= for older.
GET /v1/conversations/:id/messagessession?after= or ?before= ISO timestamps.
POST /v1/conversations/:id/messagessession{ body, attachmentIds?, idempotencyKey } — retries with the same key return the original message.
POST /v1/conversations/:id/readsessionMark replies as read.
POST /v1/conversations/:id/handoffsessionAsk for a person.
POST /v1/attachments · GET /v1/attachments/:idsessionSigned upload slot · signed download URL.
POST /v1/eventssession{ name, properties? }
POST · DELETE /v1/device-tokenssession{ provider: apns | fcm, token, apnsEnvironment? }
GET /v1/offerssessionActive offers for this customer.
POST /v1/engagementsession{ subjectType, subjectId, kind: impression | click | dismiss }
POST /v1/review-requests/eligibilitysessionWhether to request a store review now.
GET /v1/streamsessionServer-sent events: message.created, message.updated.

Example

curl -X POST https://api.parleyai.app/v1/sessions \
  -H "X-Parley-App-Key: pk_test_…" -H "Content-Type: application/json" \
  -d '{"platform":"web"}'
# → 201 { "sessionToken": "ps_…", "anonymousId": "…", "customer": {…}, "config": {…} }

Server endpoints#

NameTypeDescription
GET /v1/server/customers/:userIdsecret keyCustomer with subscription and timestamps.
PUT /v1/server/customers/:userIdsecret keyCreate or update { email?, name?, avatarUrl?, attributes? }.
DELETE /v1/server/customers/:userIdsecret keyDelete the customer and all their data.
POST /v1/server/customers/:userId/eventssecret key{ name, properties? }

Errors#

{ "error": { "code": "invalid_request", "message": "Invalid request", "issues": [{ "path": "userId", "message": "Required" }] } }
NameTypeDescription
400invalid_requestValidation failed; see issues.
401unauthorized · identity_verification_failedMissing/invalid key, session or userHash.
402plan_required · limit_reachedProduction key without a plan, or a plan limit.
403forbiddenOrigin not allowed or insufficient role.
404not_foundUnknown id, or one that belongs to someone else.
409already_identifiedCall logout() before identifying a different user.
413attachment_too_large
429rate_limitedBack off; see Retry-After.

Rate limits#

Client endpoints: 120 requests per minute per IP and 60 per minute per customer; 20 new sessions per minute per IP. Server endpoints: 600 per minute per environment.

All list endpoints return at most 100 items. Message sends are idempotent by idempotencyKey — always reuse the key when retrying.