Skip to content

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

NameInTypeDescription
id (required)pathstringProject ID
limitqueryintegerPage size, at most 100
afterquerystringThe previous page's next_after

Responses

StatusDescriptionBody
200OKdata
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
subject (required)querystringThe card's subject
session_id (required)querystringThe card's session_id
epoch (required)querystringThe card's epoch
afterquerystringThe previous page's next_cursor

Responses

StatusDescriptionBody
200OKdata
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
subject (required)querystringThe card's subject
session_id (required)querystringThe card's session_id
epoch (required)querystringThe card's epoch
Last-Event-IDheaderstringThe last event received

Responses

StatusDescriptionBody
200SSE stream
401Unauthorized
403Forbidden
404Not Found
409Conflict
422Unprocessable 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

NameInTypeDescription
id (required)pathstringProject ID
view (required)querystringThe tab One of: waiting, mine, open, closed.
doorquerystringOnly this channel One of: embed, portal, telegram, voice.
agent_idquerystringOnly this agent's conversations
limitqueryintegerPage size, at most 100
afterquerystringThe previous page's next_after

Responses

StatusDescriptionBody
200OKdata
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
handoffID (required)pathstringHandoff ID
limitqueryintegerEntries per page, at most 100
afterquerystringThe previous page's next_after

Responses

StatusDescriptionBody
200OKdata
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
handoffID (required)pathstringHandoff ID
Idempotency-Key (required)headerstringThe user action's key, at most 128 bytes

Request body (application/json)

Schema: api.handoffObservation.

FieldTypeDescription
control_versionstring
epochstring

Responses

StatusDescriptionBody
200OKdata
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
handoffID (required)pathstringHandoff ID
Idempotency-Key (required)headerstringThe user action's key, a UUID

Request body (application/x-www-form-urlencoded)

Type: file.

Request body (multipart/form-data)

Type: object.

Responses

StatusDescriptionBody
201Createddata
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
handoffID (required)pathstringHandoff ID
attachmentID (required)pathstringFile ID

Responses

StatusDescriptionBody
200The file
401Unauthorized
403Forbidden
404Not Found
409Conflict
422Unprocessable 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

NameInTypeDescription
id (required)pathstringProject ID
handoffID (required)pathstringHandoff ID
Idempotency-Key (required)headerstringThe user action's key, at most 128 bytes

Request body (application/json)

Schema: api.handoffCloseRequest.

FieldTypeDescription
control_versionstring
epochstring
last_message_seqstring
return_to_agentboolean

Responses

StatusDescriptionBody
200OKdata
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
handoffID (required)pathstringHandoff ID
Idempotency-Key (required)headerstringThe user action's key, at most 128 bytes

Request body (application/json)

Schema: api.handoffReplyRequest.

FieldTypeDescription
attachmentsstring[]
bodystring
control_versionstring
epochstring

Responses

StatusDescriptionBody
200OKdata
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID
handoffID (required)pathstringHandoff ID
Idempotency-Key (required)headerstringThe user action's key, at most 128 bytes

Request body (application/json)

Schema: api.handoffTransferRequest.

FieldTypeDescription
control_versionstring
epochstring
user_idstring

Responses

StatusDescriptionBody
200OKdata
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
id (required)pathstringProject ID

Responses

StatusDescriptionBody
200SSE stream
401Unauthorized
403Forbidden
404Not Found
422Unprocessable Entity