Capability catalogue
inboxinternal
inbox.upsert_message
Insert or update a message in a thread (dedup by external id)
Insert or update a message in a thread. The (thread_id, external_message_id) UNIQUE constraint makes duplicate inserts impossible at the DB layer — safe to call from any insertion path (sync poll, webhook delivery, agent-authored response from tickets.reply).
Effect
internal Fanout
no
Cache TTL
none
Traits
inbox_writer
Request arguments
Passed as the args parameter to ctx.capability.call("inbox.upsert_message", …).
| Field | Type | Required | Description |
|---|---|---|---|
| state | string | no | enum: ["draft","pending_review","sent","rejected","archived","sending","send_failed"] |
| sentAt | string | no | format: date-time |
| threadId | string | yes | format: uuid |
| contentMd | string | yes | |
| direction | string | yes | enum: ["inbound","outbound","internal_note"] |
| senderRef | string | no | |
| isInternal | boolean | no | default: false |
| senderType | string | yes | enum: ["external","agent","reviewer","system"] |
| contentHtml | string | no | |
| invocationId | string | no | format: uuid |
| externalMessageId | string | yes |
Response
Returned by ctx.capability.call("inbox.upsert_message", …).
| Field | Type | Required | Description |
|---|---|---|---|
| created | boolean | yes | true if a new row was inserted; false if an existing row matched (threadId, externalMessageId) and was updated |
| messageId | string | yes | format: uuid |
Example call
From inside your agent's handle(). The kernel resolves inbox.upsert_message to the tenant's connector binding at invocation time.
response = await ctx.capability.call(
"inbox.upsert_message",
args={
"state": "draft",
"sentAt": "2026-01-01T00:00:00Z",
"threadId": "...",
"contentMd": "...",
"direction": "inbound",
"senderRef": "...",
"isInternal": false,
"senderType": "external",
"contentHtml": "...",
"invocationId": "...",
"externalMessageId": "...",
},
)See SDK quickstart for the full agent handler template; code examples covers invocation patterns including fanout and error handling.