Appearance
Inbox (human handoff)
12 operations. Paths are relative to https://api.frege.io.
Who a handoff can go to
GET/v1/projects/{id}/handoff-candidates
The members who may work the CRM in this environment — its managers and the organization's admin — by user id: the recipients of a transfer and the members an agent's handoff can be routed to. An observation; transfer rechecks it. next_after continues the list, null at the end; there is no total. 100 per page by default, at most 100.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
limit | query | integer | Page size, at most 100 |
after | query | string | The previous page's next_after |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 422 | Unprocessable Entity | error envelope |
A session's ordered events
GET/v1/projects/{id}/handoff-sessions/events
One page of what happened in a conversation, in order: control changes, the episodes' events and the agent's streamed output. after is the previous page's next_cursor; an empty page keeps the cursor it was asked with. subject, session_id and epoch are read off the card. 100 per page.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
subject (required) | query | string | The card's subject |
session_id (required) | query | string | The card's session_id |
epoch (required) | query | string | The card's epoch |
after | query | string | The previous page's next_cursor |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 422 | Unprocessable Entity | error envelope |
A session, live
GET/v1/projects/{id}/handoff-sessions/stream
Server-sent events of one conversation, pushed as they happen: each event's id is its seq and its event its kind, its data as in /handoff-sessions/events. Last-Event-ID resumes after an event; without it the stream starts at what happens next. An epoch that is no longer the session's answers 409: read the card again. A comment line keeps a quiet stream open every 15 seconds; the stream ends after 5 minutes, and a reconnect resumes it.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
subject (required) | query | string | The card's subject |
session_id (required) | query | string | The card's session_id |
epoch (required) | query | string | The card's epoch |
Last-Event-ID | header | string | The last event received |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | SSE stream | |
| 401 | Unauthorized | |
| 403 | Forbidden | |
| 404 | Not Found | |
| 409 | Conflict | |
| 422 | Unprocessable Entity |
The operator inbox
GET/v1/projects/{id}/handoffs
One page of this environment's handoffs — conversations the agent handed to a person — newest-created first. view picks the tab: waiting (the queue), mine (active, held by the caller), open (waiting and active) or closed (resolved and returned); door and agent_id narrow it. total counts every match before paging; next_after continues the page with the same filters, null at the end. 50 per page by default, at most 100.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
view (required) | query | string | The tab One of: waiting, mine, open, closed. |
door | query | string | Only this channel One of: embed, portal, telegram, voice. |
agent_id | query | string | Only this agent's conversations |
limit | query | integer | Page size, at most 100 |
after | query | string | The previous page's next_after |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 422 | Unprocessable Entity | error envelope |
A handoff with its conversation
GET/v1/projects/{id}/handoffs/{handoffID}
The episode, who holds its conversation now and one page of the conversation, oldest first: what the customer and the agent said before a person came in, then every message since. epoch, control_version and last_message_seq are what each command sends back. The transcript is bound to its revision: next_after continues it, and a page asked for after the conversation changed answers 409 handoff_conflict — read it again from the first page. 100 entries per page by default, at most 100.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
handoffID (required) | path | string | Handoff ID |
limit | query | integer | Entries per page, at most 100 |
after | query | string | The previous page's next_after |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 422 | Unprocessable Entity | error envelope |
Take a waiting handoff
POST/v1/projects/{id}/handoffs/{handoffID}/accept
The caller becomes the conversation's assignee. A handoff routed to some members is taken by one of them alone (403). The body is the control state read off the card; a conversation that moved since answers 409 handoff_conflict. Idempotency-Key makes a retry an exact replay: the same key answers the first outcome, and with another body 409 handoff_idempotency_conflict. A signed-in person only.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
handoffID (required) | path | string | Handoff ID |
Idempotency-Key (required) | header | string | The user action's key, at most 128 bytes |
Request body (application/json)
Schema: api.handoffObservation.
| Field | Type | Description |
|---|---|---|
control_version | string | |
epoch | string |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 422 | Unprocessable Entity | error envelope |
Upload a file for a reply
POST/v1/projects/{id}/handoffs/{handoffID}/attachments
Keeps one file — exactly one multipart field, file — in the object store for this handoff; it sends nothing to the customer: the returned id goes into a reply's attachments. Idempotency-Key, a UUID, makes a retry the same upload. At most 64 MB; the agent module's rules on what a file may be apply. A deployment without an object store answers 409 handoff_files_unavailable.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
handoffID (required) | path | string | Handoff ID |
Idempotency-Key (required) | header | string | The user action's key, a UUID |
Request body (application/x-www-form-urlencoded)
Type: file.
Request body (multipart/form-data)
Type: object.
Responses
| Status | Description | Body |
|---|---|---|
| 201 | Created | data |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 422 | Unprocessable Entity | error envelope |
Download a handoff's file
GET/v1/projects/{id}/handoffs/{handoffID}/attachments/{attachmentID}
An operator file of this handoff, as it was uploaded, with the staff bearer: these URLs are authenticated, never public links.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
handoffID (required) | path | string | Handoff ID |
attachmentID (required) | path | string | File ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The file | |
| 401 | Unauthorized | |
| 403 | Forbidden | |
| 404 | Not Found | |
| 409 | Conflict | |
| 422 | Unprocessable Entity |
Resolve a handoff, or return it to the agent
POST/v1/projects/{id}/handoffs/{handoffID}/close
return_to_agent false resolves the conversation; true hands it back to its agent, which answers the customer's next message (409 handoff_return_unavailable when it has none). last_message_seq is the last message the decision saw: one written since answers 409 handoff_conflict. A waiting handoff may be closed by any operator, an active one by its holder. Idempotency and the control state as for accept.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
handoffID (required) | path | string | Handoff ID |
Idempotency-Key (required) | header | string | The user action's key, at most 128 bytes |
Request body (application/json)
Schema: api.handoffCloseRequest.
| Field | Type | Description |
|---|---|---|
control_version | string | |
epoch | string | |
last_message_seq | string | |
return_to_agent | boolean |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 422 | Unprocessable Entity | error envelope |
Reply to the customer
POST/v1/projects/{id}/handoffs/{handoffID}/messages
Saves an operator's message; saved is not delivered, so it starts pending and delivery_state says how far it got. A reply to a waiting handoff takes it in the same step; a conversation another member holds, or a closed one, answers 409 handoff_conflict. body is nonblank, at most 8000 characters, also when files are attached; attachments are at most ten ids of files uploaded to this handoff and not sent yet. Idempotency and the control state as for accept.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
handoffID (required) | path | string | Handoff ID |
Idempotency-Key (required) | header | string | The user action's key, at most 128 bytes |
Request body (application/json)
Schema: api.handoffReplyRequest.
| Field | Type | Description |
|---|---|---|
attachments | string[] | |
body | string | |
control_version | string | |
epoch | string |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 422 | Unprocessable Entity | error envelope |
Hand an active handoff to another operator
POST/v1/projects/{id}/handoffs/{handoffID}/transfer
Only the member who holds the conversation transfers it, to someone from /handoff-candidates (rechecked: 422 otherwise). Idempotency and the control state as for accept.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
handoffID (required) | path | string | Handoff ID |
Idempotency-Key (required) | header | string | The user action's key, at most 128 bytes |
Request body (application/json)
Schema: api.handoffTransferRequest.
| Field | Type | Description |
|---|---|---|
control_version | string | |
epoch | string | |
user_id | string |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 422 | Unprocessable Entity | error envelope |
The inbox, live
GET/v1/projects/{id}/handoffs/stream
Server-sent events of this environment's handoffs, pushed as they change (Postgres notifies; nothing polls): handoff.counters carries the tabs' counts, as decimal strings, on connect and after every change, which handoff.updated announces first. A comment line keeps a quiet stream open every 15 seconds; the stream ends after 5 minutes, and a reconnect checks access again.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id (required) | path | string | Project ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | SSE stream | |
| 401 | Unauthorized | |
| 403 | Forbidden | |
| 404 | Not Found | |
| 422 | Unprocessable Entity |