Dinghy's widget and operator app use the same HTTP API that you can build on, for example a custom widget, a bot or an integration. Every install serves its full description as OpenAPI 3.1 at /v1/openapi.json, such as https://chat.example.com/v1/openapi.json. The same file is in the repository at apps/server/openapi.json.
Versions
Every route starts with /v1. Within v1, a release may add routes, fields and error codes. A change that would break a client is meant for a new version, and the changelog names every API change.
Two APIs and the ways to sign in
- The widget API, at
/v1/widget/{key}, wherekeyis the workspace's public key. It answers only pages whoseOriginis on the workspace's allowed sites.POST /v1/widget/{key}/visitorscreates a visitor and returns its browser token once. Other calls send it asAuthorization: Bearer <token>. For a signed-in user, the bearer token is a host token that your site's server signs instead, as Add the chat to your website explains. - A reply email's chat page, at
/chat/{token}on the Dinghy server itself. Its page uses the widget API with the link's token, which starts withdcl_, asAuthorization: Bearer dcl_.... The widget API takes that token only from the Dinghy server's own origin, or with noOriginheader, and takes no other token from there. It works for 30 days. - The operator API, at
/v1/operator. It uses the session cookie that sign-in sets. Sign-in and sign-out live at/v1/auth:POST /v1/auth/sign-in/magic-linkwith{ "email" }emails a link,POST /v1/auth/magic-link/verifywith{ "token" }uses one, which the button on the page the link opens does, andPOST /v1/auth/sign-outends the session. They pass through to the BetterAuth library, so their shape follows it and is not part of the versioned API. A request that changes something must also send the server's ownOrigin, so with a session the operator API works only from the operator app's pages. - An API key, for your own scripts and AI agents. It works on part of the operator API, with no session and no
Origin, asAuthorization: Bearer dk_.... See API keys. - An OAuth access token, which an MCP client such as Claude Code gets after an owner or admin approves it in the browser. It starts with
dko_and works wherever an API key of its level works. See OAuth.
Use Dinghy with AI agents explains how to connect an agent and what it should do.
Errors
Every error answer has the same body:
{ "error": { "code": "too_many_requests", "message": "Too many requests. Try again later." } }
Branch on code, which is stable, and show message only to people. The OpenAPI document lists every code and the statuses each route can answer. Some answers also carry a requestId, which the server's log holds too. The common ones:
| Status | Codes | When |
|---|---|---|
| 400 | invalid_request, invalid_reply_to, bad_origin, not_a_member | The request does not match its schema, a reply quotes a message that is not in its conversation, a site is not an http or https origin, or an operator ID is not in the workspace |
| 401 | unauthorized, two_factor_required | No token or session, or one that is no longer valid. With two_factor_required, the session must pass two-step sign-in first |
| 402 | payment_required, read_only | On the cloud plan, a workspace that is not paid for. A self-hosted install never answers 402 |
| 403 | origin_not_allowed, suspended, forbidden, blocked | The site is not allowed or the widget is off, the workspace is suspended, the role or the key's level does not allow it, or an operator blocked the visitor |
| 403 | send_mode_required, send_as_member_required, send_email_required | For an API key's outbound message: the key drafts replies, it may not send as a member, or it may not send with sendEmail: true |
| 404 | not_found | It does not exist, or it is in another workspace |
| 409 | conversation_closed, webhook_limit, site_limit, grant_limit, message_seen | Reopen the conversation to reply or to snooze it, the workspace has 5 webhooks, 20 allowed sites or 50 connected apps already, or the visitor has seen the reply you tried to edit |
| 409 | campaign_key_taken, campaign_ended, campaign_not_live, campaign_live, campaign_sent | For a campaign: another campaign has the key, the campaign ended, a send names a campaign that is not live, or a delete names one that is live or sent messages |
| 409 | human_handling, bots_paused, drafts_text_only | For an API key: a person handles the conversation and the key sends directly, an owner or admin paused every bot, or a key in draft mode sent an image or a file. See Bots |
| 409 | draft_not_waiting, rewrites_off, change_request_pending, change_request_closed, client_id_reused | For Ask to change: the draft no longer waits or is stale, its key does not rewrite drafts, another request waits on it, a key's answer came after the request ended, or its clientId made another draft |
| 413 | too_large | The body is too large |
| 429 | too_many_requests, too_many_streams | A rate limit. Wait for the Retry-After header's seconds |
| 429 | too_many_waiting | The visitor has 5 outbound messages that wait. Cancel one, or wait for them to end |
| 503 | busy, check_unavailable | The server is overloaded for a moment, or it cannot count two-step sign-in attempts. Try again |
In a read-only or suspended workspace, operators can read and export, and a write answers 402 read_only or 403 suspended. A route whose OpenAPI entry has x-workspace-access: closed still works then: presence, removing a member, revoking an invite, and the bulk route, which allows only mark_read then. Deleting the workspace, with x-workspace-access: always, works in every state, also while a cloud workspace waits for its first payment. On Dinghy Cloud, an operator of a read-only workspace can still send a text reply in its welcome chat, which is the route with x-workspace-access: welcome; anywhere else it answers 402 read_only.
Two-step sign-in
An operator can turn on two-step sign-in, with a TOTP code (RFC 6238: 30 seconds, 6 digits). A new session of that operator then answers 401 two_factor_required on every operator route, the event stream, an upload's end and OAuth consent included, until it passes the check. Only GET /v1/operator/me, the check and POST /v1/auth/sign-out work before. me answers twoFactor: off, on, or required while the session waits for the check, and then lists no workspace. It also answers recoveryCodesLeft, the recovery codes not used yet, or null unless twoFactor is on. API keys and OAuth tokens never need it.
POST /v1/operator/two-factor/setupreturns a new secret, as base32 and as anotpauth://URI for a QR code. It answers 409two_factor_onwhen it is on already.POST /v1/operator/two-factor/enablewith{ "code" }confirms the setup with a first code, turns it on, counts this session as passed and returns 10recoveryCodes. They never show again. Every other session of the account must pass the check.POST /v1/operator/two-factor/checkwith{ "code" }passes the check, with a code from the app or a recovery code.POST /v1/operator/two-factor/recovery-codeswith{ "code" }returns 10 newrecoveryCodes, which show only now, and the old ones stop working. It takes only a current 6-digit code from the app, not a recovery code, and writes atwo_factor.recovery_regeneratedaudit line.POST /v1/operator/two-factor/disablewith{ "code" }turns it off. Sessions that never passed the check end.
A wrong code, or one used before, answers 400 wrong_code. A code from the app works once, and so does a recovery code. After 5 wrong codes in 15 minutes, the check, new recovery codes and the turn-off answer 429 too_many_attempts and end the session, and they refuse every code until 15 minutes after the first wrong one. When Valkey does not answer, they check no code and answer 503 check_unavailable, because the limit cannot count. When the stored secret does not open, because AUTH_SECRET changed, they answer 500 two_factor_unreadable, and only the server's admin can turn it off, with chat two-factor-reset.
With a mail server, the account gets an email when two-step sign-in is turned on, turned off, by the operator or by chat two-factor-reset, when a recovery code is used, and when the 5th wrong code ends a session.
Removal request
An operator who lost their app and their recovery codes can ask to remove two-step sign-in after 72 hours. The operator guide explains who is warned and how it stops.
POST /v1/operator/two-factor/removalstarts the request from a session that has not passed the check, and that an email link made in the last 15 minutes. It answerscompletesAt. While a request waits, it answers the same and changes nothing. It answers 409removal_not_neededfor a session that passed or with two-step sign-in off,sign_in_againfor an older session,removal_blockedfor 7 days after a cancel, andmanual_reviewwhen nobody else can stop it: no other owner or admin in the account's workspaces and no unexpired session that passed the check, or a server with no mail server.POST /v1/operator/two-factor/removal/cancelcancels it from a session that passed the check, or answers 409no_removal.POST /v1/account/two-factor-removal/cancelwith{ "token" }cancels it with the token from the email's link, with no session. The link opens a page of the app, and only its button sends this, so opening the link does nothing. It answers 400link_invalidonce the request has ended.- A correct code from the app or a recovery code, on any route that takes one, also cancels it.
POST /v1/operator/two-factor/skip-promptstops the prompt to turn it on again.
The worker sends the warnings, and the 72 hours count from the first one, so completesAt can move later by the time it takes. A request never completes before that warning went out. A cancel ends every session of the account that never passed the check and refuses new requests for 7 days. At the end, the worker removes the secret and the recovery codes and ends every session. me answers removalCompletesAt, the end of a waiting request or null, and asksTwoFactorAgain, true after a removal request or a reset removed it until the operator turns it on again or skips. The members list answers twoFactor as removal_requested while a request waits, and canResetTwoFactor. Each change records team.changed in the account's workspaces, so the Team pages and the account's open apps read the members and me again.
POST /v1/operator/workspaces/{workspaceId}/members/{operatorId}/two-factor-reset removes a teammate's two-step sign-in at once and ends their sessions. Owners reset admins and members, and admins reset members, only for a teammate in no other workspace. Every other case answers the same 403 forbidden, and 409 two_factor_off when it is off.
Sending without duplicates
A message, an image or a file carries a clientId that the client makes, such as m_4f9a2c. A retry with the same clientId returns the first message and creates nothing, so a client can retry a send after any network error.
A widget send also answers conversationStarted: true when that message started a new conversation. A retry of that message answers true too. A visitor who has no open conversation but a closed one writes into their newest closed one: the send reopens it, with its assignee, and answers false. Its status line and conversation.reopened event come before the message, with the visitor as the author. Only a visitor's first message starts a conversation.
The widget's send also takes outboundIds, up to 5 IDs of outbound messages that the visitor read and this message answers, and button, { outboundMessageId, index }, for a value button the visitor chose, by its place from 0. The outbound messages go in the conversation first, in the order the visitor read them, then the message, whose body becomes the button's label. An outbound message that is not this visitor's, was cancelled or expired, or was not read, is left out, and the message still goes in. pageCampaign, { id, button? }, answers a page campaign's card: the campaign's message goes in the conversation first, then the visitor's.
Close, reopen and snooze
PATCH /v1/operator/workspaces/{workspaceId}/conversations/{conversationId} takes one of:
{ "status": "closed" }or{ "status": "open" }to close or reopen it.{ "snooze": { "until": "2026-11-16T09:00:00.000Z" } }to snooze an open conversation until a time, or{ "snooze": { "until": null } }until the visitor writes again.{ "snooze": null }ends a snooze.
A snoozed conversation stays open, and does not count as waiting for a reply until its time passes or the visitor writes. A reply from the team does not end it. A close ends it, and a reopen starts with none. Snoozing a closed conversation answers 409 conversation_closed. Each Conversation has snooze: { "until" } while it is snoozed, with until null until the visitor writes, and null otherwise. A snooze writes a conversation.snoozed change to the operator stream, and the visitor hears nothing of it: no status line, no stream event and no webhook.
A message's body is plain text that the widget, the operator app and reply emails show as a small Markdown: **bold**, *italic*, `code`, blocks between lines of three backticks, [words](https://...) links, bare http and https addresses, and lists that start with -, *, + or 1.. HTML, images and headings stay text, and only http, https and mailto links work. The API stores and answers the body as it was sent.
POST /v1/operator/workspaces/{workspaceId}/conversations/{conversationId}/transcript emails the visitor the whole conversation now, open or closed, whatever the transcript setting says. The email holds the newest messages that fit, at most 100, so Gmail does not cut it. It answers 409 no_email when the visitor gave no email and email_unavailable when the server sends no email. It adds a transcript.requested event, and the worker sends it at least once, as it does reply emails. A transcript drops the visitor's waiting reply email, unless that email also carries a reply from another conversation. Transcripts go to visitors only, never to operators.
A message's kind is text, image or file for what people wrote, and note for a note that only the team sees. Closing or reopening a conversation writes a status line in the same transaction as its conversation.closed or conversation.reopened event and with the event's position, so the widget and the operator app show it in order: kind is closed or reopened, body is null, and the author is whoever made the change (an operator, an API key, or no one shown on Dinghy Cloud's welcome chat). A status line has no message.created event, so it raises no alert, no push and no webhook, it is never a conversation's lastMessage, and it counts toward neither unread replies nor first replies. A client that shows only chat skips these kinds.
Images and files
POST /v1/widget/{key}/uploads and POST /v1/operator/workspaces/{workspaceId}/conversations/{conversationId}/uploads take an image or a file as the raw request body, with clientId in the query. One message carries one image or one file, as its attachment, which is null on any other message.
- PNG, JPEG and WebP bytes become an
imagemessage, whatever their name. Dinghy encodes each image again, up to 5 MB and 16 megapixels, and a message hasattachment: { type: "image", url, width, height }. - Any other file needs
filenamein the query, such asfilename=Order%201042.pdf. Its extension must be PDF, TXT, CSV, LOG, JSON, ZIP, DOC, DOCX, XLS, XLSX, PPT, PPTX, ODT, ODS, MP4 or MOV, and its first bytes must match the type where the type has a signature. It can be up to 10 MB. Dinghy stores it as it came, keeps its name with letters, digits, spaces and._()-only, up to 100 characters, and answers afilemessage withattachment: { type: "file", url, name, size },sizein bytes. - Anything else answers 400
type_not_allowed, with the allowed types in its message. Visitors may send files only while the widget'svisitorFilessetting is on, which it is by default for a new workspace. A workspace from before the release that added files has it off until an owner or admin turns it on. With it off, a visitor's file answers 400not_an_image. Operators and API keys can always send files.
The url of an image or a file is signed and works for at least 15 minutes. A file's URL serves only a download: Content-Disposition: attachment with its name, Content-Type: application/octet-stream, X-Content-Type-Options: nosniff and Content-Security-Policy: sandbox. Dinghy does not scan files for viruses. On Dinghy Cloud, a file counts toward the workspace's storage as an image does, and goes after 12 months: then attachment is { type, removed: true }, with type image or file. A full workspace answers 507 storage_full, and text still sends. Reply emails and transcripts show a file by its name, with a link to the conversation, never as an attachment.
An operator's first reply in a conversation with no assignee assigns it to them, with a conversation.assigned event. A reply with an API key never assigns.
Labels
Labels sort conversations, such as billing or bugs. GET /v1/operator/workspaces/{workspaceId}/labels lists them by name, each { id, name, color }. color is one of gray, red, orange, yellow, green, teal, blue and purple. Every Conversation has labelIds, the IDs of its labels, and GET .../conversations?label={labelId} lists only the conversations with that label. Any member, and any API key, reads them.
With a session, any member adds a label with POST .../labels and { "name", "color" }, where color defaults to gray. Owners and admins change one with PATCH .../labels/{labelId} and either field, and delete one with DELETE, which takes it off every conversation. A name is 1 to 40 characters on one line, and unique in the workspace whatever its case: a second one answers 409 label_name_taken. A workspace keeps up to 100, and the next answers 409 label_limit. Each of these changes writes a workspace.changed change to the operator stream.
PUT .../conversations/{conversationId}/labels/{labelId} puts one label on a conversation, and DELETE on the same path takes it off. Each call changes that label only, so two people, or a person and a bot, never overwrite each other's labels. A repeat changes nothing and answers 200. Signed in or with an API key, both answer 404 when the conversation or the label does not exist. A change writes a conversation.labeled event, for the operator stream and the webhooks.
Bulk actions
POST /v1/operator/workspaces/{workspaceId}/conversations/bulk, with a session, changes up to 100 conversations at once. Its body has an action, the conversationIds, 1 to 100 of them, and the action's own field:
action | Field | What it does to each conversation |
|---|---|---|
close | Closes it, as PATCH with { "status": "closed" } does | |
assign | operatorId, a member or null | Assigns it, and makes a person handle it, as PUT .../assignee with a session does. A non-member answers 400 not_a_member |
label | labelId | Puts the label on it. A missing label answers 404 |
mark_read | Marks it read up to its newest message, for the signed-in operator. It is the only action a read-only or suspended workspace allows, and the others answer 402 read_only or 403 suspended there | |
delete | Deletes it, with its messages, images and files. Owners and admins only |
It answers { "results": [{ "conversationId", "result" }] }, one per ID in the order sent, with a repeated ID once. result is ok, unchanged when it already was as asked (for mark_read, when it was read up to its newest message already), or not_found. A member's delete answers 403 forbidden for the whole request, as the single delete does. Each conversation goes through the same code as the single action, with its own event, so webhooks and alerts behave as if done one by one. They change 25 to a transaction, so a failure partway keeps the transactions before it, and a retry of the same request is safe. There is no bulk reply.
Notes
A note is a message that only the workspace's team sees. Send "note": true in the body of POST .../conversations/{conversationId}/messages, with a signed-in operator or an API key of either level, or use the MCP add_note tool. It takes the same clientId and replyToMessageId as a reply, and answers the same InboxMessage, with kind note. A note is text only: the image upload refuses a note with 400 invalid_request.
- A note goes in a closed conversation too, and leaves it closed. It never assigns the conversation, and an operator's first reply after it still does.
- The visitor never gets a note in any form: not in the widget's message list or stream, not as an edit or a delete there, not in a reply email or a transcript, and not as a quote, because a reply that quotes a note answers 400
invalid_reply_to. A note can quote any message, another note too. - A note raises a push and an email only for the members it mentions. It is never a conversation's
lastMessage, it does not stop a conversation from waiting, it does not move the conversation up the list, it is unread only for the members it mentions, and it is not a first reply in analytics. Its receipt is always{ "readAt": null, "emailedAt": null }. - Its author edits it at any time, as the visitor never sees it, and deletes it as a reply. An owner or admin deletes anyone's.
- Its
message.created,message.updatedandmessage.deletedevents reach webhooks as any message's do, withdata.message.kindset tonote. On the operator stream, itsmessage.createdchange hasfromVisitorfalse. - A workspace export keeps notes, with their kind.
Mentions
A note can mention members: pass their operator IDs, from GET .../members or the MCP list_members tool, as mentions in the body of the send, at most 10. Write @Name in the text too, so people reading the note see who it is for. The server keeps only the IDs of current members, without the note's author, and drops the rest. Every message has mentions, the list it kept, which is empty for anything but a note.
- Each member a note mentions gets an alert with the note's text, by push and by email as their email alert setting says, even when the conversation is assigned to someone else. A member the note names in its text but not in
mentionsgets nothing. - The conversation is unread for each of them until they read past the note.
- An edit takes
mentionstoo, and replaces the list. Only the members it did not mention before get an alert, and removing a mention sends nothing. An edit with nomentionskeeps them. - A workspace export keeps them, and an import maps them to the operators of the new server.
Saved replies
Saved replies are the team's own answers to common questions, which an operator inserts in the composer by typing /. GET /v1/operator/workspaces/{workspaceId}/saved-replies lists them by shortcut, with id, body in Markdown and updatedAt. Any member, and any API key, reads them, and MCP has list_saved_replies, so a bot can answer in the team's words.
With a session, any member adds one with POST .../saved-replies and { "shortcut", "body" }, changes one with PATCH .../saved-replies/{savedReplyId} and either field, and deletes one with DELETE. A shortcut is 1 to 32 lowercase letters, digits and dashes, starts with a letter or a digit, and is unique in the workspace: a second one answers 409 saved_reply_shortcut_taken. A body is 1 to 5,000 characters. A workspace keeps up to 200, and the next answers 409 saved_reply_limit. API keys cannot change them.
Quotes, edits and deletes
A send can quote one earlier message of the same conversation: pass its ID as replyToMessageId in the body of a text reply or the widget's send, in the query of an image upload, or to the MCP reply tool. It must be text or an image that was not deleted, or the send answers 400 invalid_reply_to. Every message then has replyTo, null or { id, authorName, fromVisitor, text, hasImage }. text is the quoted message's whole text with its line breaks, with its Markdown marks removed. When the quoted message is deleted later, id is null and text is empty: show "Original message deleted". The widget API gives an operator's first name as authorName, and null for the visitor's own message.
PATCH /v1/operator/workspaces/{workspaceId}/conversations/{conversationId}/messages/{messageId} with { "body" }, and a note's mentions, changes the text of the signed-in operator's own text reply or note, and sets editedAt. It works only while the visitor has not seen the reply: it answers 409 message_seen once the visitor read it in the chat, or once a reply email or a transcript carried it or is being sent. A reply email still waiting reads the text when it goes, so it carries the edit. Nobody edits a visitor's message, and API keys and MCP cannot edit.
DELETE on the same path deletes a message: an operator deletes their own, and an owner or admin deletes anyone's, a visitor's too, such as a pasted card number. The row stays, so positions, receipts and quotes keep working: deleted is true, and body and attachment are null in every answer and webhook, and body is null in the export. Its image or file goes from storage as other deleted ones do. API keys cannot delete.
An edit adds a message.updated event and a delete a message.deleted event, in the same transaction. The widget's stream and message list send the message again at that event's position, with its seq unchanged, so a client replaces its copy by id and keeps sorting by seq.
A message has via: api or mcp for a key's reply, draft for a draft an operator sent, email for a visitor's message that came as a reply by email, and null otherwise. A message that an outbound message became keeps its via and has outboundId, the outbound message's ID, and sender: "team" or { operatorId, name } when the visitor saw the workspace or a member rather than its author, and null otherwise. A visitor's answer with a button has button: { value, label }, and its body is the label. outboundId, sender and button are null on every other message, and message.created webhooks and wait_for_events carry them too. Only a message with via: "email" has fromAddress: the address the email came from, lowercased, or null when it was the visitor's email. readAt is when the visitor's read position first passed a reply, null before that and for replies read before this field existed. GET .../messages/{messageId}/receipt answers { readAt, emailedAt }, where emailedAt is when the first reply email or transcript after the reply went out.
Visitors
The operator API's Conversation describes the visitor: name, email, userId, attributes (the custom attributes your site signed), blocked, device (such as "Chrome on macOS"), lastPage, lastSeenAt, country (ISO 3166-1 alpha-2) and timeZone (IANA), the last two from the widget's beat. The conversation also has pageContext: what the page last sent with Dinghy.setContext(), or null. Your site does not sign it, so anyone can change it in their browser. Treat it as a hint, never as proof. A conversation's messages also answer visitorOnline: true while the visitor has a widget stream open, and null when the server cannot tell.
POST /v1/widget/{key}/page with { "page", "title" } reports the page the visitor is on. The widget sends it only for a visitor who has chatted, when it loads and when the address changes. The server keeps the origin and path, never the query string or # part, up to 2,000 characters, and the title on one line, up to 200 characters. It stores nothing for a visitor with no conversation, and a host token sent here never creates a visitor. Each report adds a row to the visitor's page journey, unless it repeats the newest row's address, in which case it only fills in a new title. A visitor keeps the newest 100 rows, and the worker deletes rows after 90 days. The widget's GET /v1/widget/{key}/me answers chatted, true once the visitor has a conversation.
POST /v1/widget/{key}/context with { "locale", "context": { ... } } sends the widget's language, en, fr or es, and what the page set with Dinghy.setContext(). Either may be left out, but not both. context holds at most 20 keys of 1 to 40 characters, each with a string of up to 200 characters, a number, true, false or null. Each report replaces the last one. The widget sends it on each page load for a visitor who has chatted, and again after the first message, and the server keeps it only for a visitor who has a conversation. It goes with the visitor's last conversation, as the page journey does. The visitor's locale sets the language of their reply emails, transcripts and chat page, and the inbox shows it on the conversation's visitor.
POST /v1/widget/{key}/beat with { "tab", "page", "title", "referrer", "timeZone" } says a tab of the site is open, for the live view. The loader sends it on load, once a minute while the tab shows, and when a chat starts, with the visitor's token when they have one. tab is 6 to 32 lowercase letters and digits that the page keeps in memory only. The server keeps the page's origin and path, the title, the referrer's origin unless it is the site's own and a known time zone, looks up the country of the request's address and drops the address, and keeps the tab in Valkey for 90 seconds after its last beat, at most 2,000 tabs a workspace. For a visitor with a token, it saves country and timeZone on the visitor. It answers { "ok": true, "waiting", "pages" }, where waiting counts the visitor's outbound messages that wait to show, so the loader fetches the chat only when one waits, and pages lists the live page campaigns for this visitor, each { id, url, seconds }. A beat never creates a visitor. POST /v1/widget/{key}/leave?tab= drops a tab at once, and the loader sends it with sendBeacon. GET /v1/operator/workspaces/{workspaceId}/visitors/live lists the open tabs, newest first, with visitor (id, name, email, userId and conversationId) for a visitor who has chatted, as visitors, and the most tabs open at once in each of the last 60 minutes, oldest first, as lastHour. /visitors/live/count counts the open tabs. Each answers null when Valkey cannot tell. A chatting visitor's waitingSince is the time of their message when their open, unsnoozed conversation's newest message is theirs, else null. GET .../visitors/stats?days=7|30|90&tz= (default 30 days and UTC) answers the site's numbers for a period, which the Analytics page shows. A period runs from the start of the day, days - 1 days ago, in tz, to now, as for analytics below. It holds visits, pageViews and chats (the conversations visitors started, without the welcome chat and test visitors), and previous with the same three counts for a period of the same length just before, or null when the stored hours do not reach back to its start, peak ({ count, at }, the minute with the most tabs open at once, or null), series (the visits per day in tz, oldest first), and the top 8 pages ({ page, title, count }) and referrers ({ referrer, count }, with null for none). A visit is a new tab with no referrer or one from another origin, and a page view a new tab or a page change in one. The beats count each hour in Valkey, at most 200 distinct pages and 200 referrers an hour, and the worker copies the hours to Postgres within about a minute and keeps them 182 days.
POST /v1/widget/{key}/typing with { "draft" }, up to 2,000 characters, passes a visitor's unsent words to the workspace's open operator apps, which get it as a notice. It stores nothing, and does nothing for a visitor with no open conversation, a blocked visitor, or a workspace whose typingPreview is off. Owners and admins change that with PUT /v1/operator/workspaces/{workspaceId}/widget/typing-preview and { "enabled" }, and the appearance answers typingPreview, so the widget sends nothing when it is off.
GET /v1/operator/workspaces/{workspaceId}/contacts lists the visitors who have a conversation, newest seen first, or with sort=firstSeen newest first. q matches the name, email or user ID, and limit is 1 to 100. hasChatted=false adds the people who have no conversation: those your server created, a signed-in user your site identified, and those you sent an outbound message to. filter keeps the contacts that match a condition, as JSON text, such as filter={"field":"attributes.plan","op":"eq","value":"pro"} URL-encoded. Each contact has company (the signed company attribute), country, timeZone, lastSeenAt, createdAt, conversationCount and pictureUrl (on Dinghy Cloud, the founder's picture on the new workspace's founder contact, and null for everyone else), and the answer's next goes in before for the next page. GET .../contacts/export downloads them all as CSV, with every cell that a spreadsheet would read as a formula starting with a quote mark. GET .../contacts/{visitorId} adds online (null when the server cannot tell), attributes, pageContext, the team's private note, the pages, and every conversation with messageCount, assigneeName, closedBy (the member or API key that closed it, null while open or when the visitor closed it) and firstReplySeconds. PATCH on it changes note, and for a visitor your site did not sign in, name and email. A signed-in visitor's name and email answer signed_in. Owners and admins DELETE a contact with all their conversations, messages and images.
A conversation's messages answer visitorPages: the visitor's newest 20 pages, newest first, each with path (origin and path), title (null when the page had none) and viewedAt. They also answer welcome, which is null except on Dinghy Cloud's welcome chat (see Architecture). On the new workspace's side, welcome is { "with": "founder", "pictureUrl" }, and the conversation's visitor.pictureUrl holds the same picture, in lists too. Every other visitor's pictureUrl is null. And they answer receipts: how far the visitor has seen the replies, as message positions. A reply at or below readSeq was read in the chat. Each entry of emails is a reply email or a transcript, with the positions of the first and last message it carried, fromSeq and toSeq, and sent. A reply inside a sent one's range went out by email, and one inside only failed ones' ranges was in an email that failed. A reply in none and above readSeq is stored only.
GET /v1/operator/workspaces/{workspaceId}/get-started answers which first steps are done for the signed-in member: install, logo, widget, team, notifications and chat, and dismissed. POST .../get-started/dismiss hides them for that member.
GET /v1/operator/workspaces/{workspaceId}/conversations answers waiting, the open conversations whose newest message is the visitor's and that are not snoozed, snoozeEndsInMs, the milliseconds until the workspace's next timed snooze ends (null with none), after which waiting can change with no change on the stream, and openBy, the open conversations for each filter: all, mine (always 0 for an API key) and unassigned. Each Conversation has startedBy: visitor, or team when an outbound message started it. ?startedBy=team lists only the conversations an outbound message started and the visitor has not answered yet. They do not count in waiting. GET /v1/operator/waiting answers waiting for each of the signed-in operator's workspaces, for the workspace menu.
Each operator has their own read position in each conversation. A Conversation has unread, true when a visitor message that is not deleted is past the signed-in operator's position, and always false for an API key. POST /v1/operator/workspaces/{workspaceId}/conversations/{conversationId}/read with { "seq" }, a message's seq, moves the position forward to it, never back and never past the newest message. Only a signed-in operator calls it; an API key gets 403.
GET /v1/operator/workspaces/{workspaceId}/conversations/search?q= searches open and closed conversations by the visitor's name, email or user ID and by message text, ignoring case. q has 3 to 100 characters, and the answer has at most 50 conversations, newest activity first. A conversation found by a message has that message's text as lastMessage.body and text as its kind, while fromVisitor and createdAt stay those of the newest message.
GET /v1/operator/workspaces/{workspaceId}/analytics?days=30&tz=Europe/Paris answers support numbers for any member and any API key. days is 7, 30 or 90, and tz is an IANA time zone, by default UTC. The period runs from the start of the day, days - 1 days ago, in tz, to now, and every number is about the conversations that started in it: started, startedByTeam (those of started that an outbound message started), closed (closed now), answered, firstReply with medianSeconds, p90Seconds and fast (how many of started got a first reply within 5 minutes), perDay (one { date, conversations } per day, oldest first), repliers (conversations by who sent the first reply, most first: { kind: "operator", operatorId, name }, { kind: "api_key", apiKeyId, name }, or one { kind: "former" } for deleted operators, each with conversations) hours (7 rows, Monday first, of 24 counts by the hour each conversation started) and labels (conversations by each label they have now, most first: { labelId, name, color, conversations }, leaving out labels on none), and previous, with started and firstReply (medianSeconds and fast) for a period of the same length just before, which ends days days ago, to compare with. A first reply is the first message from an operator or an API key after the visitor's first message, timed from that message, so a conversation the team started waits only once the visitor writes. The numbers come from the stored conversations and messages; nothing tracks visitors for them. On Dinghy Cloud, the welcome chat counts nowhere, and test visitors count nowhere either.
Replies by email
On a server with INBOUND_EMAIL_DOMAIN and a receiver set (see Self-hosting), each reply email and transcript has Reply-To: "<workspace name>" <reply+<workspace>.<token>@<INBOUND_EMAIL_DOMAIN>>, with the name quoted or encoded as it needs, where the workspace is its ID in hex with no dashes and the token is 25 characters of lowercase letters and digits. The server stores only the token's hash, with the conversation and the visitor. The address works until 90 days after its last use and goes with its conversation, and exports leave it out, as they do chat links. Its emails start with a marker line, "Write your reply above this line" in the visitor's language. When a reply email carries replies from several of the visitor's conversations, its address goes to the conversation of the newest reply.
The mail forwarder posts each email to POST /v1/inbound-email as the raw message, up to 25 MB, with a Content-Length and Dinghy-Inbound-Signature: t=<unix seconds>,v1=<hex>. The hex is the HMAC-SHA256 of the time, a dot and the body's bytes under INBOUND_EMAIL_SECRET, as webhooks sign, and the time must be within 5 minutes of the server's. The server refuses a request without a Content-Length with 411 length_required and a larger one with 413 too_large, and checks the signature's age and how many emails it holds, all before it reads the body. It checks the signature itself before it parses the email. It answers:
- 200
{ "ok": true }when it took the email, when it had already taken it, and when it dropped an automatic answer (one withAuto-Submittedother thanno,Precedence: bulkorlist, or a common out-of-office subject) or an email with no sender. - 401
bad_signature, 411length_required, 413too_largefor an email over 25 MB or with more than 100,000 characters of text, 404not_foundwhen no recipient inTo,CcorDelivered-Tois a current reply address or its workspace was deleted, 403blockedfor a blocked visitor andsuspendedfor a suspended workspace, 402payment_requiredorread_onlyfor a workspace that waits for payment or is read-only, 429too_many_requestspast 20 emails to one address in an hour, and 503busywhen 4 emails are being received or the image queue is full. A forwarder retries on 429 and 503, and refuses the email on the other errors.
The email becomes the visitor's messages in the address's conversation, never in another, and reopens it when it is closed, as a widget message does. They alert the team and go to webhooks like any visitor message, with via: "email". Up to 5 attachments come first, one message each, with the same checks and limits as POST /v1/widget/{key}/uploads, and visitorFiles decides whether files other than images go in. An inline image under 16 KB, one inside the HTML such as a signature logo, is skipped, because it would come with every answer. A larger one, such as a pasted screenshot, counts as an attachment. The text comes last: the plain text part, or the HTML part made into text with its entities decoded. It is cut where the quote of the marker starts: the marker as a whole line, once quote marks go, and the block of lines just above it when that block names the quote, such as "On Monday, Acme wrote:" or Outlook's From: and Sent: lines, in English, French or Spanish. Any other block, such as "Order: 1042", is the visitor's text and stays. Without the marker it stays whole. Text longer than a message goes in as consecutive messages of up to 10,000 characters each, split at a paragraph or line break when one is near, and at most 10 of them. When an attachment is left out, a note in the visitor's language says so at the end of the text, as part of its body. Their clientId is email: and the SHA-256 of the email's Message-ID, or of the whole email when it has none, with :1 to :5 for the attachments and :text1, :text2 and on for the text, so the sender's retry adds nothing. A From other than the visitor's email is taken, and goes in fromAddress.
Through Shipmail
On a server with SHIPMAIL_API_KEY, SHIPMAIL_WEBHOOK_SECRET and SHIPMAIL_MAILBOX_ID set, Shipmail's webhook posts its JSON events to POST /v1/inbound-email/shipmail, up to 256 KB. X-Shipmail-Signature is the hex HMAC-SHA256 of v1=, the time in X-Shipmail-Timestamp, a line break and the body's bytes, under SHIPMAIL_WEBHOOK_SECRET, and the time must be within 5 minutes of the server's. The server checks both before it parses the event, and answers 401 bad_signature when either is wrong. It answers 200 { "ok": true } to any event but message.received for the mailbox SHIPMAIL_MAILBOX_ID, and does nothing else with it.
For that event, the server downloads the raw email with GET /mailboxes/{id}/inbox/messages/{email_id}/raw, up to 25 MB, and takes it as POST /v1/inbound-email does. It then moves the message to Trash, deletes it and answers 200 when it took the email, dropped it as an automatic answer, or refused it for good, such as for a blocked visitor (403 blocked), an unknown address (404) or an email over the limit (413). For an unpaid or suspended workspace, which the raw route answers with 402 or 403 suspended, it keeps the message and answers 200, so nothing is lost and Shipmail stops retrying. The email comes in by itself after the workspace opens again, within a minute or two once the worker's hourly sweep has seen it, and the worker deletes it from the mailbox after 90 days if it never does. It keeps the message when the intake answers 429 too_many_requests or 503 busy, and answers the same, so Shipmail retries. A download, a move or a delete that fails answers 500, and Shipmail retries the event. A retry adds nothing, as the clientId comes from the email's Message-ID, and a retry after the delete finds no message and answers 200. The worker also sweeps the mailbox with GET /mailboxes/{id}/inbox/messages when it starts and once an hour, so a reply whose webhook delivery failed comes in within about 70 minutes of its arrival.
The widget's look
GET /v1/operator/workspaces/{workspaceId}/widget answers the widget's settings to any member and to a Full access key. Owners, admins and Full access keys replace them with PUT on the same address, with every field:
| Field | Value |
|---|---|
title, greeting, away | The widget's own words, at most 40, 200 and 200 characters on one line, or null for Dinghy's |
primary, accent | A full hex color, such as #0b2239, or null for Dinghy's |
position | left or right |
theme | light, dark or auto, which follows the visitor's device |
launcher | bubble, label, square, boat or hidden |
radius | The corners in pixels, a whole number from 0 to 24 |
mascot | Whether the open chat shows the boat |
emailAsk | off, after_first or before_first: when a signed-out visitor is asked for an email |
branding | Whether the chat shows "Powered by Dinghy" |
transcript | Whether a visitor with an email gets the conversation by email 5 minutes after it closes, when someone on the team replied since the last transcript. A reopen within the 5 minutes cancels it, and a later close sends only the messages since the last transcript the visitor got |
sound | Whether the widget plays a soft chime for a reply that arrives while the chat is closed or its tab is hidden |
language | en, fr or es for the widget's own words, or visitor for the first of the browser's languages that it speaks. The tag's data-locale wins over it |
Both answer the settings with logoUrl and team: up to 3 members who sent the latest replies, each with an id that matches the authorId on their replies, a first name and a picture's address. PUT .../widget/logo sets the logo from the raw body, a PNG, JPEG or WebP of at most 2 MB, and DELETE .../widget/logo removes it. No API key can reach the logo routes.
GET /v1/widget/{key}/appearance answers the same, with no Origin check, because the widget shows all of it. Any site may read it. It caches for 5 minutes, so a saved change reaches sites within 5 minutes, and it answers 304 to a matching If-None-Match. A workspace whose widget is off, or an unknown key, answers 404. GET /v1/widget/{key}/presence answers only online, members, emailReplies and replySeconds. members lists the members online now, who are not away, by the same hash as authorId on their replies, so the widget can mark their faces. replySeconds is the 30-day median first reply time while headerStatus is reply_time and someone is online, and null otherwise. Only an open chat asks for presence, every 30 seconds, so a page view never computes it. The appearance's faces are the header's candidates: every member for headerFaces online, latest repliers first, which the widget cuts to those online, the latest repliers for repliers, and the chosen members for chosen.
Business hours
GET /v1/operator/workspaces/{workspaceId}/business-hours answers the team's business hours, to any member and to a Full access key, or null when nobody saved them, which means off. Owners, admins and Full access keys replace them with PUT on the same address and { "enabled", "timeZone", "week" }. timeZone is an IANA name, such as Europe/Paris. week has a key for each day, mon to sun, each with up to 3 ranges such as ["09:00", "18:00"], in order and apart. A range may end at 24:00, and a day with none is closed. The appearance answers hours with timeZone and week while they are on, and null while they are off. Outside them the widget shows the away message and when the team is back, in place of the presence or reply-time line, and asks for an email: before the first message, or after it for a visitor who has chatted. A time zone that the visitor's browser does not know turns the hours off there. It needs no other request.
A message in the widget API has fromBot, true for a reply sent with an API key, authorId, a hash that tells authors apart and names none, authorName, the operator's first name or the key's name, and authorPictureUrl. A deleted account's replies keep the name "Former team member" and have no picture. These fields are null for the visitor's own messages. On a reply that an outbound message became, they name who the visitor sees: the member, or the workspace's name and logo for sender: "team". outboundId is the outbound message it came from, so the widget drops its own copy, and button is the { value, label } a visitor's answer chose. Both are null on other messages.
An operator sets their picture with PUT /v1/operator/me/picture and the raw body, a PNG, JPEG or WebP of at most 2 MB, and removes it with DELETE. The server cuts it to a 128-pixel square. GET /v1/operator/me and the members list answer pictureUrl, and GET /v1/pictures/{operatorId} serves it to anyone.
Live updates
A client receives with server-sent events. GET /v1/widget/{key}/stream and GET /v1/operator/workspaces/{workspaceId}/stream send:
message(widget) orchange(operator) events, whoseidis the new cursor. Achangefor a new message hasfromVisitor, true when the visitor wrote it. An edited or deleted message comes again as a widgetmessage, and as amessage.updatedormessage.deletedoperatorchange,readyonce the stream has caught up,resyncwhen the client must load everything again, such as after a restore,close, with a reason, before the server ends the stream,- on the operator stream, a
campaign.updatedchangewhen a campaign is created, saved, paused, resumed or ended, - on the operator stream,
noticeevents with noid:{ "kind": "typing", conversationId, visitorId, draft }while a visitor types, with an emptydraftwhen they stop,{ "kind": "bot_typing", conversationId, name, typing }while an API key's bot writes, and{ "kind": "receipts", visitorId }when a visitor read replies or a reply email went out. A notice can be lost, so treat it as a hint to load again, - on the widget stream,
noticeevents with noid:{ "kind": "typing", name, typing }while an API key's bot writes a reply, and withtyping: falsewhen it stops, and{ "kind": "outbound" }when the visitor's outbound messages change.
Pass the last cursor when you reconnect, and the stream replays what you missed. A stream lasts at most 15 minutes, and it sends a heartbeat every 25 seconds. The widget reads it with fetch, because EventSource cannot send a bearer token. Architecture explains cursors.
API keys
An API key lets a script or an AI agent work in one workspace without a person's session. An owner or admin creates one in Settings > API & webhooks, and gives it a name, such as "Support bot", a level and a reply mode. The token, which starts with dk_, shows once. Store it like a password. Dinghy keeps only its hash. An MCP client can instead get a token in the browser, with OAuth. Such a connected app is a key too, and everything in this section applies to it.
Send it as a bearer token. It needs no Origin, because a browser never sends this header on its own:
curl https://chat.example.com/v1/operator/workspaces/WORKSPACE_ID/conversations \
-H "Authorization: Bearer dk_..."
A key works in its own workspace only, at the access level chosen when it was made. There are two, which the operator app calls Chats and Full access, and the API calls conversations and setup, in level, in OAuth scopes and in the OpenAPI enums. Chats, the default, has a member's permissions. It can:
- list, search and read conversations, with the visitor and the page journey (
?assignee=nonelists the unassigned ones; a key is assigned nothing, soassignee=meanswers 400), - reply with text or an image, as its reply mode says, write notes, hand a conversation to people and show that it types (see Bots),
- close, reopen, snooze, assign and label a conversation,
- send outbound messages and create or update contacts by user ID,
- read campaigns and their results, send a live campaign to one person, and track server events,
- read contacts, the visitors on the site now, the analytics, the saved replies and the labels, and stream events from
GET /v1/events.
Full access can do all of that, and set the workspace up: the campaigns and their settings, the webhooks (list, add, change, delete, replace a secret, send a test, read and replay the deliveries), the widget's look, and the install routes and test visitors. It lets an agent, such as a coding agent working on your site, connect Dinghy by itself. To let an agent set up Dinghy, create a Full access key.
A route that every key can call lists apiKey in its OpenAPI security, and a route that only a Full access key can call lists setupKey. A Chats key on such a route answers 403 forbidden. Every other route, such as members, keys, billing, export, deleting the workspace, sending or discarding a draft, giving a conversation back, pausing bots or /v1/operator/me, answers 403 forbidden to any key: no key can create, list or revoke keys, and no key reads the signing secret. Another workspace's routes answer 404. An unknown, expired or revoked key answers 401. Each key may send 300 requests a minute, across the API, MCP and the event stream, and over that it gets 429 with Retry-After.
POST .../api-keys takes name, level (conversations or setup), replyMode (send or draft, by default draft), rewritesDrafts (whether its bot answers Ask to change, by default false) and permissions, a list, empty by default. The permissions are send_as_member, which the operator app calls May send as a member: the key may send outbound messages with a member's name and picture, and send_email, called May email visitors: the key may send outbound messages with sendEmail: true, which the reply email to the contact's address carries. PATCH .../api-keys/{keyId} changes name, level, replyMode, rewritesDrafts or permissions, and DELETE revokes the key or disconnects the app. Only owners and admins call them, with a session. The key list answers each key's level, replyMode, rewritesDrafts, source (static for a key made in Settings, oauth for a connected app), client (null for a key, else a connected app's kind, host and local: cimd names the host that published the app, dcr the host or scheme it returns to, and local is true when that is the user's own computer), createdByName (who made the key or approved the app), permissions and lastUsedAt.
A reply sent with a key has authorApiKeyId set and authorOperatorId null, and authorName is the key's name. Visitors see the key's name on it, with a bot icon. Revoking a key in Settings stops it at once, and its old replies keep its name. Settings shows when each key was last used.
A token names its workspace: it is dk_, the workspace's ID, a dot, and a random part.
OAuth
Dinghy is its own OAuth 2.1 authorization server, as the MCP authorization spec of 2026-07-28 describes. An MCP client connects with no token, and the person approves it in the browser. Use Dinghy with AI agents shows the steps. OAuth is on when PUBLIC_URL is https, or a loopback address such as http://localhost:3000, because OAuth 2.1 forbids an http issuer anywhere else. When it is off, API keys still work. It needs no other setting.
The issuer is the origin of PUBLIC_URL, such as https://chat.example.com, and the one resource is https://chat.example.com/v1/mcp. A client must use that address: through another name, the resource does not match.
Discovery
POST /v1/mcpwith no token answers 401 withWWW-Authenticate: Bearer resource_metadata="https://chat.example.com/.well-known/oauth-protected-resource/v1/mcp", scope="conversations". With a token that is not valid, expired or revoked, it addserror="invalid_token", so the client refreshes.GET /.well-known/oauth-protected-resource/v1/mcp, and the same at/.well-known/oauth-protected-resource, answer the resource, the authorization server,scopes_supportedandbearer_methods_supported: ["header"].GET /.well-known/oauth-authorization-serveranswers the issuer and the endpoints:/oauth/authorize,/v1/oauth/token,/v1/oauth/registerand/v1/oauth/revoke. It supports thecoderesponse type, theauthorization_codeandrefresh_tokengrants, PKCE withS256only, and public clients only (token_endpoint_auth_methods_supported: ["none"]). It setsclient_id_metadata_document_supportedandauthorization_response_iss_parameter_supportedto true.
Clients
A client names itself in one of two ways:
- A Client ID Metadata Document, which the spec prefers: its
client_idis anhttpsURL with a path, such ashttps://claude.ai/oauth/claude-code-client-metadata. Dinghy fetches it only after the person signs in, from public addresses only, with no redirect, within 5 seconds and 5 KB, and keeps it for an hour. The document'sclient_idmust equal the URL, and itsredirect_urismust hold the one the request uses. - Dynamic Client Registration:
POST /v1/oauth/registerwith RFC 7591 metadata:redirect_uris(1 to 5) and an optionalclient_name. It ignores fields it does not use. It answers 201 with aclient_idthat holds the name and the addresses, signed by the server, so Dinghy stores nothing. A client always getstoken_endpoint_auth_method: "none"and no secret. A client address may register 10 times an hour.
A redirect URI is https on any host, http on localhost, 127.0.0.1 or [::1] (where only the port may differ from the registered one), or a private-use scheme with a dot, such as com.example.app:/callback. Dinghy refuses one with a fragment or user info, and javascript:, data: and file:.
Scopes and levels
The scopes are conversations (Chats) and setup (Full access), the two key levels. The consent page preselects the level from scope, and the person may change it. A Full access grant's tokens carry the scope conversations setup. Dinghy ignores scopes it does not know, such as offline_access, and always gives a refresh token. A Chats token does not see the Full access tools in MCP, and on a setupKey route it gets 403 with WWW-Authenticate: Bearer error="insufficient_scope", scope="setup".
Consent
GET /oauth/authorize is a page of the operator app, with the usual query: response_type=code, client_id, redirect_uri, code_challenge, code_challenge_method=S256, and optional state, scope and resource. A resource must be the MCP address or the origin, or the page answers invalid_target. A client_id or redirect_uri that is not valid shows an error page and never redirects. The page asks the person to sign in first, then shows the app's name, a workspace picker with the workspaces where they are an owner or admin, the access (Chats or Full access) and the reply mode.
Approve sends POST /v1/operator/workspaces/{workspaceId}/oauth/grants with the session, and Cancel sends POST /v1/operator/oauth/deny. Both answer { redirectTo }, with code or error=access_denied, and state and iss. Approving makes a connected app, a key with source: "oauth" named after the app, in Drafts only unless the person chose Send directly. When the same person approves the same app again, Dinghy replaces their earlier grant only if it no longer has a live token, so the same app on a second computer keeps the first one's grant. A workspace has at most 50 connected apps, and the 51st answers 409 grant_limit.
Tokens
POST /v1/oauth/token takes a form body (application/x-www-form-urlencoded), and its answers carry Cache-Control: no-store:
grant_type=authorization_codewithcode,code_verifier,client_id,redirect_uriand optionalresource. A code works once, for 60 seconds. A second use revokes the grant.grant_type=refresh_tokenwithrefresh_token, and optionalclient_idandresource. Each refresh gives a new refresh token. The old one works once more within 60 seconds, for two processes that refresh at once or a lost answer. After that, a second use revokes the grant.
It answers access_token, token_type: "Bearer", expires_in, refresh_token and scope. An access token, dko_..., lasts 1 hour, and a refresh token, dkr_..., 30 days. Both name their workspace, as dk_ keys do, and Dinghy keeps only their hashes. A client address may send 60 token requests a minute.
POST /v1/oauth/revoke (RFC 7009) takes token and optional client_id, and revokes the grant that the access or refresh token belongs to. It answers 200, also for a token it does not know.
Errors on these routes have OAuth's shape, { "error", "error_description" }, not Dinghy's: invalid_request, invalid_grant (a code or refresh token that is not valid, expired or used), unsupported_grant_type, invalid_target, invalid_client_metadata, invalid_redirect_uri, and temporarily_unavailable with 429 over a limit.
Where a token works
An access token works as a key of its grant's level: on /v1/mcp, on every operator route that such a key may call, and on GET /v1/events. A refresh token or a code never works as a bearer token. A grant ends when someone revokes it in Settings > API & webhooks, when the app revokes it, when a token is replayed as above, and when the person who approved it leaves the workspace, loses the owner or admin role, or deletes their account. The worker deletes expired tokens once a day, and grants whose code nobody redeemed within an hour.
Bots: reply modes, drafts, notes and handoff
These routes let an API key's bot answer chats while people stay in control. The MCP tools of the same names do the same.
Reply modes and drafts
Each key has a replyMode. With send, a reply goes to the visitor. With draft, POST .../conversations/{conversationId}/messages answers 202 with { draft } and nothing reaches the visitor: the draft waits under the conversation's last message for an operator. A key in draft mode cannot send an image, which answers 409 drafts_text_only. A key made before reply modes existed sends; a new key or connected app drafts unless an owner or admin chooses otherwise.
A draft has id, conversationId, apiKeyId, authorName, clientId, body, replyToMessageId, status, times, canAskToChange and changeRequest. status is open, stale (the visitor or an operator wrote after it), sent, discarded or replaced (its key wrote a new one for an Ask to change). With a session:
GET .../conversations/{conversationId}/draftslists the open and stale drafts, newest first.POST .../drafts/{draftId}/send, with an optional{ "body" }to edit it, sends it as the operator's own reply, withvia: "draft". It answers 201 with the message, and 200 with the same message when it was sent before, by any operator, so the visitor never gets it twice. Sending approves the bot's words, so the bot keeps the conversation. The other drafts that wait become stale.POST .../drafts/{draftId}/discarddiscards it.
Keys cannot send or discard drafts. The MCP list_drafts tool shows a key the drafts and what became of them.
Ask to change
An operator can ask the key that wrote an open draft to rewrite it. Dinghy writes nothing itself: the key's bot answers with a new draft. Agents explains it for bot builders.
- A key takes requests when its
rewritesDraftsis true. A draft'scanAskToChangeis true while it is open and its key takes requests, and itschangeRequestis the request that waits on it, or null. POST .../drafts/{draftId}/change-requests, with a session, takes{ "clientId", "instruction" }, an instruction of 1 to 500 characters. It answers 201 with{ changeRequest }, and 200 with the first request on a retry with the sameclientId. It answers 409draft_not_waitingwhen the draft was sent, discarded or replaced, or is stale,rewrites_offwhen its key does not take requests,conversation_closed, andchange_request_pending, with the waiting request aschangeRequest, when one waits already.POST .../drafts/{draftId}/change-requests/{changeRequestId}/cancelcancels a waiting request, and answers{ changeRequest }as it is now. The operator app's Ask again cancels the request and asks again, in two calls.- A request is
{ id, draftId, conversationId, apiKeyId, instruction, status, createdAt, resolvedAt, replacementDraftId }, withstatuspending,fulfilledorcancelled. Sending or discarding the draft, or a message that makes it stale, cancels it in the same transaction. - The request writes a
draft.change_requestedevent, withdata: { changeRequest, draft }. Webhooks that ask for it get every one.GET /v1/eventsandwait_for_eventsgive it only to the key that wrote the draft. - The key answers with
POST .../conversations/{conversationId}/messages, or the MCPreply, withchangeRequestId. It answers 202 with{ draft }, the new draft, whatever the key's reply mode and while a person handles the conversation, and the old draft becomesreplaced. WithoutreplyToMessageIdthe new draft keeps the old one's quote. Another key's request, or one in another conversation, answers 404, a request that ended answers 409change_request_closed, and paused bots 409bots_paused. A retry with the sameclientIdanswers the same new draft, and aclientIdthat made another draft answers 409client_id_reused. An operator's reply or a note withchangeRequestIdanswers 400invalid_request.
Human handling
A person handles a conversation from when an operator replies in text or with an image, or a bot hands it off. A conversation's handler says who handles it:
{ kind: "person", operatorId, name, since }: a person handles it, and it is assigned to this member.{ kind: "team", since }: a person handles it, and it is assigned to no one.{ kind: "bot", apiKeyId, name }: no person handles it, and this key took part last, with a message, a draft, a note or a handoff.- null: no person handles it, and no bot took part.
A conversation's bot is { apiKeyId, name } of the key that took part last, whoever handles it now, or null when no key did. It is the bot that a person can give the conversation back to.
While a person handles it, a key that sends directly gets 409 human_handling on a reply and on typing. A key in draft mode may still write drafts, as suggestions.
People pick who handles a conversation with two routes, with a session only:
POST .../conversations/{conversationId}/give-backgives it back to the bots. In one transaction it clears the assignee, with aconversation.assignedevent when there was one, and makes no person handle it, with aconversation.given_backevent.PUT .../conversations/{conversationId}/assigneewith{ "operatorId": "<member>" }, ornullfor the whole team, takes it over. In one transaction it sets the assignee, with aconversation.assignedevent, and makes a person handle it, as a reply does. With an API key the same route changes only the assignee, and the bot keeps answering.
Handoff
POST .../conversations/{conversationId}/handoff, with an API key only, takes clientId, reason (up to 500 characters), and optional summary (up to 2,000), operatorId and visitorMessage. In one transaction, it sends visitorMessage as the key's reply (or a draft in draft mode), assigns the conversation to operatorId, makes a person handle it, adds a note with the reason and the summary, and adds a conversation.handoff event. The note's handoff is { operatorId }: the member it went to, or null for the whole team. Every other message has handoff: null. That event alerts the assignee, or every member with alerts on when there is none, as a new visitor message does. It answers 201 with visitorMessage: { status: "sent", message }, { status: "drafted", draft }, { status: "not_sent", reason: "bots_paused" } or null. A retry with the same clientId answers 200 with the first result and changes nothing, even when bots were resumed since.
Notes from bots
A key writes a note as an operator does, with "note": true or the MCP add_note tool. A note is never refused with human_handling or bots_paused, so a bot can pass on what it found while a person handles the conversation. An operator's note does not make a person handle the conversation, and it does not make drafts stale: only a reply that reaches the visitor does. The operator app shows each link in a key's note as plain text with its address, so a link that a visitor gave a bot cannot pass as the team's.
Pause all bots
PUT .../bots-paused with { "paused": true }, from an owner or admin with a session, pauses every bot of the workspace. While paused, every key's reply, draft and typing answer 409 bots_paused. Reads, notes and handoffs still work. The workspace lists answer botsPaused, botsPausedBy, the name of who paused them, and botsPausedAt, when. The route answers { paused, pausedBy }.
Typing
POST .../conversations/{conversationId}/typing with { "typing": true }, from an API key only, shows the visitor "false to stop. It stores nothing. A key in draft mode shows it to operators only. It is refused like a reply, with bots_paused or human_handling.
Events for API keys
GET /v1/events streams the workspace's events to an API key, as server-sent events, for a bot with no public address. Each event's name is its webhook type, its id is its position, and its data is { type, workspaceId, data }, with the same data as a webhook body. ?types=message.created,conversation.handoff keeps only those types.
curl -N "https://chat.example.com/v1/events?types=message.created" \
-H "Authorization: Bearer dk_..."
With no position, it starts from now. Reconnect with Last-Event-ID, or ?after= and the last id, and it sends what you missed. One change can make two events: a conversation's first message sends conversation.created, then message.created. The first has the position generation.seq.0, and the last has the change's cursor, generation.seq, so a stream that drops between them sends the second when it resumes. ready comes when it has caught up, and resync when the cursor is too old: read the open conversations again. It sends a heartbeat every 25 seconds, ends after 15 minutes with a close event, and takes a slot in the workspace's stream limit, so too many streams answer 429 too_many_streams. A revoked key's stream ends within 25 seconds. A notice has no id and may be lost: { "kind": "typing", conversationId, draft } carries a visitor's unsent words, only while the workspace's typing preview is on. Messages from test visitors come with conversation.visitor.isTest: true. A key gets draft.change_requested only for its own drafts.
Outbound messages and contacts
An outbound message is a message from the team to one visitor, which may exist before any conversation. Outbound messages explains when one shows, when it becomes a conversation and every status, with recipes. These routes are under /v1/operator/workspaces/{workspaceId}, for any API key and for members with a session.
| Route | What it does |
|---|---|
POST /outbound-messages | Sends one to one visitor. It answers 201 with { outboundMessage }, and 200 with the first one for a retry with the same clientId or a dedupeKey the visitor already has |
GET /outbound-messages | Lists them, newest first, by visitorId, userId, dedupeKey, status, apiKeyId and campaignId, with limit (1 to 100, 50 by default). It answers { outboundMessages, next }, and next goes in cursor |
GET /outbound-messages/{id} | Reads one |
POST /outbound-messages/{id}/cancel | Cancels one that the visitor has not read, and answers it as it is now |
POST /outbound-messages/cancel | { "visitor": { "userId" } or { "id" }, "dedupeKey" } cancels the one that the visitor's dedupeKey names. outboundMessage is null when there is none |
GET /contact-fields | The attributes and events of the 1,000 contacts seen last, A to Z, as { attributes, events }. Each is { name, contacts }, with lastSeenAt for an attribute and lastAt for an event. Every member and key reads it |
PUT /contacts/by-user/{userId} | Creates or updates a contact by your user ID, with name, email and attributes. It answers 201 with a new contact, 200 otherwise, as GET /contacts/{visitorId} does |
A send's body has clientId, visitor ({ userId, name?, email?, attributes? }, which creates or updates the contact, or { id }), body, and the optional buttons, sender, assignOnReply, startConversation (on_reply by default), show (badge by default), ifConversationOpen (hold by default), dedupeKey, metadata, sendAt or delay, unless, expiresAt or expiresIn, and sendEmail (false by default). A clientId is unique per author and never expires: a retry with it answers the first result. metadata is up to 20 keys of your own with text values, which come back on the message, its webhooks and the event stream, and never reach the visitor. Send one describes each field and the answer.
status is scheduled, sent, delivered, read, replied, dismissed, cancelled or expired. statusReason says why a message waits or was cancelled, and is null otherwise: open_conversation, open_conversation_skipped, human_handling, bots_paused, blocked, permission_revoked, workspace_inactive, unless_matched, cancelled_by_request and conversation_deleted, and for a campaign's message also audience_unmatched, frequency_capped, goal_reached, outside_business_hours, outside_send_window, campaign_paused, campaign_ended and control_group. Status reasons says what each campaign value means.
A send answers 403 send_mode_required for a key in draft mode, 403 send_as_member_required for a member sender from a key without the send_as_member permission, 403 send_email_required for sendEmail: true from a key without the send_email permission, 403 blocked, 404 not_found for an unknown visitor id, 409 bots_paused for a key's send with no later send time while bots are paused, and 429 too_many_waiting when the visitor already has 5 that wait in no conversation. Each key may send 60 a minute, on top of its 300 requests a minute, and over that it gets 429 too_many_requests with Retry-After.
The contact upsert sets name and email, and merges attributes key by key, up to 2 KB of JSON: a null value removes a key, and a key you leave out stays. Each write carries its time, and the later write wins for each field and each attribute, whether it came from this route or from a host token, whose time is its iat. A change cancels the contact's scheduled outbound messages whose unless now matches, and checks the contact against the live campaigns that read a changed field.
The widget's part
The widget reads and answers outbound messages with these routes, with the visitor's token:
| Route | What it does |
|---|---|
GET /v1/widget/{key}/outbound-messages | The messages that wait to show to this visitor, oldest first: { outboundMessages: [{ id, body, buttons, show, read, fromBot, authorName, authorPictureUrl, authorId, createdAt }] }. Each is checked again: one that may join the open conversation goes in it and comes on the stream instead, and a fetch makes sent ones delivered |
POST /v1/widget/{key}/outbound-messages/{id}/read | The visitor saw it in the open chat. A repeat changes nothing. 404 when it is not theirs or it ended |
POST /v1/widget/{key}/outbound-messages/{id}/dismiss | { "button": 0 }: the visitor chose the dismiss button at that place, from 0. It records the read, and the message ends as dismissed |
POST /v1/widget/{key}/outbound-messages/{id}/click | { "button": 0 }: the visitor chose the button at that place that opens a page. It records the read and the button, and sends outbound_message.clicked |
POST /v1/widget/{key}/campaigns/{id}/show | A page campaign's message showed on the page. It counts in the campaign's results and stores nothing about the visitor |
POST /v1/widget/{key}/campaigns/{id}/read | The visitor read a page campaign's message |
POST /v1/widget/{key}/campaigns/{id}/press | { "button": 0 }: the visitor chose a page campaign's button at that place |
The widget's send takes outboundIds, button and pageCampaign for the answer, and the beat answers waiting and pages. The widget stream sends a notice, { "kind": "outbound" }, when the visitor's outbound messages change, and the widget fetches them. A notice can be lost, so the widget fetches on its beat too.
Campaigns
A campaign is a saved rule that sends outbound messages: who gets one, when, what it says and how often. Its definition is one JSON object. Campaigns describes every field, the triggers, the rules and the results, with recipes. These routes are under /v1/operator/workspaces/{workspaceId}. A route on one campaign takes its ID, /campaigns/{id}, or its key, /campaigns/by-key/{key}. Every member and every API key reads them. Owners, admins and Full access keys change them, and anyone else gets 403 forbidden.
| Route | What it does |
|---|---|
GET /campaigns | Lists them, oldest first, as { campaigns }. status keeps one status: draft, live, paused or ended |
POST /campaigns | Creates a draft from the whole definition, and answers 201 with { campaign }. A key that another campaign has answers 409 campaign_key_taken |
PUT /campaigns/by-key/{key} | Creates a draft with this key, 201, or replaces the definition of the campaign that has it, 200. It never changes the status |
GET /campaigns/{id} | Reads one, as { campaign } |
PATCH /campaigns/{id} | Replaces the parts the body gives, such as message or rules, each one whole, and checks the whole definition again |
POST /campaigns/{id}/resume | Starts a draft, or resumes a paused campaign |
POST /campaigns/{id}/pause | Pauses a live campaign: it makes no new messages, and those not sent yet wait |
POST /campaigns/{id}/end | Ends it for good. Its messages that wait are cancelled with campaign_ended |
DELETE /campaigns/{id} | Deletes a campaign that never sent a message, with its test messages. A live one answers 409 campaign_live, and one that sent 409 campaign_sent |
GET /campaigns/{id}/results | Its results per day in UTC and per variant, as { days, variants }, from from to to, such as 2026-12-01 |
POST /campaigns/{id}/send | { clientId, visitor, data? } runs a live campaign for one person |
POST /campaigns/{id}/test | With a session only: shows the message to a test visitor named after the member, and answers { outboundMessage, blockedBy } |
POST /campaigns/estimate | { audience?, trigger? }: how many contacts the editor's choices reach |
GET /campaign-settings | { paused, gapHours, pausedBy, pausedAt }, the rules for every campaign, and who paused them and when |
PUT /campaign-settings | Changes both. Owners, admins and Full access keys only |
POST /track | Tracks a server event about a contact. API keys only |
A campaign is { id, status, version, definition, totals, createdAt, updatedAt, liveAt, endedAt }. version goes up by one on each save. totals adds up its results since it started. liveAt is when it last went live, and endedAt when it ended.
A save checks the definition, and answers 400 invalid_request with one line for each problem, such as an unknown variable or a page campaign with show: "chat". A campaign's messages come from the member or key that saved it last, so a save answers 403 send_mode_required from a key in draft mode, send_as_member_required for a member sender from a key without the send_as_member permission, and send_email_required for sendEmail or emailIfUnread from a key without send_email. An ended campaign answers 409 campaign_ended to a save or an action. An action from a status it does not start from changes nothing, and answers the campaign as it is.
send skips the audience and the trigger, and keeps the frequency and the other rules. data fills {{ data.<key> }} in the text, with up to 20 keys. It answers 201 with { outboundMessage }, and 200 with the message that is there for a retry with the same clientId or when the frequency keeps the person out. It answers 409 campaign_not_live for a campaign that is not live, 403 blocked, 404 not_found for an unknown visitor id or campaign, and 429 too_many_waiting. Sends count in the key's 60 outbound messages a minute.
test sends the message to a new test visitor, in a conversation the member can open, whatever the rules say, with no variants. blockedBy names what would hold a real message now, campaign_ended, campaign_paused, outside_business_hours or outside_send_window, or is null.
estimate answers matching, the contacts who match audience now, and lastWeek, those a match or event trigger would have reached in the last 7 days, or null for another trigger. Each is { count, more }, and a count stops at 10,000 with more: true. Test visitors are left out.
PUT /campaign-settings answers as the GET does, and takes paused, which holds every campaign's messages with campaign_paused until it is false, apart from the bots' pause, and gapHours, from 0 to 720, 24 by default: the fewest hours between two campaign messages to one visitor, checked when a message is about to be sent. One that comes sooner is cancelled with frequency_capped. 0 turns it off.
POST /track takes { visitor, name, properties?, occurredAt?, id? }. visitor creates or updates the contact as a send's does. name is up to 64 letters, digits, _, ., : and -. properties, up to 4 KB of JSON, fill an event campaign's text and are never stored. id, up to 100 characters, counts a repeat once. It answers { visitorId, counted }, with counted false for a repeat. Each contact keeps one row per name with its count and its first and last time, which conditions read as events.<name>.count and events.<name>.lastAt. A member's session answers 403 forbidden, an unknown visitor id answers 404, and each key may track 600 events a minute, apart from its 300 requests.
Install and test visitors
These routes help a person or a Full access key put the widget on a site. They are under /v1/operator/workspaces/{workspaceId}, and owners, admins and Full access keys can call them.
| Route | What it does |
|---|---|
GET /install/snippet?framework= | The code that adds the widget, for html, nextjs, react, vue, rails, laravel or wordpress: code, the file it goes in, the placement in that file, notes, and the public key and server address it holds |
GET /install/check?origin= | Whether the widget is installed: allowed (whether origin is an allowed site, null without one), widgetSeenAt, sites (allowed sites and sites that loaded the widget, with firstSeenAt and lastSeenAt, written at most once an hour), refused (origins whose widget calls were refused in the last 24 hours, a hint only), liveTabs and nextStep |
GET /install/identity?language= | Server code that signs the token for Dinghy.identify(), for typescript, python, ruby, php or go. It reads the secret from DINGHY_SIGNING_SECRET, and never contains it: secretNote says where a person puts it |
GET /sites | The allowed sites, as { sites } |
POST /sites | { "origin" } allows one more origin. A workspace has at most 20: 409 site_limit past that, and 400 bad_origin for anything that is not an http or https origin without a path |
DELETE /sites?origin= | Stops the widget on an origin. Its open chats end at their next check |
POST /test-visitors/messages | { "body", "name", "conversationId" }, the last two optional, sends a message as a test visitor through the widget's own path, and answers { visitorId, conversationId, message }. Without conversationId, a new test visitor starts a conversation. A workspace may send 10 a minute |
DELETE /test-visitors | Deletes every test visitor, with their conversations, messages and images, and answers { deleted } |
A test visitor has isTest: true, and the inbox shows a Test label. Webhooks, /v1/events and wait_for_events see test visitors, so a bot can be tested from end to end. Analytics, contacts, live counts, push and email alerts and transcripts leave them out.
Webhooks
A webhook sends a signed POST to your server when something changes in a workspace. An owner or admin adds one in Settings > API & webhooks, with its address and the events it wants, or a Full access key adds one with the same routes. Each webhook answers createdBy: { "kind": "operator" | "key", "name" }, or null for one from an older release, and Settings shows it. A workspace has at most 5. The signing secret shows once, and Replace secret makes a new one. Send test sends a webhook.test event at once and shows the answer.
| Event | When |
|---|---|
conversation.created | A visitor starts a conversation, or an outbound message starts one. Its first message also sends message.created |
message.created | A visitor, an operator or an API key writes a message or a note |
message.updated | An operator edits a reply or a note |
message.deleted | An operator deletes a message. data.message has deleted: true and no body |
conversation.closed | A conversation is closed |
conversation.reopened | A conversation is reopened |
conversation.assigned | A conversation's assignee changes, or is cleared |
conversation.handoff | An API key's bot handed the conversation to people |
conversation.given_back | An operator gave the conversation back to the bots |
conversation.labeled | A label was put on a conversation or taken off. data also has label, { id, name, color }, and action, added or removed. If the label is deleted before the send, Dinghy sends nothing. |
draft.change_requested | An operator asked a key to rewrite its draft. data is { changeRequest, draft }, with no conversation. See Ask to change |
outbound_message.sent | An outbound message reached its send time and waits for the widget |
outbound_message.delivered | The widget fetched an outbound message |
outbound_message.read | The visitor read an outbound message |
outbound_message.clicked | The visitor opened a page with an outbound message's url button. Its button says which |
outbound_message.replied | The visitor answered an outbound message |
outbound_message.dismissed | The visitor chose an outbound message's dismiss button |
outbound_message.cancelled | An outbound message was cancelled, by a cancel or a check |
outbound_message.expired | An outbound message's expiresAt passed before the visitor read it |
campaign.updated | A campaign was created, saved, paused, resumed or ended |
Drafts send no webhook, except draft.change_requested. The body is JSON:
{
"id": "6a0f3f1e-3c1b-4f6e-9d5a-2b7c8e9f0a1b",
"type": "message.created",
"createdAt": "2026-11-10T09:31:00.000Z",
"workspaceId": "0b6f1c6e-2f4a-4c1e-9a57-3f1b8f0e6d21",
"data": {
"conversation": { "id": "...", "status": "open", "visitor": { "...": "..." }, "pageContext": null },
"message": { "id": "...", "body": "Do you ship to Canada?", "fromVisitor": true, "authorName": null }
}
}
data.conversation and data.message have the same shape as the operator API's Conversation and InboxMessage. Only the message.* events have data.message, and only conversation.labeled has data.label. The outbound_message.* events have only data.outboundMessage, the same shape as the OutboundMessage of the outbound routes, because the message may be in no conversation. campaign.updated has only data.campaign, the same shape as the Campaign of the campaign routes. They hold the state when the request is sent, which can be later than the change, such as after a retry. A test visitor's conversation has visitor.isTest: true.
Each request has these headers:
Dinghy-Event-Id: the same asid. It stays the same on every retry and replay, and for every webhook, so drop an ID you have seen.Dinghy-Signature:t=<unix seconds>,v1=<hex>, where the hex is the HMAC-SHA256 of<t>.<body>with the webhook's secret.
Check the signature on the raw body before you parse it, compare in constant time, and refuse a t older than 5 minutes. Keep the secret in your server's environment. The MCP tool get_webhook_verification gives the same code.
In TypeScript, with Node or Bun:
import { createHmac, timingSafeEqual } from "node:crypto";
const TOLERANCE_SECONDS = 300;
/** True when the request came from Dinghy. Pass the raw body, before any JSON parsing. */
export function isFromDinghy(rawBody: string, header: string | null, secret: string): boolean {
const match = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? "");
if (match === null) return false;
const [, timestamp = "", received = ""] = match;
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > TOLERANCE_SECONDS) return false;
const expected = createHmac("sha256", secret).update(timestamp + ".").update(rawBody).digest();
return timingSafeEqual(expected, Buffer.from(received, "hex"));
}
In Python:
import hashlib
import hmac
import re
import time
TOLERANCE_SECONDS = 300
def is_from_dinghy(raw_body: bytes, header: str, secret: str) -> bool:
"""True when the request came from Dinghy. Pass the raw body, before any JSON parsing."""
match = re.fullmatch(r"t=(\d+),v1=([0-9a-f]{64})", header or "")
if match is None:
return False
timestamp, received = match.group(1), match.group(2)
if abs(time.time() - int(timestamp)) > TOLERANCE_SECONDS:
return False
signed = timestamp.encode() + b"." + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, received)
In Go:
package dinghy
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"regexp"
"strconv"
"time"
)
const toleranceSeconds = 300
var signaturePattern = regexp.MustCompile("^t=(\\d+),v1=([0-9a-f]{64})$")
// IsFromDinghy reports whether a request came from Dinghy. Pass the raw body, before any parsing.
func IsFromDinghy(rawBody []byte, header, secret string) bool {
match := signaturePattern.FindStringSubmatch(header)
if match == nil {
return false
}
timestamp, err := strconv.ParseInt(match[1], 10, 64)
age := time.Now().Unix() - timestamp
if err != nil || age > toleranceSeconds || age < -toleranceSeconds {
return false
}
received, err := hex.DecodeString(match[2])
if err != nil {
return false
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(match[1] + "."))
mac.Write(rawBody)
return hmac.Equal(mac.Sum(nil), received)
}
Answer with any 2xx status within 10 seconds. Dinghy follows no redirect. Any other answer, or none, is tried again after 30 seconds, then after twice as long each time, up to an hour apart, for about a day. Delivery is at least once, so the same event can come twice, and events can come out of order.
Deliveries in Settings, and GET .../webhooks/{webhookId}/deliveries, show each webhook's last 20, with their status (pending, sent or failed), attempts, the last HTTP status and error, and responseExcerpt: the first 2 KB of the receiver's last refusing answer, as UTF-8 with control characters removed. Replay, or POST .../webhooks/{webhookId}/deliveries/{deliveryId}/replay, sends the delivery's event again now, as a new delivery with the same Dinghy-Event-Id, replayOf set to the first one and replayedAt set to now. Its body keeps the event's own createdAt, so a receiver sees when the change happened. It answers 201 with the new delivery, which is retried for a day from the replay, like any other delivery.
A webhook goes only to an https address on the public internet. Dinghy checks every address the name resolves to each time it sends, not only when you save it, and refuses this host, private networks and link-local addresses such as cloud metadata. A self-hosted install that sends to its own network can allow http and private addresses with WEBHOOK_ALLOW_PRIVATE.
MCP
Dinghy is an MCP server, so an AI agent can install Dinghy on a site, and read and answer your conversations. It lives at /v1/mcp, over Streamable HTTP. It takes an OAuth access token or an API key. The token's workspace is the one it works in, and its replies show the key's or the app's name.
To add it to Claude Code, with OAuth in the browser:
claude mcp add --transport http dinghy https://chat.example.com/v1/mcp
Or with an API key, for a server or CI:
claude mcp add --transport http dinghy https://chat.example.com/v1/mcp --header "Authorization: Bearer dk_..."
Another client that supports remote servers over HTTP takes the same address, and the same header for a key. Many read a JSON file such as this one:
{
"mcpServers": {
"dinghy": {
"type": "http",
"url": "https://chat.example.com/v1/mcp",
"headers": { "Authorization": "Bearer dk_..." }
}
}
}
Every key and connected app gets the Chats tools. A Full access one also gets the Full access tools. A Chats tools/list does not include the Full access tools, and calling one answers that there is no such tool.
| Tool | Level | What it does |
|---|---|---|
list_conversations | Chats | Lists open or closed conversations, newest activity first. label, a label's ID, keeps only the conversations with it, as the list route's label does. Pass nextCursor back as cursor for the next page |
search_conversations | Chats | Finds conversations by the visitor's name, email or user ID, or by message text |
get_conversation | Chats | Reads a conversation: its messages, notes among them with kind: "note", the handler, the visitor, pageContext, the pages and replySeconds. format: "markdown" answers a short transcript with the assignee's name and replySeconds |
reply | Chats | Replies in an open conversation, as the key's reply mode says: status: "sent" or status: "drafted". Quote an earlier message with replyToMessageId. Pass the same clientId on a retry. With changeRequestId it answers an Ask to change with a new draft |
add_note | Chats | Adds a note that only the team sees, in an open or closed conversation, even while a person handles it or bots are paused. mentions takes member IDs from list_members, and each gets an alert. Quote any earlier message with replyToMessageId. Pass the same clientId on a retry |
list_drafts | Chats | Lists the drafts of keys in draft mode: open, stale or all, each with the changeRequest that waits on it |
hand_off | Chats | Hands a conversation to people, with a reason, a summary and an optional last message to the visitor |
list_members | Chats | Lists the members: id, name, role and whether they are online. The id is what assign_conversation, hand_off and the mentions of add_note take |
list_saved_replies | Chats | Lists the team's saved replies: shortcut and body, to answer in the team's words |
set_typing | Chats | Shows the visitor that the bot is typing, for 6 seconds |
wait_for_events | Chats | Waits up to 30 seconds for events from a cursor: new visitor messages, and the draft.change_requested of the key's own drafts, each with its type. With no cursor it answers the cursor for now, and no earlier events |
close_conversation | Chats | Closes a conversation. Marked destructive |
reopen_conversation | Chats | Reopens a closed conversation |
snooze_conversation, unsnooze_conversation | Chats | Snoozes an open conversation until until, or with until null until the visitor writes, or ends its snooze |
assign_conversation | Chats | Assigns a conversation to a member by operator ID, or clears it with null |
list_labels | Chats | Lists the team's labels: id, name and color. A conversation's labelIds name them |
label_conversation, unlabel_conversation | Chats | Puts one label on a conversation, or takes it off. A repeat changes nothing |
get_contact | Chats | Reads a visitor, by visitorId or by conversationId, exactly one of them, with their local time, pages and other conversations |
list_contacts, search_contacts | Chats | Lists or finds the people who have a conversation. list_contacts with hasChatted: false adds those with none, and filter takes a condition |
upsert_contact | Chats | Creates or updates a contact by your userId: name, email and attributes, which merge key by key |
send_outbound_message | Chats | Sends an outbound message to one visitor, with the fields of the route. Pass the same clientId on a retry |
cancel_outbound_message | Chats | Cancels an outbound message that the visitor has not read, by outboundMessageId, or by visitor and dedupeKey. Marked destructive |
list_outbound_messages | Chats | Lists outbound messages with their status and statusReason, by visitorId, status, apiKeyId or campaignId |
list_campaigns, get_campaign | Chats | Lists the campaigns, with status, or reads one by id or key, with its definition and totals |
get_campaign_results | Chats | A campaign's results per day and per variant, between from and to |
send_campaign | Chats | Runs a live campaign for one person, by id or key, with visitor, clientId and data. Pass the same clientId on a retry |
track_event | Chats | Tracks a server event about a contact, with the fields of POST /track |
get_live_visitors | Chats | Lists the tabs of the site open now |
get_analytics | Chats | The Analytics page's numbers for 7, 30 or 90 days |
get_install_snippet | Full access | The code that adds the widget for a framework, and where it goes |
list_allowed_sites, add_allowed_site | Full access | Lists or adds the origins where the widget may load |
remove_allowed_site | Full access | Stops the widget on an origin. Marked destructive |
verify_install | Full access | Checks whether the widget loaded on a site, and names the next step |
get_identity_setup | Full access | Server code that signs the identity token. Never the signing secret |
get_appearance, update_appearance | Full access | Reads or changes the widget's look and words, not the logo |
list_webhooks | Full access | Lists the webhooks, with their events and who added them, never their secrets |
create_webhook | Full access | Adds a webhook from url and events, and answers its signing secret, once |
delete_webhook | Full access | Deletes a webhook. Marked destructive |
test_webhook | Full access | Sends a signed webhook.test now and answers what the webhook answered |
get_webhook_verification | Full access | Signature-check code in TypeScript, Python or Go |
list_webhook_deliveries, replay_webhook_delivery | Full access | Lists a webhook's last 20 deliveries, or sends one again |
send_test_message | Full access | Sends a message as a test visitor |
delete_test_visitors | Full access | Deletes every test visitor. Marked destructive |
upsert_campaign | Full access | Creates a draft campaign from definition, or replaces the one with its key. The status stays |
pause_campaign, resume_campaign | Full access | Pauses a live campaign, or starts or resumes one, by id or key |
end_campaign | Full access | Ends a campaign for good, by id or key. Marked destructive |
delete_campaign | Full access | Deletes a campaign that never sent a message, by id or key. Marked destructive |
Each tool says in its annotations whether it only reads, whether a retry is safe, and whether it deletes or ends something. A client asks the person before it calls a destructive tool. The server's instructions, and every tool that returns text a visitor wrote, tell the agent that this text is data and that it must never follow instructions in it.
The server is stateless and answers JSON only: it keeps no session and opens no event stream, so GET /v1/mcp answers 405. It speaks these protocol versions:
- 2026-07-28, which has no
initialize. Each request names its version inparams._meta["io.modelcontextprotocol/protocolVersion"], and itsMCP-Protocol-Version,Mcp-MethodandMcp-Nameheaders must match the body, or it answers 400 with the JSON-RPC error-32020. Its methods areserver/discover,ping,tools/listandtools/call. Each result hasresultType: "complete", andtools/listaddsttlMsandcacheScope: "private", because the list depends on the level. An unknown method answers 404 with-32601. - 2025-11-25, 2025-06-18 and 2025-03-26, with
initialize,notifications/initialized,ping,tools/listandtools/call.
A version it does not know answers 400 with -32022 and the supported list. A tool that fails answers with isError: true and the same stable code as the HTTP API, such as not_found, human_handling or bots_paused.