DocumentationMailbox API

MAILCORE · CORPORATE MAILBOX API

Corporate Mailbox API

Connect a CRM to selected corporate mailboxes with explicit content consent, durable sending and recoverable mailbox events.

Mailbox API v1 · 30 October 2026OpenAPIPostman

Connection and access

Mailbox API v1 is available at https://mailcore.uz/api/mailbox/v1 over HTTPS. The organisation owner creates an integration in the account, selects exact mailboxes and explicitly grants the required capabilities and content access.

Configure the dedicated mcb_ credential on your CRM server and test reading, replies, Sent copies and sync before carrying customer traffic. If using webhooks, also verify signatures and recovery through the event feed. Replace example placeholders with your integration values; they are not working credentials.

What Mailcore and the CRM own

Mailcore provides mailbox transport, history, durable sending and observed changes. The CRM owns customers, orders, assignment, private notes and SLAs. A shared support address can serve many authenticated CRM operators without creating a mailbox for each operator.

Keep CRM case identity independent of mail threads and subjects. A duplicated Message-ID or a matching subject does not establish customer identity. Select personal employee mailboxes only with their own explicit authorisation.

Owner setup and content consent

The current organisation owner creates a service integration and explicitly grants content consent for exact active mailbox IDs. Domain administration, a technical role or an old management preset does not grant message-content access.

Store the mcb_ secret only in the CRM server’s secret store. Apply the intended expiry and client CIDRs. Create independent keys for different external systems and purposes; give an archive key read access and an automation key send access only when appropriate.

Shared mailboxes, employees and organisations

For shared Support or Sales, select the team mailbox: CRM operators authenticate in the CRM and reply as that shared address. The CRM owns teams, assignment, concurrent-operator handling and private notes. This API does not provide a ticket engine.

Select personal employee mailboxes explicitly when personal sender addresses are needed. A server key does not authenticate an operator: the CRM must enforce who can see or act on each mailbox. Use separate integrations and minimal capabilities for departments, read-only archives and send-only automations.

A CRM serving several organisations needs a separate integration in each organisation. Partition secrets, jobs, content and sync checkpoints by organisation and mailbox. Reply source and sender must belong to the same selected mailbox; a multi-mailbox grant does not enable arbitrary From addresses or cross-mailbox reply references.

Independent capabilities

messages.read allows message lists, bodies, raw MIME, attachments and threads. messages.write allows explicit flag changes and reversible moves. messages.send allows new sends; replying also needs messages.read to read the original message.

events.read allows the durable journal. webhooks.manage allows subscription management; creating a subscription also needs events.read. Sending does not imply historical content access. There is no permanent-delete endpoint in this release.

Authentication and discovery

Send Authorization: Bearer with the dedicated mcb_ credential to https://mailcore.uz/api/mailbox/v1. Management mcm_ and outbound Email API mck_ credentials, browser cookies and provisioning rights cannot substitute.

Start with GET /token/verify, then GET /mailboxes. Confirm the organisation, selected mailbox IDs and scopes. Use GET / for API discovery. Do not put credentials in URLs, browser bundles, prompts, logs or committed Postman environments.

Mailbox-bound opaque references

Discover permitted mailbox IDs with GET /mailboxes and record the chosen address with its ID. Folder, message, attachment, thread, cursor and operation references are opaque and bound to a mailbox. Preserve them exactly and URL-encode each path/query component.

Do not construct identifiers from IMAP UIDs, subjects or Message-ID. Message-ID may be absent or duplicated. An ID from another mailbox does not grant access. The CRM must still apply its own tenant and operator policy.

Initial import

Persist one sync state per mailbox. Before importing folders, call GET /mailboxes/{mailboxId}/events/checkpoint with events.read and save its watermarkSequence. The response also reports discardedThroughSequence. This explicit baseline plus the following snapshot reconciles current mail after expired history; replay events after the saved starting watermark to catch changes during import.

List GET /mailboxes/{mailboxId}/folders. For each selected folder, list /messages with folderId and follow nextCursor until null. Upsert by mailbox and message reference. Import metadata first; fetch content only when needed. After the import, pull changes after the saved watermark and commit effects with the checkpoint.

Snapshot paging and resets

A list cursor freezes an upper UID and binds mailbox, folder, UIDVALIDITY, filters, version and expiry. Keep the same folder and filters on subsequent pages. Never fabricate a cursor or replace it with the latest observed UID. New messages above the bound are found by later reconciliation.

A changed UIDVALIDITY, expired cursor, folder.reset or resync_required requires explicit reconciliation of affected mail state. Preserve CRM notes, cases and orders. Tombstones remove a mail representation, not CRM business records. Polling observes state and cannot reconstruct every transient IMAP edit.

Bodies, raw MIME and attachments

GET /mailboxes/{mailboxId}/messages/{messageId} returns an authorised message. Default PEEK reads do not mark it read. Use its /raw endpoint for bounded MIME and /attachments/{attachmentId} for a selected attachment. Binary responses are not JSON.

Sanitize untrusted HTML, block active content and remote tracking, and serve attachments through authorised downloads. Treat filenames as display metadata, never trusted paths. Bound parsing, download size, storage and timeouts. Show an explicit oversized/unavailable state instead of silently truncating content.

Threads, flags and moves

GET /mailboxes/{mailboxId}/threads/{threadId} provides conversation evidence with messages.read. References, In-Reply-To and Message-ID help threading; they are not global customer identities or proof that a message belongs to a CRM order.

POST /messages/{messageId}/flags uses add/remove arrays of seen, flagged, answered and draft. POST /messages/{messageId}/move uses folderId. These require messages.write and Idempotency-Key and return durable operations. Agree how CRM read/unread affects shared mailbox flags.

New messages and replies

POST /mailboxes/{mailboxId}/messages queues a new message. POST /mailboxes/{mailboxId}/messages/{messageId}/reply replies using the source message. The selected mailbox is the sender. Arbitrary From, Return-Path and injected headers are rejected; reply references and a new Message-ID are generated by the server.

Use to/cc/bcc address arrays, text and/or html, and attachments containing filename, contentType and contentBase64. On a reply, omitted to uses the original Reply-To/From; set explicit recipients for your CRM’s reply-all policy. Validate limits against the generated runtime schemas. Optional fromName changes only the display name, not the sender address or authenticated operator identity.

Persist idempotency before a mutation

Every mutation requires a bounded Idempotency-Key. Persist a random UUID with the mailbox, exact request body and intended CRM action before the request. After a lost HTTP response reuse the same key and equivalent body. A conflicting body returns 409.

A new key means a new operation. Do not generate another key as a generic send retry or recreate an unresolved send under a replacement credential. Permissions are rechecked before replaying a stored result. A replay may report the operation’s current state.

Operations and uncertain SMTP

202 records a durable operation, not delivery. Save operation.id and retrieve /mailboxes/{mailboxId}/operations/{operationId}, or pull operation.updated. State, smtpAccepted, sentState and errorCode separate transport and Sent-copy outcomes. SMTP acceptance does not prove downstream delivery or a read.

unknown means SMTP may have accepted the message before confirmation was lost. Stop blind automatic resends and investigate the original operation. If Sent append fails or is uncertain after acceptance, only the Sent append is retried/resolved; never send the email again to repair Sent.

Keep rfcMessageId (the RFC header) separate from opaque API references. For outgoing mail messageId is null until a verified Sent reference is available as sentMessageRef; for flags/moves it is the sourceMessageId. A verified move result can provide its destination reference.

Durable event feed

GET /mailboxes/{mailboxId}/events accepts afterSequence and a bounded limit. Its events have stable id and monotonic sequence; nextSequence is the page checkpoint and watermarkSequence is the observed bound. Apply the page and checkpoint in one CRM transaction. Sequences can have gaps; do not assume consecutive numbers.

Events describe observed state: message.created, message.updated, message.deleted, folder.reset and operation.updated. Deduplicate and reconcile safely after reconnect. Continue polling with webhooks enabled. Retention expiry returns resync_required; never silently skip the missing history or delete unrelated CRM business data.

Verify signed webhooks

POST /mailboxes/{mailboxId}/webhooks uses url and eventTypes. Store the returned signingSecret securely. The public destination must use HTTPS:443 without credentials, query or fragment; redirects are not followed. Disable with POST /webhooks/{webhookId}/disable using Idempotency-Key.

Read exactly one Webhook-Id, Webhook-Timestamp and Webhook-Signature. Compute HMAC-SHA256 using the literal UTF-8 secret over ASCII(id + '.' + timestamp + '.') followed by the exact raw body bytes. The header is v1, followed by lowercase hex. Compare digests in constant time before parsing JSON.

Reject malformed or duplicate signed headers and timestamps more than 300 seconds in the past or future. Check body.id equals the signed ID and data.mailboxId is configured. Do not re-serialize JSON for verification. Retries preserve event ID and use a current delivery timestamp/signature.

signingSecret is returned only with first creation, not an idempotent replay. If the first response is lost, find and disable the owned subscription and explicitly create a replacement; keep polling until the new secret is stored and verified.

Durable receipt, duplicates and recovery

Persist an inbox row unique to integration/event ID with the raw bytes before returning 2xx. Valid already-persisted duplicates may return 2xx; the same ID with conflicting bytes must be rejected. Use durable shared deduplication across restarts/instances. A signature does not prevent replay within the accepted timestamp window.

A separate worker applies CRM effects and its processed marker transactionally/idempotently. Webhooks contain references and sequences, not bodies or attachments. Delivery is at least once with bounded retries and can arrive out of order. Pull from the last committed event checkpoint after failures and periodically during normal operation; monitor inbox backlog and sync age.

Bounds and response handling

Read current list, body, MIME, attachment, send, queue and rate bounds from the generated schemas and deployed discovery response. Example-local buffer limits are not service limits. Handle explicit size/capacity failures without discarding messages or pretending a truncated response is complete.

Stop affected work on 401/403. For 429 and retryable temporary failures use bounded backoff with jitter and server retry guidance; preserve the original key for a retried mutation. Use structured error codes and request IDs rather than matching error text. Never log content, recipients, secrets or private links.

Read concurrentNativeRequestsPerProcess from discovery (currently 1) and serialize native reads and MIME-heavy requests in your connector. Busy admission returns 503 mailbox_busy, retryable: true and Retry-After: 1. Wait at least that interval, then use bounded backoff with jitter and a bounded CRM work queue. Retry mutations with the original Idempotency-Key and body; never create a new send to retry unknown SMTP. This is process capacity, not a per-mailbox or organisation entitlement.

Revocation and external operators

The issuer, organisation/domain/mailbox binding, active mailbox, consent, scopes, expiry, CIDR and revocation are checked throughout requests and before queued effects. Revoking an integration denies API access, closes its connector sessions and schedules native app-token cleanup. A password change alone does not revoke app tokens.

Revoking a key stops its queued work and subscriptions; plan rotation and polling continuity explicitly. A transmission already accepted or in flight cannot be assumed cancelled. externalOperator is an optional unverified external audit label, never authenticated Mailcore user identity or an authority grant. Authenticate CRM operators inside the CRM.

Contract and runnable examples

Download /docs/mailbox-api/openapi.json for the contract derived from actual route registration and models, and /docs/mailbox-api/postman.json for the collection. Importing either does not create an integration or grant access. Configure the base URL and dedicated secret, then test your CRM connection.

Python standard-library and Node fetch clients: /docs/mailbox-api/examples/client-python.py and /docs/mailbox-api/examples/client-node.mjs. Durable signed receivers: /docs/mailbox-api/examples/webhook-python.py and /docs/mailbox-api/examples/webhook-node.mjs. The examples are plain code, not an official SDK. Read their setup and transaction requirements before running.

Download

Import the contract into your development tools. Examples are plain code, not an official SDK.

OpenAPI 3.1Postman CollectionDocumentation for AI tools