The datamodel as the schema schema-definition-xsd/klok-mail-v1.xsd (namespace dev.klok.klok.public) defines it: the
root level first, then every complex type in the order the root reaches it, then the simple types. A field whose type
the schema defines links to its section.
KlokMail_v1
The root element is KlokMail_v1.
KlokMail_v1 is the root container for the klok-mail-v1 datamodel. It wraps four distinct mail-related contexts:
incoming messages, outgoing requests, delivery results, and draft responses. An instance of this type holds one specific
part of a mail workflow, such as a received email or a send confirmation, depending on which child element is populated.
Since the schema does not define mutual exclusion, clients inspect the presence of specific child elements to determine
the payload's intent.
Simple fields
The root type KlokMail_v1 contains no simple fields. All data is held within complex child structures.
Complex fields
The following fields define the structure of KlokMail_v1. Each field corresponds to a specific stage or artifact in
the mail lifecycle.
| Field |
Type |
Cardinality |
Purpose |
| inbound |
KlokMailInboundV1 |
1 |
Holds a mail received by an account. It is published on the KlokMailInboundV1_account topic and keyed by providerMessageId. |
| outbound |
KlokMailOutboundV1 |
1 |
Holds a mail request that an account wants to send. It is published on the KlokMailOutboundV1_account topic and keyed by sendKey. |
| sendResult |
KlokMailSendResultV1 |
1 |
Holds the outcome of a send attempt. It is published on the KlokMailSendResultV1_account topic and keyed by sendKey. |
| draft |
KlokMailDraftV1 |
0..1 |
Holds a draft answer generated by Klok Svar for a specific thread. It is published on klok/mailbox/KlokMailDraftV1_svar and keyed by draftId. |
inbound
This field carries the KlokMailInboundV1 object. It is required (cardinality 1). The schema indicates this structure
represents mail received for an account. Clients use this field when processing incoming mail flows.
outbound
This field carries the KlokMailOutboundV1 object. It is required (cardinality 1). It represents a mail the account
intends to send. Clients use this field when submitting new mail requests to the platform.
sendResult
This field carries the KlokMailSendResultV1 object. It is required (cardinality 1). It reports the result of a
previous outbound request. Clients use this field to track delivery status and handle errors or confirmations.
draft
This field carries the KlokMailDraftV1 object. It is optional (cardinality 0..1). It represents a draft answer
generated by the Klok Svar system for the newest mail in a thread of an SVAR mailbox. It also records what a person
decided about the draft (sent, dropped, or modified).
KlokMailInboundV1
A mail received for an account, published on KlokMailInboundV1_account keyed by providerMessageId. Delivery is at least
once: a provider that resends a webhook produces the same providerMessageId again, and the client deduplicates on it.
Used in KlokMail_v1 (inbound).
| Field |
Type |
Cardinality |
Description |
account |
string |
1 |
– |
provider |
string |
1 |
The provider that received the mail, for example postmark. |
providerMessageId |
string |
1 |
The provider's id of the received mail; the deduplication key. |
messageId |
string |
0..1 |
The Message-ID header, with angle brackets. |
receivedAt |
dateTime |
1 |
– |
dateHeader |
string |
0..1 |
The Date header as the sender wrote it. |
originalRecipient |
string |
0..1 |
The address the provider delivered the mail to; the recipient that matters when the account has several addresses. |
mailboxHash |
string |
0..1 |
The part after + in the recipient's local part, when the provider extracts it. |
subject |
string |
0..1 |
– |
textBody |
string |
0..1 |
– |
htmlBody |
string |
0..1 |
– |
strippedTextReply |
string |
0..1 |
The new text of a reply without the quoted history, when the provider can tell them apart. |
inReplyTo |
string |
0..1 |
– |
references |
string |
0..n |
– |
htmlBodyOmitted |
boolean |
0..1 |
True when htmlBody was left out because the message would not fit on the broker; textBody is always kept. |
threadId |
string |
0..1 |
The thread of the mailbox the mail belongs to, thr_ followed by a ULID: the thread of the mail its inReplyTo or references name, else a new one. |
This type represents a single email message as it arrived at a provider. It is the core payload for inbound mail flows,
published on the KlokMailInboundV1_account topic and keyed by providerMessageId. Because delivery is at-least-once,
clients must handle duplicate messages by checking this key. The data sits inside the inbound element of the
KlokMail_v1 root structure.
Core identifiers and metadata
These fields establish the source, timing, and unique identity of the message.
| Field |
Type |
Cardinality |
Description |
| account |
string |
1 |
The identifier for the specific mail account associated with the message. |
| provider |
string |
1 |
The service that received the mail, such as postmark. |
| providerMessageId |
string |
1 |
The provider's internal ID for the email. This is the deduplication key. |
| messageId |
string |
0..1 |
The Message-ID header from the email, including angle brackets. |
| receivedAt |
dateTime |
1 |
The timestamp when the provider received the message. |
| dateHeader |
string |
0..1 |
The original Date header as written by the sender. |
Participants
The addressing fields describe who sent the mail and who received it. from is mandatory, while the recipient fields
are optional and can hold multiple entries.
| Field |
Type |
Cardinality |
Description |
| from |
KlokMailAddressV1 |
1 |
The sender of the email. Contains the address and optional display name. |
| to |
KlokMailAddressV1 |
0..n |
The primary recipients. |
| cc |
KlokMailAddressV1 |
0..n |
The carbon copy recipients. |
| bcc |
KlokMailAddressV1 |
0..n |
The blind carbon copy recipients. |
| replyTo |
KlokMailAddressV1 |
0..n |
The addresses specified for replies. |
| originalRecipient |
string |
0..1 |
The specific address the provider delivered to. Useful when an account handles multiple addresses. |
| mailboxHash |
string |
0..1 |
The text after the + sign in the recipient's local part. Present only if the provider extracts it. |
Content and threading
These fields carry the message body and the relationship to previous or subsequent messages. Note that htmlBody might
be omitted from the broker payload to save space, indicated by htmlBodyOmitted.
| Field |
Type |
Cardinality |
Description |
| subject |
string |
0..1 |
The subject line of the email. |
| textBody |
string |
0..1 |
The plain text version of the email body. |
| htmlBody |
string |
0..1 |
The HTML version of the email body. |
| htmlBodyOmitted |
boolean |
0..1 |
Set to true if htmlBody was removed because the message was too large for the broker. textBody is always retained. |
| strippedTextReply |
string |
0..1 |
The new text in a reply, with quoted history removed. Populated only if the provider can distinguish the new text. |
| inReplyTo |
string |
0..1 |
The Message-ID of the message being replied to. |
| references |
string |
0..n |
The Message-ID values of messages in the reference chain. |
| threadId |
string |
0..1 |
The mailbox thread identifier, formatted as thr_ followed by a ULID. Derived from inReplyTo or references, or generated as new. |
Headers and attachments
Raw header data and file attachments are preserved here. The headers include technical metadata required for client-side
validation.
| Field |
Type |
Cardinality |
Description |
| headers |
KlokMailHeaderV1 |
0..n |
A list of all email headers. Includes Authentication-Results, Received-SPF, and other auto-reply headers. |
| attachments |
KlokMailAttachmentV1 |
0..n |
A list of files attached to the message. |
Routing context
This complex field provides context about where the message was routed within the platform, specifically for solution
KLK006.
| Field |
Type |
Cardinality |
Description |
| mailbox |
KlokMailMailboxRefV1 |
0..1 |
The mailbox the mail was routed to. This is present on the klok/mailbox topic but absent on the account's topic in klok/mail. |
KlokMailOutboundV1
A mail the account wants sent, published on KlokMailOutboundV1_account keyed by sendKey. Every request gets exactly one
KlokMailSendResultV1 with the same sendKey.
Used in KlokMail_v1 (outbound).
| Field |
Type |
Cardinality |
Description |
sendKey |
string |
1 |
The client's unique key for this mail. It correlates the result, and a client that writes it down before publishing can tell a mail it already asked for from a new one. |
subject |
string |
1 |
– |
textBody |
string |
0..1 |
– |
htmlBody |
string |
0..1 |
– |
inReplyTo |
string |
0..1 |
Message-ID of the mail this one answers, with angle brackets; sent as the In-Reply-To header. |
references |
string |
0..n |
Message-IDs of the thread, oldest first; sent as the References header. |
messageStream |
string |
0..1 |
The provider's stream for this kind of mail; the account's default when empty. |
tag |
string |
0..1 |
One word that groups mail in the provider's statistics. |
threadId |
string |
0..1 |
The thread the mail answers or starts. |
origin |
string |
0..1 |
Who wrote the mail (KLK021): PERSON (a person sent it, also from a draft), KOLLEGA (a Klok Kollega sent it by itself), NOTICE (a notice of the mail service). Absent means PERSON. A string with documented values, so that a new origin is a compatible change. |
aiGenerated |
boolean |
0..1 |
True when an AI wrote the text and no person read it before it was sent; such a mail carries the AI label and Auto-Submitted: auto-replied. Absent means false. |
kollegaMode |
string |
0..1 |
For origin KOLLEGA: the mailbox mode that sent it, answer (an answer from the knowledge sources) or fill (a question for missing fields of a document category, or the confirmation of a filled one). A string with documented values. |
KlokMailOutboundV1 represents a single email request that a tenant account wants sent through the platform. It serves as
the core structure within KlokMail_v1.outbound for defining who receives the mail, what it says, and how it is
tracked. When you publish an instance of this type, the system correlates it with a KlokMailSendResultV1 using the
unique sendKey.
Identity and routing fields
These fields control how the mail is identified in the system and where it originates.
| Field |
Type |
Cardinality |
Description |
| sendKey |
string |
1 |
The client’s unique identifier for this specific mail request. It links the outbound request to its corresponding send result. If a client records this key before publishing, it can distinguish a re-requested mail from a completely new one. |
| from |
KlokMailAddressV1 |
1 |
The sender address. This value must match one of the sender addresses or domains explicitly configured for the account. See the KlokMailAddressV1 section below. |
| mailbox |
KlokMailMailboxRefV1 |
0..1 |
The specific mailbox the mail is sent from. This ensures the sent mail is stored on the correct thread in the Operative Data Layer (ODL). Notices do not have a mailbox. See the KlokMailMailboxRefV1 section below. |
| threadId |
string |
0..1 |
The ID of the conversation thread this mail answers or initiates. |
Recipient fields
The mail must have at least one primary recipient. Optional fields allow for copying, blind copying, and directing
replies.
| Field |
Type |
Cardinality |
Description |
| to |
KlokMailAddressV1 |
1..n |
The primary recipients. See the KlokMailAddressV1 section below. |
| cc |
KlokMailAddressV1 |
0..n |
Carbon copy recipients. See the KlokMailAddressV1 section below. |
| bcc |
KlokMailAddressV1 |
0..n |
Blind carbon copy recipients. See the KlokMailAddressV1 section below. |
| replyTo |
KlokMailAddressV1 |
0..n |
Addresses where replies should be directed. If absent, replies go to the from address. See the KlokMailAddressV1 section below. |
Content fields
You can provide the email body as plain text, HTML, or both. Most providers prefer HTML, but text remains critical for
accessibility and fallback.
| Field |
Type |
Cardinality |
Description |
| subject |
string |
1 |
The subject line of the email. |
| textBody |
string |
0..1 |
The plain text version of the email body. |
| htmlBody |
string |
0..1 |
The HTML version of the email body. |
| attachments |
KlokMailAttachmentV1 |
0..n |
Files attached to the email. See the KlokMailAttachmentV1 section below. |
Thread context and headers
These fields help mail clients group messages correctly and handle metadata beyond the standard fields.
| Field |
Type |
Cardinality |
Description |
| inReplyTo |
string |
0..1 |
The Message-ID of the email this message is replying to. This value must include angle brackets (e.g., <unique-id>) and is sent as the In-Reply-To header. |
| references |
string |
0..n |
A list of Message-ID values for the current conversation thread, ordered from oldest to newest. These are sent as the References header. |
| headers |
KlokMailHeaderV1 |
0..n |
Custom email headers (name-value pairs). These are useful for flags like Auto-Submitted. Note that headers managed automatically by the email provider are ignored. See the KlokMailHeaderV1 section below. |
Provider and origin metadata
These fields map to specific provider capabilities and track the operational origin of the message within the Klok
platform.
| Field |
Type |
Cardinality |
Description |
| messageStream |
string |
0..1 |
The provider-specific stream name for this type of mail (e.g., separating transactional mail from marketing). If empty, the account’s default stream is used. |
| tag |
string |
0..1 |
A single word used to group and filter mail in the provider’s statistical reports. |
| metadata |
KlokMailKeyValueV1 |
0..n |
Custom key-value pairs. These are sent to the provider if supported, and they are always echoed back in the KlokMailSendResultV1. See the KlokMailKeyValueV1 section below. |
| origin |
string |
0..1 |
Identifies who or what created the mail. This helps distinguish between human actions and automated system behaviors. If absent, it defaults to PERSON. |
| aiGenerated |
boolean |
0..1 |
Indicates if the text was written by an AI without human review before sending. If true, the mail carries an AI label and the Auto-Submitted: auto-replied header. Defaults to false if absent. |
| kollegaMode |
string |
0..1 |
Used only when origin is KOLLEGA. It specifies the mailbox mode used: answer (reply from knowledge sources) or fill (requesting missing fields or confirming a filled document). |
Origin values for KlokMailOutboundV1
The origin field determines the provenance of the mail. While the type is string to allow for compatible future
additions, the current documented values are:
| Value |
Meaning |
| PERSON |
A person sent the mail, or sent it from a draft. This is the default if origin is not set. |
| KOLLEGA |
A Klok Kollega automation sent the mail independently. |
| NOTICE |
The mail service itself sent the mail as a system notice. |
Kollega mode values
When origin is KOLLEGA, the kollegaMode field clarifies the intent. The documented values are:
| Value |
Meaning |
| answer |
The mail is an answer generated from knowledge sources. |
| fill |
The mail asks for missing fields in a document category, or confirms a field that was filled. |
Reference types
KlokMailOutboundV1 relies on several complex types to structure its data.
KlokMailAddressV1
Holds a single mailbox definition, consisting of the email address and an optional display name.
KlokMailHeaderV1
Represents a standard email header with a name and a value, exactly as they appear in the message transmission.
KlokMailAttachmentV1
Represents a single file attachment sent with the mail.
KlokMailKeyValueV1
A simple key-value pair used for client metadata. This data persists through the sending process and is available in the
result.
KlokMailMailboxRefV1
A reference to the mailbox the mail belongs to. This links the outbound message to the internal platform mailbox
structure (associated with solution KLK006) to ensure proper threading in the ODL.
KlokMailSendResultV1
The outcome of one KlokMailOutboundV1, published on KlokMailSendResultV1_account keyed by sendKey. Delivery is at least
once; the client deduplicates on sendKey.
Used in KlokMail_v1 (sendResult).
| Field |
Type |
Cardinality |
Description |
sendKey |
string |
1 |
– |
account |
string |
1 |
– |
status |
KlokMailSendStatusType |
1 |
– |
provider |
string |
1 |
– |
providerMessageId |
string |
0..1 |
– |
messageId |
string |
0..1 |
The Message-ID header the mail went out with, with angle brackets; replies carry it in In-Reply-To. |
submittedAt |
dateTime |
0..1 |
– |
errorCode |
string |
0..1 |
The provider's error code for REJECTED, the Klok error code for FAILED. |
errorMessage |
string |
0..1 |
– |
A KlokMailSendResultV1 represents the outcome of processing a single KlokMailOutboundV1 request. It is published on
the KlokMailSendResultV1_account topic and keyed by the sendKey, allowing clients to track delivery status. Because
delivery guarantees are at-least-once, consumers must deduplicate messages using this key.
Core identifiers and status
The following fields identify the specific send operation, the target account, and the ultimate result of the delivery
attempt.
| Field |
Type |
Cardinality |
Description |
| sendKey |
string |
1 |
The unique identifier for the outbound request. Used as the partition key on the result topic. |
| account |
string |
1 |
The mail account used to send the message. |
| provider |
string |
1 |
The mail provider handling the delivery. |
| status |
KlokMailSendStatusType |
1 |
The result of the delivery attempt. One of SENT, REJECTED, or FAILED. |
The status field determines the interpretation of the error fields and whether a retry is appropriate:
SENT: The provider accepted the mail for delivery.
REJECTED: The provider refused the request (e.g., invalid address, sender not allowed). Retrying without changes will
fail again.
FAILED: The service did not receive an answer from the provider after retries. The request may be sent again later.
Message identity and timing
These fields provide timestamps and identifiers for the sent message, useful for tracing and correlating with subsequent
replies.
| Field |
Type |
Cardinality |
Description |
| submittedAt |
dateTime |
0..1 |
The timestamp when the mail was submitted to the provider. |
| messageId |
string |
0..1 |
The Message-ID header of the sent mail, including angle brackets. Subsequent replies include this value in their In-Reply-To header. |
| providerMessageId |
string |
0..1 |
An identifier assigned by the provider to the message, if available. |
Error details
If the status is REJECTED or FAILED, these fields provide context about why the delivery did not succeed.
| Field |
Type |
Cardinality |
Description |
| errorCode |
string |
0..1 |
For REJECTED status, this is the provider's error code. For FAILED status, this is the internal Klok error code. |
| errorMessage |
string |
0..1 |
A human-readable description of the error. |
Optional and complex associations
These fields carry additional metadata or link to the originating mailbox context.
| Field |
Type |
Cardinality |
Description |
| metadata |
KlokMailKeyValueV1 |
0..n |
Key-value pairs sent with the original request. If the provider supports it, this metadata is attached to the mail; it is always echoed back in the send result. See KlokMailKeyValueV1 for structure. |
| mailbox |
KlokMailMailboxRefV1 |
0..1 |
A reference to the mailbox associated with the original request. This field is present only if the inbound request specified a mailbox. See KlokMailMailboxRefV1 for structure. |
Field relationships
- The
sendKey is the primary deduplication mechanism for clients consuming from the KlokMailSendResultV1_account
topic.
- The
status field dictates the presence and meaning of errorCode. Specifically, errorCode contains
provider-specific codes when status is REJECTED, but Klok-specific codes when status is FAILED.
- The
mailbox field acts as an echo of the input context, linking the result back to a specific mail flow (KLK006) if
one was defined.
KlokMailDraftV1
Klok Svar's draft answer to the newest mail of a thread of a SVAR mailbox, and what a person decided about it
(KLK006A13, published on klok/mailbox/KlokMailDraftV1_svar keyed by draftId). A draft is never sent by itself: only a
person's send call sends, and it sets status SENT or SENT_CHANGED with the sendKey of that mail. In a mailbox of mode
answer (KLK021) the draft is also the escalation: what the Klok Kollega did not send by itself is a draft with status
ESCALATED and the reason in escalationReason.
Used in KlokMail_v1 (draft).
| Field |
Type |
Cardinality |
Description |
draftId |
string |
1 |
drf_ followed by a ULID. |
threadId |
string |
1 |
– |
replyToProviderMessageId |
string |
0..1 |
The providerMessageId of the inbound mail the draft answers. |
subject |
string |
0..1 |
– |
textBody |
string |
0..1 |
– |
htmlBody |
string |
0..1 |
– |
answerable |
boolean |
0..1 |
False when the knowledge source did not answer the question; the app then says so beside the draft. |
knowledgeSources |
string |
0..n |
The Klok Kunskap source ids the draft was asked from. |
taskId |
string |
0..1 |
The Klok AI task that wrote the draft. |
model |
string |
0..1 |
– |
createdAt |
dateTime |
1 |
– |
status |
string |
1 |
READY (written, not decided), SENT (sent as written), SENT_CHANGED (sent after a person changed it), DROPPED (a person chose not to use it), FAILED (no draft; the reason in failureReason), ESCALATED (KLK021: the Klok Kollega did not send by itself and a person is asked to decide; the reason in escalationReason; a person then sends or drops it as a READY draft). A string with documented values, so that a new state is a compatible change. |
decidedBy |
string |
0..1 |
The person who sent or dropped the draft, klok:<sub>. |
decidedAt |
dateTime |
0..1 |
– |
sendKey |
string |
0..1 |
The sendKey of the mail a person sent from the draft. |
failureReason |
string |
0..1 |
For FAILED: SOURCE_TOO_LARGE, SOURCE_NOT_READY, SOURCE_NOT_FOUND, SOURCE_NOT_ALLOWED, TASK_FAILED, TASK_CANCELLED or ABANDONED. |
mode |
string |
0..1 |
The mailbox mode the draft was written in (KLK021): suggest (Klok Svar, a person always sends), answer or fill. Absent means suggest. A string with documented values. |
escalated |
boolean |
0..1 |
True when the Klok Kollega handed the thread to a person (status ESCALATED); stays true after a person sent or dropped the draft, so that the escalation is still seen afterwards. Absent means false. |
escalationReason |
string |
0..1 |
Why the Klok Kollega escalated: NOT_ANSWERABLE (the sources do not answer), LOW_CONFIDENCE (an answer below the minimum confidence), SOURCE_REFUSED (a source could not be asked), CAP_REACHED (the automatic mails per thread or per day are used up), SENDER_NOT_APPROVED (the sender is not approved or not verified), ASKED_FOR_PERSON (the sender asked for a person), TASK_STALE (the ask did not finish in time), FORM_GAVE_UP (fill: the missing fields were asked for too many times). A string with documented values, so that a new reason is a compatible change. |
A KlokMailDraftV1 represents a draft response generated by the Klok Svar system for the most recent email in a
specific thread within a SVAR mailbox. It captures both the content of the draft and the actions taken by a human
regarding that content, such as sending it, modifying it, or rejecting it. This object sits within the root
KlokMail_v1 model and acts as the central record for decision-making in mail handling workflows. In answer mode
mailboxes, it also serves as the escalation record for interactions the automated system could not or chose not to
resolve independently.
Identity and Context
These fields establish who created the draft, where it belongs, and which part of the conversation it addresses.
draftId (string, required)
- The unique identifier for this draft. The format is always
drf_ followed by a ULID.
mailbox (KlokMailMailboxRefV1, required)
- A reference object identifying the specific mailbox to which the related mail belongs. See the Reference Objects
section below for details on the
KlokMailMailboxRefV1 structure.
threadId (string, required)
- The identifier of the email thread this draft belongs to.
replyToProviderMessageId (string, optional)
- The
providerMessageId of the specific inbound email that this draft is answering.
Draft Content and Metadata
These fields hold the proposed answer and the technical context of how that answer was generated.
subject (string, optional)
- The subject line for the draft email.
textBody (string, optional)
- The plain text body of the draft.
htmlBody (string, optional)
- The HTML body of the draft.
answerable (boolean, optional)
- Indicates if the knowledge source successfully generated an answer. If
false, the application displays a notification
to the user alongside the draft that no answer was found.
knowledgeSources (string, optional, multiple)
- A list of IDs from the Klok Kunskap sources that were queried to generate this draft.
taskId (string, optional)
- The identifier of the Klok AI task that wrote this draft.
model (string, optional)
- The name or identifier of the model used to generate the content.
createdAt (dateTime, required)
- The timestamp when the draft was created.
Status and Lifecycle
The status field drives the state machine of the draft. A draft is never sent automatically; it requires a human
action.
status (string, required)
- The current state of the draft. The allowed values are:
READY: The draft is written and awaiting human decision.
SENT: The draft was sent exactly as written.
SENT_CHANGED: The draft was sent, but a person modified the content before sending.
DROPPED: A person chose not to use the draft.
FAILED: No draft could be generated. The reason is found in the failureReason field.
ESCALATED: (Specific to answer mode/KLK021) The automated system (Klok Kollega) did not send the response and
instead requested a human decision. The reason is found in the escalationReason field. Once escalated, a person can
then proceed to send or drop it, treating it like a READY draft.
When the status changes to a terminal state involving human action (SENT, SENT_CHANGED, DROPPED), the following
fields are populated:
decidedBy (string, optional)
- The identifier of the person who sent or dropped the draft. Format:
klok:<sub>.
decidedAt (dateTime, optional)
- The timestamp when the decision was made.
sendKey (string, optional)
- The
sendKey of the actual email message sent to the provider. This links the draft to the sent mail record.
Failure and Escalation Details
These fields provide the "why" behind states that are not simply READY or successfully processed drafts.
failureReason (string, optional)
- Populated when
status is FAILED. The allowed values are:
SOURCE_TOO_LARGE: The knowledge source was too large to process.
SOURCE_NOT_READY: The knowledge source was not available.
SOURCE_NOT_FOUND: The knowledge source could not be located.
SOURCE_NOT_ALLOWED: Access to the knowledge source was denied.
TASK_FAILED: The generation task failed.
TASK_CANCELLED: The generation task was cancelled.
ABANDONED: The task was abandoned.
escalationReason (string, optional)
- Populated when
status is ESCALATED (KLK021). The allowed values are:
NOT_ANSWERABLE: The sources could not answer the question.
LOW_CONFIDENCE: The generated answer fell below the minimum confidence threshold.
SOURCE_REFUSED: A source refused to answer.
CAP_REACHED: The limit for automatic mails per thread or per day was reached.
SENDER_NOT_APPROVED: The sender is not approved or verified.
ASKED_FOR_PERSON: The sender explicitly requested a human agent.
TASK_STALE: The ask task did not finish in time.
FORM_GAVE_UP: (Fill mode) The required missing fields were asked for too many times without resolution.
Operational Mode and State Flags
These fields define the context of the mailbox mode and persistent flags that survive state transitions.
mode (string, optional)
- The mailbox mode the draft was written in (KLK021). Absent means
suggest.
suggest: Klok Svar mode. A person always sends the mail.
answer: Klok Kollega mode. The system may send automatically or escalate.
fill: Form filling mode.
escalated (boolean, optional)
- True if the Klok Kollega handed the thread to a person (typically when
status was ESCALATED).
- Important: This flag remains
true even after a person sends or drops the draft. It serves as a historical marker that
this interaction required human intervention at some point, distinct from the current status. Absent means false.
Reference Objects
KlokMailMailboxRefV1
This complex type identifies the mailbox a routed mail belongs to (KLK006). It allows the draft to be strictly
associated with a specific SVAR mailbox instance.
KlokMailAddressV1
One mailbox: the address and the optional display name.
Used in KlokMailInboundV1 (from), KlokMailInboundV1 (to),
KlokMailInboundV1 (cc), KlokMailInboundV1 (bcc),
KlokMailInboundV1 (replyTo), KlokMailOutboundV1 (from),
KlokMailOutboundV1 (to), KlokMailOutboundV1 (cc),
KlokMailOutboundV1 (bcc), KlokMailOutboundV1 (replyTo).
| Field |
Type |
Cardinality |
Description |
address |
string |
1 |
– |
name |
string |
0..1 |
– |
A KlokMailAddressV1 represents a single mailbox, capturing both the email address itself and an optional
human-readable display name. This complex type acts as a building block within the mail data model, appearing repeatedly
in inbound and outbound message structures to define senders, recipients, and reply-to targets.
Fields
The type consists of two simple string fields, both of which lack specific format restrictions or enumerated values in
the schema.
| Field |
Type |
Cardinality |
Description |
| address |
string |
Required (1) |
The email address. No specific format pattern or validation constraints are defined in the schema beyond it being a string. |
| name |
string |
Optional (0..1) |
The display name associated with the address. May be absent if the sender or recipient does not provide a readable name. |
Structural context
The schema does not impose a conditional dependency between address and name; an instance may contain just an
address, or both an address and a display name. This type has no internal choices, discriminators, or references to
other data models. Its role is purely to pair a mandatory email string with an optional display string wherever a
mailbox is needed in KlokMailInboundV1 or KlokMailOutboundV1.
One mail header, name and value as they appear in the message.
Used in KlokMailInboundV1 (headers), KlokMailOutboundV1 (headers).
| Field |
Type |
Cardinality |
Description |
name |
string |
1 |
– |
value |
string |
1 |
– |
A KlokMailHeaderV1 represents a single header line from an email message, holding both its name and its value exactly as
they appear in the raw message. It is a simple complex type that appears in the headers collection of both inbound
messages (KlokMailInboundV1) and outbound messages (KlokMailOutboundV1).
Fields
| Field |
Type |
Cardinality |
Description |
| name |
string |
1 (required) |
The header's field name, for example Subject, To, From, Content-Type, X-Custom-Header. |
| value |
string |
1 (required) |
The header's field value, for example Meeting notes.pdf, user@example.com, application/pdf. |
Both fields are mandatory and hold a single string each. There is no enumeration, no optional variant, and no nesting
beyond these two plain strings.
How the fields belong together
The type is a flat name/value pair. The schema places no constraint on which names may appear, so any SMTP or MIME
header name can be used. Because a single header line can have several values (for example multiple Received or
Set-Cookie lines, or several addresses in a To header split across separate headers), a message's full set of
headers is represented by a collection of KlokMailHeaderV1 instances, not by one instance holding everything. Each entry
captures one line.
The type has no keys, no references to other types, and no mutual dependencies between name and value at the schema
level.
KlokMailAttachmentV1
One attachment. Inbound attachments are always stored in the claim check store and referenced by claimCheckUri. An
outbound attachment carries either claimCheckUri or, when small, the bytes in content.
Used in KlokMailInboundV1 (attachments), KlokMailOutboundV1
(attachments).
| Field |
Type |
Cardinality |
Description |
fileName |
string |
1 |
– |
contentType |
string |
0..1 |
– |
sizeBytes |
long |
0..1 |
– |
contentId |
string |
0..1 |
Content-ID of an inline part, referenced from the HTML body as cid:contentId. |
sha256 |
string |
0..1 |
– |
claimCheckUri |
string |
0..1 |
– |
content |
base64Binary |
0..1 |
– |
The type in one paragraph
A KlokMailAttachmentV1 represents a single file attached to a mail message. It acts as the container for metadata like
filename and size, while the actual binary payload is handled differently depending on the direction of the traffic. The
model distinguishes between inbound mail, where attachment data is always stored externally and referenced by URI, and
outbound mail, which can either reference an external store or carry the raw bytes directly if the file is small.
Field breakdown
Each field serves a specific purpose in identifying the attachment or locating its content.
fileName: This required field holds the human-readable name of the attachment. It is a standard string.
contentType: An optional string that specifies the MIME type of the attachment (for example, application/pdf or
image/png).
sizeBytes: A long integer indicating the total size of the attachment in bytes. This is optional.
contentId: An optional string used to identify inline parts of an email. When present, the HTML body of the mail
references this part using the cid:contentId scheme.
sha256: An optional string containing the SHA-256 hash of the attachment content, likely used for integrity
verification.
claimCheckUri: An optional string holding the URI that points to the attachment's data in the claim check store. As
noted in the type description, this is the mandatory method for inbound attachments.
content: An optional base64Binary field containing the actual raw bytes of the attachment. This is used for outbound
attachments that are small enough to fit within the message envelope, providing an alternative to the claimCheckUri.
KlokMailMailboxRefV1
The mailbox a routed mail belongs to (KLK006). Set by the router that chose the mailbox, never by the sender of the
mail.
Used in KlokMailInboundV1 (mailbox), KlokMailOutboundV1 (mailbox),
KlokMailSendResultV1 (mailbox), KlokMailDraftV1 (mailbox).
| Field |
Type |
Cardinality |
Description |
id |
string |
1 |
The mailbox id, mbx_ followed by a ULID. |
kind |
string |
1 |
PERSONAL (a person's secure mailbox), FUNCTION (a function mailbox with members), SVAR (a Klok Svar mailbox), KOLLEGA (a Klok Kollega mailbox). A string with documented values, so that a new kind is a compatible change; a reader treats an unknown value as a kind it does not handle. |
account |
string |
1 |
The Klok AI account that owns the mailbox, acc_ followed by a ULID. |
name |
string |
0..1 |
– |
A KlokMailMailboxRefV1 identifies the specific mailbox that a routed mail message belongs to. Within the
klok-mail-v1 datamodel, this reference appears in inbound messages, outbound messages, send results, and drafts,
serving as the authoritative pointer to the destination or origin mailbox determined by the system's routing logic
rather than by the message sender.
id
A required string containing the unique identifier of the mailbox. The format is strict: it must start with the prefix
mbx_ followed immediately by a ULID (Universally Unique Lexicographically Sortable Identifier).
kind
A required string that specifies the nature of the mailbox. While this is typed as a generic string to ensure forward
compatibility, the schema defines these specific values:
PERSONAL: A mailbox belonging to an individual person.
FUNCTION: A shared mailbox associated with a specific business function, having members.
SVAR: A mailbox related to a Klok Svar context.
KOLLEGA: A mailbox related to a Klok Kollega context.
Developers must handle this field as an open enumeration. If a consumer encounters a kind value not listed above, it
should treat the mailbox as a kind it does not support, rather than failing hard, allowing new kinds to be added without
breaking existing integrations.
account
A required string identifying the Klok AI account that owns the mailbox. Like the id, this uses a specific format: the
prefix acc_ followed by a ULID. This links the mailbox to its parent ownership structure.
name
An optional string. The schema provides no further constraints or formatting rules for this field. It likely holds a
human-readable label or display name for the mailbox, but developers should verify against source data or UI
requirements, as the schema does not mandate its content or format.
Relationships and Usage
The KlokMailMailboxRefV1 type acts as a structural reference. It does not contain the mail content itself but points
to the container (the mailbox) where the mail resides or is destined.
- Routing Responsibility: The schema documentation explicitly states that this reference is set by the router that
selected the mailbox. Integrators must not populate this field based on the sender's input; it is a system-assigned
property.
- Contextual Placement: This type is embedded within four main data structures:
KlokMailInboundV1,
KlokMailOutboundV1, KlokMailSendResultV1, and KlokMailDraftV1. In each case, the mailbox field holds a single
instance of this reference (cardinality 1 in those parent contexts, though the reference itself has optional fields).
- Identifier Correlation: The
id and account fields are the primary keys for correlation. The id uniquely
identifies the mailbox, while account provides the necessary scope (the owning AI account) to resolve that ID within
the broader Klok platform.
KlokMailKeyValueV1
Client metadata: sent with the mail where the provider supports it, and always echoed in the send result.
Used in KlokMailOutboundV1 (metadata), KlokMailSendResultV1
(metadata).
| Field |
Type |
Cardinality |
Description |
name |
string |
1 |
– |
value |
string |
1 |
– |
A KlokMailKeyValueV1 is a single metadata pair sent to the mail provider and returned in the send result. It sits inside
KlokMailOutboundV1.metadata when sending and inside KlokMailSendResultV1.metadata when reading the provider's response.
Fields
| Field |
Type |
Required |
Description |
| name |
string |
yes |
The key of the metadata pair. |
| value |
string |
yes |
The value of the metadata pair. |
Both fields carry no documentation of their own in the schema. Their meaning is fixed by how the surrounding element
uses them: KlokMailKeyValueV1 holds client metadata that the mail provider accepts and reflects back, so name names
the metadata item and value holds its content.
Tip: expect to find the same KlokMailKeyValueV1 entries in the send result as you put in the outbound request, since the
schema states the provider always echoes them back.
KlokMailSendStatusType
SENT: the provider accepted the mail for delivery. REJECTED: the provider refused this request (invalid address,
inactive recipient, sender not allowed); sending it again unchanged fails again. FAILED: the service could not get an
answer from the provider after its retries; the request may be sent again later.
Restricts string.
| Value |
Description |
SENT |
– |
REJECTED |
– |
FAILED |
– |