Skip to content

REST API

The Lane.Chat REST API is a small, JSON-over-HTTPS surface for identifying users, tracking events, and registering push tokens from your own backend or a native app. It's the same API the native SDKs use under the hood.

Lane.Chat is SaaS-only; every request targets the official Lane.Chat cloud.

Base URL

https://api.lane.chat/api/v1

All requests are POST with a JSON body and Content-Type: application/json.

Authentication

There are two tiers:

  • POST /sdk/sessions is public. You identify your app with its public app key (app_id, looks like app_1a2b…). Call this first — it returns a short-lived session token.

  • Every other endpoint requires that session token as a bearer credential:

    Authorization: Bearer <session_token>

Session tokens are per-device and expire (see expires_at in the response). Call /sdk/sessions again to obtain a fresh one — reusing the same device_id / fingerprint_hash returns the same underlying visitor.

Response envelope

Every response is a JSON object with a numeric code (0 means success):

json
{ "code": 0, "message": "success", "data": { /* ... */ } }

Errors carry a non-zero code and a human-readable message:

json
{ "code": 422, "message": "fingerprint_hash must be 16 or 64 hex chars", "errors": [] }

Common codes: 422 (validation), 401 (missing or invalid session token), 404 (app_not_found), 429 (rate limited). See Error codes.

Rate limits

Per app, per hour:

EndpointLimit
/sdk/sessions10,000 / hour
/sdk/events100,000 / hour

See Rate limits for headers and backoff guidance.

Endpoints

Start a session

POST /sdk/sessionspublic. Creates (or reuses) a visitor for a device and returns a session token.

FieldTypeRequiredNotes
app_idstringyesYour public app key (app_…)
fingerprint_hashstringyes16- or 64-hex device hash (canonical: SHA-256)
device_idstringnoStable device id (IDFV / ANDROID_ID). Derived from the hash if omitted
platformstringnoios, android, web, or unknown
sdk_versionstringnoFree-form, ≤ 40 chars
app_versionstringnoFree-form, ≤ 40 chars
os_versionstringnoFree-form, ≤ 40 chars
bash
curl -X POST https://api.lane.chat/api/v1/sdk/sessions \
  -H "Content-Type: application/json" \
  -d '{
    "app_id": "app_1a2b3c…",
    "fingerprint_hash": "e3b0c44298fc1c149afbf4c8996fb924…",
    "device_id": "A1B2-C3D4",
    "platform": "ios"
  }'
json
{
  "code": 0,
  "message": "success",
  "data": {
    "session_token": "eyJ0eXAiOiJKV1Qi…",
    "expires_at": "2026-07-30T17:17:55+08:00",
    "client_id": 999212,
    "device_id": "A1B2-C3D4"
  }
}

Identify a user

POST /sdk/identifybearer. Attaches your own user id and traits to the session's visitor, so agents see who they're talking to and one person maps to one visitor across web and native.

FieldTypeRequiredNotes
user_idstringyesYour stable user id, ≤ 128 chars
traitsobjectnoFlat key/value map (email, name, plan…)
bash
curl -X POST https://api.lane.chat/api/v1/sdk/identify \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <session_token>" \
  -d '{
    "user_id": "user-42",
    "traits": { "email": "[email protected]", "name": "Ada", "plan": "pro" }
  }'
json
{ "code": 0, "message": "success", "data": { "client_id": 999212, "external_user_id": "user-42" } }

Register a push token

POST /sdk/push/registerbearer. Stores an APNs/FCM token so Lane.Chat's servers can push agent replies to the device. Your signing key stays on the server; the client only forwards the device token.

FieldTypeRequiredNotes
device_tokenstringyesAPNs/FCM token, ≤ 255 chars
platformstringyesios or android
bash
curl -X POST https://api.lane.chat/api/v1/sdk/push/register \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <session_token>" \
  -d '{ "device_token": "fMEP0…", "platform": "ios" }'
json
{ "code": 0, "message": "success", "data": { "token_id": 553, "client_id": 999212, "platform": "ios", "registered": true } }

Track an event

POST /sdk/eventsbearer. Records a product event against the visitor. Useful for triggering flows and giving agents context.

FieldTypeRequiredNotes
event_namestringyes≤ 80 chars
propertiesobjectnoFlat key/value map
bash
curl -X POST https://api.lane.chat/api/v1/sdk/events \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <session_token>" \
  -d '{ "event_name": "checkout_started", "properties": { "cart_total": 42.0 } }'
json
{ "code": 0, "message": "success", "data": { "event_id": 2, "event_name": "checkout_started", "accepted": true } }

Fingerprint hash

fingerprint_hash uniquely identifies a device install. The canonical form is a 64-character SHA-256 hex digest; a 16-character legacy hash is also accepted. Send the same hash across calls so the server reuses one visitor for the device.

Opening chat

The REST API handles identity, events, and push — it does not stream messages. To show the conversation, open the hosted chat page (or use a native SDK), passing the identity so web and native share one visitor:

https://cdn.lane.chat/widget.html?app_id=app_1a2b…&fp=<fingerprint_hash>&did=<device_id>&user_id=<user_id>

The hosted chat page and the SDKs handle the live conversation — message delivery, typing, and calls — for you.

Lane.Chat — AI customer support, multichannel CRM, and roleplay AI.