Skip to content
Konstera
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", …).

FieldTypeRequiredDescription
statestringno
enum: ["draft","pending_review","sent","rejected","archived","sending","send_failed"]
sentAtstringno
format: date-time
threadIdstringyes
format: uuid
contentMdstringyes
directionstringyes
enum: ["inbound","outbound","internal_note"]
senderRefstringno
isInternalbooleanno
default: false
senderTypestringyes
enum: ["external","agent","reviewer","system"]
contentHtmlstringno
invocationIdstringno
format: uuid
externalMessageIdstringyes

Response

Returned by ctx.capability.call("inbox.upsert_message", …).

FieldTypeRequiredDescription
createdbooleanyestrue if a new row was inserted; false if an existing row matched (threadId, externalMessageId) and was updated
messageIdstringyes
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.