API Reference
The HTTP API Ziyarn exposes, and how to authenticate.
Ziyarn exposes two kinds of HTTP API:
- Public — used by the widget and by visitor-facing pages. No account, no API key. The widget authenticates with a domain's embed secret.
- Dashboard — used by the dashboard itself. It authenticates with the signed-in user's session cookie, exactly like the dashboard pages.
There is no API key system yet. If you need to drive Ziyarn from your own backend, use the public endpoints with a domain's embed secret, or ask us for an API key.
Base URL
The API lives on the same host as the dashboard:
https://ziyarn.vercel.app/apiAuthentication
Public endpoints (widget and portal)
The widget sends the domain's embed secret in a header:
curl -H "x-embed-secret: YOUR_EMBED_SECRET" \
https://ziyarn.vercel.app/api/chatThe embed secret is on Dashboard → Domains → [Domain] → Settings → Embed secret. It authorises the domain, not a person: anyone holding it can post to that agent, so treat it like a password.
For signed-in customer chat, also send the short-lived customer pass:
authorization: Bearer CUSTOMER_PASSA request with a pass is scoped to that customer. A request without one is anonymous. A broken pass is rejected; it never falls back to anonymous. See Signed-in Customer Chat.
The booking endpoints are public and need no secret — they are keyed by
domainId.
Dashboard endpoints
They use the session cookie of a signed-in user, so a script can only call them with that user's session. Every one of them checks what the caller may do: their own domains, and the teams they belong to.
Identity API (server-to-server)
Issue a customer pass
POST /api/chat/identity
authorization: Bearer YOUR_IDENTITY_KEY
content-type: application/json{
"externalId": "customer-123",
"email": "customer@example.com",
"name": "Sam"
}externalId is required. email and name are optional. The response is:
{
"token": "…",
"expiresAt": "2026-03-04T10:30:00.000Z"
}The pass lasts 30 minutes and is bound to the domain and customer. This endpoint has no CORS: call it from your server, never from a browser. The identity key is shown once when the feature is enabled.
| Status | Code | Meaning |
|---|---|---|
| 400 | INVALID_BODY | externalId is missing or invalid |
| 401 | INVALID_IDENTITY_KEY | The identity key is missing or wrong |
| 403 | IDENTIFIED_CHAT_DISABLED | The feature is off or the plan no longer includes it |
| 429 | RATE_LIMITED | Too many identity requests for this domain |
Chat API
Get the agent's configuration
GET /api/chatRequires the x-embed-secret header. Returns the agent's name, welcome
message, business type, placeholder text, and the widget variant the domain
uses.
{
"agentName": "Acme Support",
"greeting": "Hi! How can we help?",
"businessType": "retail",
"placeholders": ["Where is my order?"],
"knowledgeSearch": true,
"widgetVariant": "classic"
}Conversation history
GET /api/chat?conversationId=<id>Returns the messages of one conversation. Requires the embed secret.
Signed-in customers use GET /api/chat?history=1 with their pass instead of a
conversation id. The API returns their one open conversation, or an empty
history with conversationId: null if they have none yet. A history=1 request
without a pass answers 401 IDENTITY_REQUIRED.
Send a message
POST /api/chatHeaders: x-embed-secret, content-type: application/json, and
authorization: Bearer CUSTOMER_PASS when the customer is signed in.
{
"message": "Where is my order?",
"conversationId": "optional-id"
}The response is a stream (text/event-stream): the agent's reply arrives
token by token, so the widget can render it as it is written. When the agent
escalates to a human, the owner's replies are delivered on the same stream.
Errors:
| Status | Code | Meaning |
|---|---|---|
| 401 | MISSING_SECRET | The x-embed-secret header was not sent |
| 401 | INVALID_SECRET | The secret does not match a domain |
| 401 | IDENTITY_EXPIRED | The customer pass expired; fetch a new one |
| 401 | INVALID_IDENTITY_TOKEN | The pass is malformed or belongs to another domain |
| 401 | IDENTITY_REQUIRED | history=1 was requested without a pass |
| 403 | IDENTIFIED_CHAT_DISABLED | A pass was sent while the feature is off or paused |
| 403 | RATE_LIMITED | Too many conversations for this domain today |
| 429 | CONVERSATION_LIMIT_REACHED | The plan's daily conversation limit is used up |
Rate limits are per domain and per day, and follow the plan's
conversationsPerDay limit — see Billing.
Booking API (public)
Availability settings
GET /api/public/booking-settings?domainId=<id>Returns the days, hours, slot duration and notice a domain offers.
Open slots
GET /api/public/booking-slots?domainId=<id>&date=YYYY-MM-DDReturns the times still free on that date.
{ "slots": ["09:00", "09:30", "10:00"] }Create a booking
POST /api/public/bookings{
"domainId": "…",
"date": "2026-03-04",
"time": "09:30",
"name": "Sam",
"email": "sam@example.com",
"topic": "Order #123"
}The slot is checked before the booking is written, so two visitors cannot take
the same time. A taken slot answers 409 with SLOT_UNAVAILABLE.
Team API (dashboard session)
These are the endpoints the team page uses. All of them act on teams the caller belongs to, and check the caller's role.
| Method | Path | Who | What |
|---|---|---|---|
GET | /api/workspace | member | The teams the caller belongs to, with their role |
POST | /api/workspace | member | Create a team (the caller becomes its owner) |
PATCH | /api/workspace/[workspaceId] | owner, admin | Rename the team |
DELETE | /api/workspace/[workspaceId] | owner, admin | Delete the team, its memberships and its invites |
POST | /api/workspace/[workspaceId]/invite | owner, admin | Invite someone by email |
DELETE | /api/workspace/[workspaceId]/invites/[inviteId] | owner, admin | Revoke a pending invite |
PATCH | /api/workspace/[workspaceId]/members/[memberId] | owner, admin | Change a member's role |
DELETE | /api/workspace/[workspaceId]/members/[memberId] | owner, admin | Remove a member |
POST | /api/invite/accept | signed in | Accept an invite with its token |
Creating a team:
POST /api/workspace
{ "name": "Acme Support" }Inviting someone:
POST /api/workspace/<workspaceId>/invite
{ "email": "teammate@example.com", "role": "member" }The response carries the invite's accept link. The dashboard emails it; the link is also returned so a client can share it itself.
Webhooks
| Path | From | What |
|---|---|---|
POST /api/webhooks/stripe | Stripe | Payment events; a paid plan is applied to the account's domains |
POST /api/webhooks/resend | Resend | Email delivery, bounce and complaint events |
Both verify the provider's signature before acting on an event.
Error shape
Every endpoint answers a failure the same way:
{ "code": "INVALID_INPUT", "message": "Please fix the highlighted fields" }Some endpoints add fieldErrors for per-field problems:
{
"code": "INVALID_INPUT",
"message": "Please fix the highlighted fields",
"fieldErrors": { "email": ["Invalid email address"] }
}| Code | Status | Meaning |
|---|---|---|
INVALID_INPUT | 400 | The request did not validate |
UNAUTHORIZED | 401 | No or invalid credentials |
FORBIDDEN | 403 | Signed in, but not allowed to do this |
NOT_FOUND | 404 | No such resource, or none you can see |
CONFLICT | 409 | The slug or email is already taken |
PLAN_LIMIT_EXCEEDED | 429 | The plan's limit would be passed |
INTERNAL | 500 | Something went wrong on our side |