Skip to content
Docs
WebsiteOpen app

Widget

The endpoints the chat widget uses, and the admin settings behind it.

The widget endpoints are called by the visitor’s browser. Apart from config and session, they use the visitor token: Authorization: Visitor od_vis_.... The workspace comes from the session.

Method Path Description
GET /v1/widget/config?key=<widget_key> Public config for the widget
POST /v1/widget/session Start or resume a visitor session
POST /v1/widget/verification Email the visitor a link to verify their address
GET /v1/widget/conversations The visitor’s chat conversations
POST /v1/widget/conversations Start a conversation
GET /v1/widget/conversations/{id}/messages Public messages only, never notes
POST /v1/widget/conversations/{id}/messages Send a message
POST /v1/widget/attachments Upload a file (multipart)
POST /v1/widget/conversations/{id}/handoff Ask for a person after an AI answer
GET, PATCH /v1/widget/settings Admin: widget settings
Terminal window
curl "https://api.opendesk.sh/v1/widget/config?key=<widget_key>"
{ "workspace_name": "Example", "brand_color": "#0A0A0A", "greeting": "Hi, how can we help?", "help_center_url": "https://...", "require_email": false }
Terminal window
curl https://api.opendesk.sh/v1/widget/session \
-H "Content-Type: application/json" \
-d '{ "key": "<widget_key>", "user_id": "42", "user_hash": "<hex hmac>", "email": "[email protected]", "name": "Ana" }'
{ "visitor_token": "od_vis_...", "contact": { "id": "...", "email": "[email protected]", "name": "Ana", "avatar_url": "" }, "ws_token": "<jwt>", "gateway_url": "wss://gateway.opendesk.sh/socket/widget" }
Field Notes
key the workspace’s public widget key, required
visitor_token resume an existing session
email, name what the visitor told you
user_id, user_hash a verified identity: user_hash is hex HMAC-SHA256 of user_id with the widget secret
company { id }, with a verified identity only: your own id for the user’s account. The contact is linked to the company whose external_id it is. A company is never created or changed from here, and an unknown id is ignored
fields with a verified identity only: contact custom fields by key. Only keys that start with widget_ are set; others are ignored

ws_token is a 5-minute widget_ws token for the realtime gateway’s widget endpoint. It lets the visitor join only their own contact topic.

The session also carries verification: status is verified (the visitor confirmed their address, or signed in with user_hash), unverified (they gave an address that is not confirmed) or none (no address). While unverified, email is the address, sent_at when the newest working link went out, and resend_at the earliest time another can.

Terminal window
curl https://api.opendesk.sh/v1/widget/verification \
-H "Authorization: Visitor od_vis_..." \
-H "Content-Type: application/json" \
-d '{ "resend": false, "locale": "fr" }'
{ "status": "unverified", "email": "[email protected]", "sent_at": "2026-11-13T10:00:00Z", "resend_at": "2026-11-13T10:01:00Z" }

Emails the visitor a link to verify the address they gave, in locale (the language the widget shows them; else the brand’s, else the workspace’s) and in the brand’s email design. While a link still works, nothing is sent unless resend is true, so calling it again never sends a duplicate. A verified visitor, or one without an address, gets nothing. Resending waits a minute after the last link, and one visitor or one address gets at most five a day: before resend_at the answer is 429 verification_too_soon. The chat works whether or not the visitor verifies. When they confirm the link, the widget’s socket gets contact.verified, and agents see the contact’s verification change through contact.updated.

Terminal window
curl https://api.opendesk.sh/v1/widget/conversations \
-H "Authorization: Visitor od_vis_..." \
-H "Content-Type: application/json" \
-d '{ "body": "Hi, my order has not arrived." }'

GET and PATCH /v1/widget/settings with { greeting, require_email, enabled, allowed_origins }, from the agent side. Rotate the widget secret with POST /v1/workspace/widget-secret/rotate.

Edit this page on GitHub