Ziyarn Docs

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/api

Authentication

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/chat

The 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_PASS

A 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.

StatusCodeMeaning
400INVALID_BODYexternalId is missing or invalid
401INVALID_IDENTITY_KEYThe identity key is missing or wrong
403IDENTIFIED_CHAT_DISABLEDThe feature is off or the plan no longer includes it
429RATE_LIMITEDToo many identity requests for this domain

Chat API

Get the agent's configuration

GET /api/chat

Requires 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/chat

Headers: 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:

StatusCodeMeaning
401MISSING_SECRETThe x-embed-secret header was not sent
401INVALID_SECRETThe secret does not match a domain
401IDENTITY_EXPIREDThe customer pass expired; fetch a new one
401INVALID_IDENTITY_TOKENThe pass is malformed or belongs to another domain
401IDENTITY_REQUIREDhistory=1 was requested without a pass
403IDENTIFIED_CHAT_DISABLEDA pass was sent while the feature is off or paused
403RATE_LIMITEDToo many conversations for this domain today
429CONVERSATION_LIMIT_REACHEDThe 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-DD

Returns 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.

MethodPathWhoWhat
GET/api/workspacememberThe teams the caller belongs to, with their role
POST/api/workspacememberCreate a team (the caller becomes its owner)
PATCH/api/workspace/[workspaceId]owner, adminRename the team
DELETE/api/workspace/[workspaceId]owner, adminDelete the team, its memberships and its invites
POST/api/workspace/[workspaceId]/inviteowner, adminInvite someone by email
DELETE/api/workspace/[workspaceId]/invites/[inviteId]owner, adminRevoke a pending invite
PATCH/api/workspace/[workspaceId]/members/[memberId]owner, adminChange a member's role
DELETE/api/workspace/[workspaceId]/members/[memberId]owner, adminRemove a member
POST/api/invite/acceptsigned inAccept 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

PathFromWhat
POST /api/webhooks/stripeStripePayment events; a paid plan is applied to the account's domains
POST /api/webhooks/resendResendEmail 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"] }
}
CodeStatusMeaning
INVALID_INPUT400The request did not validate
UNAUTHORIZED401No or invalid credentials
FORBIDDEN403Signed in, but not allowed to do this
NOT_FOUND404No such resource, or none you can see
CONFLICT409The slug or email is already taken
PLAN_LIMIT_EXCEEDED429The plan's limit would be passed
INTERNAL500Something went wrong on our side