OverviewProductsPlatformsAPI ReferenceResources

Email

Read and search Gmail, send, reply and forward, schedule and track sends, work with drafts, labels, send-as aliases and signatures, and catch bounces.


Every call takes the accountId of a Google account connected with scopes=email. Ids are Gmail's own message, thread and label ids, and every object carries provider and accountId.

Before you start

Sending from Gmail needs a payment method on your Zernio workspace. Without one, sends and replies answer 402 payment_required. Reading, labelling and trashing never need one.

List and search threads

GET /v1/email/threads returns threads newest first, from the inbox unless you pass folder:

Terminal
curl "https://zernio.com/api/v1/email/threads?accountId=ACCOUNT_ID&folder=inbox&unread=true&limit=20" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
JSON
{
  "data": [
    {
      "id": "18f2c0a9d3b1e7f4",
      "accountId": "ACCOUNT_ID",
      "provider": "google",
      "subject": "Contract for Q4",
      "snippet": "Hi Ana, attached is the signed version…",
      "unread": true,
      "latestMessageReceivedAt": "2026-10-26T09:12:00.000Z"
    }
  ],
  "pagination": { "hasMore": true, "nextCursor": "…" },
  "meta": { "filteredClientSide": [] }
}

GET /v1/email/messages takes the same filters and returns single messages. Both page with cursor and limit (up to 200, default 50).

ParameterWhat it does
folderinbox, sent, drafts, trash, spam, archive, or a label id from GET /v1/email/folders
unread, starred, hasAttachmenttrue or false
from, to, cc, bcc, anyEmailAn address. anyEmail matches any participant
subjectWords in the subject
after, beforeISO 8601 bounds on the message date
searchQueryNativeA Gmail search query passed as it is, such as has:attachment larger:5M (up to 500 characters)
sortOrderdesc (default) or asc

On Gmail, folders are labels and archive means mail that carries none of the inbox, trash or spam labels. Gmail lists newest first only, so sortOrder=asc reverses each fetched page.

A filter Gmail cannot apply itself is applied to the fetched page and named in meta.filteredClientSide. Such a page can hold fewer than limit items while pagination.hasMore stays true.

Read a thread or message

GET /v1/email/threads/{threadId}?accountId=… returns the thread with its messages. GET /v1/email/messages/{messageId}?accountId=… returns one message with text, html and attachments. Add includeHeaders=true for the headers, or raw=true for the full MIME source.

Add clean=true to either call for a clean object on each message, ready to hand to an LLM:

JSON
"clean": {
  "text": "Sounds good, Thursday at 3 works.\n\nAna Ruiz\nHead of Ops, Acme",
  "status": "stripped",
  "removed": { "quoted": true, "forwardHeader": false, "boilerplate": true },
  "signature": "Ana Ruiz\nHead of Ops, Acme",
  "forwarded": null
}

text drops quoted replies, tracking pixels and footers such as "Sent from my iPhone", in the common languages. The signature stays in text and also comes alone in signature.

A forward keeps the forwarded content, and its From, To, Date and Subject come parsed in forwarded.

text is never empty for a mail with a body: when nothing can be stripped safely you get the whole body with status: "fallback". The rules are deterministic; no model reads the mail.

Send an email

POST /v1/email/messages sends from the connected mailbox and returns the sent copy with 201:

Terminal
curl -X POST "https://zernio.com/api/v1/email/messages" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "ACCOUNT_ID",
    "to": [{ "email": "client@example.com", "name": "Client" }],
    "subject": "Your booking",
    "html": "<p>See you on Tuesday.</p>",
    "attachments": [{ "filename": "invoice.pdf", "contentType": "application/pdf", "url": "https://example.com/invoice.pdf" }],
    "metadata": { "bookingId": "bk_123" }
  }'
FieldWhat it does
to, cc, bccUp to 100 addresses each, as { email, name? }. to needs at least one
replyToUp to 5 addresses
fromNameThe display name. The address is always the mailbox
subjectUp to 998 characters
text, htmlAt least one
attachmentsUp to 20, each { filename, contentType, url } or { filename, contentType, base64 }. Add contentId to reference an inline image from html
replyToMessageIdThreads the email under that message
headersCustom headers. Only names starting with X- are accepted
metadataString pairs echoed on the returned message

Schedule a send

Add scheduledFor to a send or a reply, as ISO 8601 between 1 minute and 30 days ahead. Zernio answers 202 with the scheduled send and sends it within a minute of that time:

Terminal
curl -X POST "https://zernio.com/api/v1/email/messages" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "ACCOUNT_ID",
    "to": [{ "email": "client@example.com" }],
    "subject": "Following up",
    "html": "<p>Any questions about the proposal?</p>",
    "scheduledFor": "2026-11-12T09:00:00Z"
  }'
JSON
{ "data": { "id": "SCHEDULE_ID", "status": "scheduled", "scheduledFor": "2026-11-12T09:00:00.000Z", "to": [{ "email": "client@example.com" }], "subject": "Following up" } }
  • GET /v1/email/messages/scheduled?accountId=… lists scheduled sends in send order. Filter with status: scheduled, sending, sent, failed or cancelled.
  • GET /v1/email/messages/scheduled/{scheduleId}?accountId=… reads one. Once sent it carries sentMessageId and sentThreadId.
  • DELETE /v1/email/messages/scheduled/{scheduleId}?accountId=… cancels one that has not left yet. Later it answers 409.

The account and its areas are checked when you schedule. The daily cap and cooldowns apply when the email leaves.

If it cannot leave then, it moves to failed with an error and Zernio fires email.send_failed. Nothing is retried, so schedule it again once the cause is fixed.

Hold it as a draft in the mailbox

Add "holdAsDraft": true next to scheduledFor to save the email as a draft in Gmail right away. The user can read and edit it there, and Zernio sends the draft as it stands at scheduledFor.

The scheduled send then carries holdAsDraft: true and draftId, the Gmail draft id. Cancelling it deletes the draft.

If the draft is deleted or sent from the mailbox first, the send moves to failed and Zernio fires email.send_failed. holdAsDraft without scheduledFor answers 400.

Track opens, clicks and replies

Add any of these to a send or a reply:

FieldWhat it doesWebhook
trackOpensAdds a 1x1 image to the htmlemail.opened
trackLinksSends every http(s) link in the html through a Zernio redirect to the original URLemail.link_clicked
trackRepliesWatches the Gmail thread for mail from anyone other than the mailboxemail.thread_replied

The sent message carries a trackingId, and every tracking webhook carries it with the message's messageId, threadId and your metadata. trackOpens and trackLinks need html. trackReplies works with text too. Tracking is free.

Opens are a signal, not proof of reading:

  • Image proxies such as Gmail's and Apple Mail's fetch the pixel themselves, some as soon as the mail arrives.
  • Clients that block images never report an open.
  • Opening the message in the mailbox's own Sent folder counts.

Mail security gateways sometimes follow links on delivery, which reports a click. Auto-replies count as replies. A bounce does not: it fires email.bounced.

Reply to a message

POST /v1/email/messages/{messageId}/reply replies inside the Gmail thread, with the threading headers set for you. It goes to the original sender, or with mode: "replyAll" to every recipient too:

Terminal
curl -X POST "https://zernio.com/api/v1/email/messages/MESSAGE_ID/reply" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "ACCOUNT_ID", "mode": "replyAll", "text": "Thanks, confirmed." }'

to and subject are optional on a reply and default to the original's. Replies count against the same daily cap as sends.

Forward a message

POST /v1/email/messages/{messageId}/forward forwards the mail with its attachments. Your text or html goes above it, and the subject defaults to Fwd: plus the original's:

Terminal
curl -X POST "https://zernio.com/api/v1/email/messages/MESSAGE_ID/forward" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 3f1c9a2e-forward-1" \
  -d '{ "accountId": "ACCOUNT_ID", "to": [{ "email": "sales@acme.com" }], "text": "Can you take this one?", "excludeAttachmentIds": ["ATTACHMENT_ID"] }'

The forward stays in the original Gmail thread. Tracking, from and the send caps work as on a send, and the response carries forwardedFrom.

includeAttachments: false keeps only the original's inline images. excludeAttachmentIds leaves out the attachments you name, by the ids a read of the message returned. Everything together stays under 25 MB, else 413 attachment_too_large.

Work with drafts

Drafts suit an agent that writes and a person who approves. POST /v1/email/drafts saves a draft in the mailbox, where the user sees it in Gmail. Recipients and subject can wait.

inReplyTo makes a reply draft in that thread, and forwardOf a forward draft with the original's attachments:

Terminal
curl -X POST "https://zernio.com/api/v1/email/drafts" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "ACCOUNT_ID", "inReplyTo": "MESSAGE_ID", "html": "<p>Proposed answer</p>" }'

The draft comes back with its id, a kind (new, reply or forward, fixed for its life) and a version. Store the id; messageId changes on every save.

CallWhat it does
GET /v1/email/draftsLists the mailbox's drafts, the user's own included
GET /v1/email/drafts/{draftId}Reads a draft as it stands now
PATCH /v1/email/drafts/{draftId}Changes the fields you send and keeps the rest
DELETE /v1/email/drafts/{draftId}Deletes it
POST /v1/email/drafts/{draftId}/sendSends it, with any edits the user made in Gmail

Approve exactly one version

The version changes whenever anyone edits the draft, the user in Gmail included. Pass it as If-Match on PATCH or send.

If the draft changed since, you get 412 draft_conflict with the current draft in details.draft, so you can review what the person wrote:

Terminal
curl -X POST "https://zernio.com/api/v1/email/drafts/DRAFT_ID/send" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "If-Match: \"VERSION\"" \
  -d '{ "accountId": "ACCOUNT_ID" }'

The sent message carries draftId, and email.sent fires with source: "draft". A second send while one is in flight answers 409 draft_sending, and a draft the user deleted or sent answers 404 draft_not_found.

Add sendAt to send later instead: you get 202 with a scheduled send, and the draft stays editable until then. Cancelling it keeps the draft.

Tracking set at creation applies. If an edit removed the open pixel or tracked links, Zernio puts them back before sending.

Detect bounces

When a recipient's server refuses a mail, the bounce report lands in the mailbox and Zernio fires email.bounced, once per failed recipient. Delay warnings and out-of-office replies do not fire it.

Act on bounce.recommendedAction:

recommendedActionWhenWhat to do
removeuser_unknown, domain_not_foundStop sending to this address
retrymailbox_full, rate_limited, any soft bounceTry again later
fix_configurationauth_failure, blocklistedFix SPF, DKIM, DMARC or your sending reputation
reviewspam_blocked, policy_blocked, message_too_large, content_rejected, otherLook at the content or the recipient's policy

The event also carries type (hard, soft or undetermined), the status such as 5.1.1, a numeric smtpCode, the server's diagnostic, and detection.

Bounces arrive minutes to days after the send; bouncedAt and detectedAt show both times. When the send had tracking, email.messageId, trackingId and metadata are set. Otherwise match on threadId, internetMessageId or the quoted subject.

Send from an alias with a signature

GET /v1/email/send-as?accountId=… lists the addresses the mailbox can send from: its own address and every Gmail send-as alias, each with verificationStatus and the signature it would get.

Pass one as from on a send, reply or scheduled send. Add appendSignature: true to append that address's signature to html and text:

Terminal
curl -X POST "https://zernio.com/api/v1/email/messages" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "ACCOUNT_ID", "from": "support@acme.com", "appendSignature": true, "to": [{ "email": "ada@example.com" }], "subject": "Your order", "html": "<p>It shipped today.</p>" }'

A from outside the list, or an alias Gmail has not verified, answers 400. Without from, appendSignature uses the mailbox address's own signature.

Manage signatures in Zernio

appendSignature takes the Zernio signature set as the default for the sending address first, then the Gmail one. It answers 400 when there is neither.

Store a signature once and make it the default for an address:

Terminal
curl -X POST "https://zernio.com/api/v1/email/signatures" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Sales", "html": "<b>Ada Lovelace</b><br>Acme Sales", "defaultFor": ["sales@acme.com"] }'

Omit accountId to share it across every mailbox in the workspace. Pass signatureId on a send or reply to pick one explicitly.

POST /v1/email/signatures/import?accountId=… copies the Gmail signatures in, each the default for its address. The signature lands in a marked block above any quoted text.

To switch the signature on a draft, PATCH it with the new html or text and signatureId. The old signature block is replaced, never stacked; signatureId: null removes it.

Label a message

Create the label once. Nested names like Hermia/Handled show as a label group in Gmail. Creating a name that already exists returns it with 200, so the call is safe to repeat:

Terminal
curl -X POST "https://zernio.com/api/v1/email/labels" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "ACCOUNT_ID", "name": "Hermia/Handled" }'

Then add or remove it with addLabels and removeLabels, by label id or name. The message stays in the inbox:

Terminal
curl -X PATCH "https://zernio.com/api/v1/email/messages/MESSAGE_ID" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "ACCOUNT_ID", "addLabels": ["Hermia/Handled"], "removeLabels": ["Hermia/For you"] }'

PATCH /v1/email/threads/{threadId} labels every message in the thread. Each message lists its user label ids in labels. GET /v1/email/labels lists label ids and names, and DELETE /v1/email/labels/{labelId} deletes a label.

Archive or trash

The same PATCH endpoints take unread, starred and folder. Setting folder moves the mail and drops the user labels it had, so "folder": "archive" archives it. DELETE /v1/email/messages/{messageId}?accountId=… moves a message to the trash.

Download an attachment

Attachment ids come in each message's attachments. GET /v1/email/attachments/{attachmentId}?accountId=…&messageId=… streams the file with its Content-Type and filename.

How it behaves

  • Daily send cap. 200 sends a day on a consumer Gmail account and 500 on Google Workspace, counted per mailbox and reset at midnight UTC. Every send answers with X-Zernio-Send-Limit, X-Zernio-Send-Remaining and X-Zernio-Send-Reset. GET /v1/accounts/{accountId}/health reports the same as sendCap.
  • Bulk protection. The same body sent to more than 50 distinct recipients within an hour pauses the mailbox: 10 minutes the first time, doubling up to 24 hours, and Zernio fires account.rate_limited. The mailbox is for one-to-one mail, not newsletters.
  • Attachments. Up to 25 MB in total per email. Attachments given by url must download within 20 seconds.
  • Inbox. Mail received while the account is connected, and mail sent through the API, appears as inbox conversations, one per Gmail thread, and fires message.received or message.sent. Older mail is reachable through these endpoints, not the inbox.
  • Reads. Reads are live calls to Gmail, are not metered, and count against your API rate limit. When Gmail throttles the mailbox, Zernio retries once, then answers 429 rate_limited.

If it fails

ErrorCauseFix
402 payment_requiredNo payment method on the workspace (Gmail sends only)Add a card in billing, then send again.
429 email_send_cap_reachedThe mailbox reached today's cap. details.cap has limit, used and resetsAtWait for Retry-After or resetsAt.
429 rate_limitedThe mailbox is in a cooldown after a recipient burst, or Gmail throttled itWait for Retry-After, and send fewer identical emails.
404 resource_not_foundaddLabels or removeLabels names a label the mailbox does not haveCreate it with POST /v1/email/labels first.
400 invalid_field_valueA field is invalid: a non X- header, attachments over 25 MB, scheduledFor outside 1 minute to 30 days, tracking without htmlFix the field named in param.
400 from_not_allowedThe address is not a send-as alias of the mailbox, or Gmail has not verified itUse an address from GET /v1/email/send-as with verificationStatus: "accepted".
400 signature_unavailableThe sending address has neither a Zernio default nor a Gmail signatureCreate one with defaultFor, or pass signatureId.
412 account_scope_missingThe account has no email areaConnect again with email in scopes.
401 reconnect_requiredGoogle refused the account's accessReconnect the account.
Was this page helpful?

On this page