Send
POST /v1/email/messages sends one message to up to 50 recipients (to, cc and bcc), with the application’s live key and the email:send scope. A test key sends in test mode, to the simulator addresses only. A partner’s live key (tk_partner_) sends for one of the partner’s own applications that carries its id, named as application in the body (?application= on the reads).
html and text together are at most 512 KiB. There are no templates: render the message on your side. cc, bcc, headers and tags are honoured. Any other field is ignored, not refused. To send many different messages in one call, use a batch.
Recipients
to, cc and bcc each take one address as a string or an array of them, and each address is a bare address (sara@example.com) or one with a display name (Sara Ali <sara@example.com>, the name 1 to 120 printable characters). At least one of the three holds an address.
- At most 50 together, counted as given, before duplicates are removed.
- A duplicate is kept once. An address given twice, in any case, is sent to once, in the first of
to,cc,bccthat holds it, and charged once. - Every recipient is one e-mail: it counts against the daily limit and is charged on its own, whatever field it sits in.
- A suppressed recipient is skipped: an address on your account’s suppression list is kept on the message as
suppressed, never sent to and never charged, and the others are sent. - An invalid address refuses the message with
422 invalid_destination, naming where it sits:"field": "cc", "field_index": 2.
to string, with no cc, bcc, tags or scheduled_at, is answered in the original shape, exactly as before: to a string and no recipients. Any other message is answered in the extended shape, where to, cc, bcc, reply_to, recipients and tags are always arrays (empty when there are none) and cost counts the e-mails. headers, a one-address reply_to and the string form of from never change the shape.
Custom headers
headers adds your own headers to the message: at most 15, each name 1 to 126 header-name characters ([!-9;-~]), each value one line of at most 870 characters. A value beyond ASCII is encoded for you.
- Allowed:
List-Unsubscribe,List-Unsubscribe-Post,List-ID,In-Reply-To,References,Auto-Submitted,Precedence,X-Entity-Ref-IDand any otherX-header. - Set by Tawked or the sending service, refused with
422 header_not_allowedand theheaderit names:From,Sender,To,Cc,Bcc,Reply-To,Subject,Date,Message-ID,Return-Path,MIME-Version,Content-Type,Content-Transfer-Encoding,Content-Disposition,Content-ID,Content-Description,DKIM-Signature,DomainKey-Signature,Authentication-Results,Received,Received-SPF,Feedback-ID,Errors-To,Bounces-To, any name startingARC-,Resent-,X-Tawked-orTawked-, and the sending service’s ownX-headers. Names are compared in any case. Use the fields for what they set:reply_to, not aReply-Toheader. - One-click unsubscribe (RFC 8058):
List-Unsubscribeis one or more<https:…>or<mailto:…>URIs in ASCII;List-Unsubscribe-Postmust be exactlyList-Unsubscribe=One-Clickand needs aList-Unsubscribeholding anhttps:one.
header_names when you read it); the values are kept only until the message is sent, since an unsubscribe link may hold a token.
Tags
tags labels the message for your own reports and lookups: up to 20 { "name", "value" } objects, each name and value 1 to 256 ASCII letters, digits, _ or -.
message_id, application_id, account_id and any name starting tawked. Tags come back when you read the message and on its webhooks, and filter the list (tag=category:order).
Attachments
A CV, an invoice, a ticket:attachments carries up to 10 files with the message, at no extra price.
The files together are at most 10 MiB once decoded, beside the 512 KiB of
html and text. Executables, scripts and shortcuts (.exe, .bat, .js, .vbs, .ps1, .lnk, .msi and the rest of the list mail services refuse) are refused with 422 attachment_type_blocked, and so are disk images (.iso, .img, .vhd), OneNote, Java and app packages, and any program whatever its name (a Windows, Linux or macOS binary); zip them or send a link. Attachments go with a message sent now: not with scheduled_at, and not in a batch. Tawked keeps each file’s name, type and size: Read a message lists them.
The answer
The answer is202 Accepted. In the original shape:
mode closes the extended shape: live, or test for a message a test key sent in test mode. The original shape has no mode.
The message is charged and queued at once, and sent in its turn. price_halalas is the whole halalas this message took from your balance (0 while this month’s free e-mails last, then 1 about every tenth e-mail). cost says what it cost: emails handed over for sending, suppressed skipped, free covered by the month’s allowance, billed paid, and halalas the cost before rounding, a decimal string such as "0.3". The first answer’s status is accepted (scheduled for a scheduled send); a message whose every recipient is suppressed answers failed and charges nothing. Read the message, or wait for the webhooks, to follow it.
Something that goes wrong at the sending service after the 202, such as a domain that lost its record, arrives as the message’s failed status and an email.failed webhook, its price refunded. A pause after the 202 (the account paused by Tawked or by its team, a pause at the sending service, or a hold on all of Tawked Email) does not fail the message: it stays queued, still charged, and is tried again every few minutes. It is sent if the pause is lifted within 12 hours of its time; otherwise it fails with queue_expired and is refunded once. Do not resend a message that is still queued: it goes out once the pause lifts. A message that failed before sending does not count toward the day’s limit.
Read a message
GET /v1/email/messages/{id} needs email:read (which email:send includes) and answers for a message of the key’s application; any other id answers 404 not_found. A message sent in the original shape reads in that shape:
created_at, then attachments, header_names, error, the message’s timestamps, canceled_at, batch_id, and the fields below, and each recipient with its own status, timestamps, bounce, error, opens and clicks:
opened_at, clicked_at, opens and clicks stay empty. A message to one recipient (not counting suppressed ones) counts them on that recipient too.
attachments lists what the message carried, in the order sent: each file’s name, type, size in bytes and whether it sat inside the HTML; [] when none.
Read what was sent
When the application keeps previews,GET /v1/email/messages/{id}/content answers the copy it kept of a message: its subject, HTML and text as sent, and kept_until. It needs a live key of the application with the explicit email:manage (a test key with email:send reads its own test messages; a partner key answers 403 application_key_required); every read is recorded on the account’s trail, by the key. Without a copy it answers 404 content_not_kept.
List messages
GET /v1/email/messages (with email:read) lists the application’s messages, newest first, each in the extended shape, a page at a time:
The answer is
{ "data": [...], "has_more": true, "next_cursor": "..." }: follow next_cursor while has_more is true. A bad parameter answers 400 invalid_request with the field it names. Messages are kept for 30 days, then deleted. Daily figures and the suppression list stay.
Statuses
A message:accepted (queued in the extended shape) then sent then delivered; bounced or failed end it. A message waiting for its time is scheduled, and one canceled before it is canceled. Statuses only move forward.
Each recipient has its own status in
recipients: queued, scheduled, sent, delivered, bounced, failed, suppressed (on the account’s list: never sent, never charged) or canceled. A bounce can arrive after delivered, when a mailbox accepts the message and refuses it later: the recipient becomes bounced. A complaint, a recipient marking the message as spam, sets complained_at on that recipient and the message and suppresses the address; the status and the price stay.
The suppression list
Each account keeps one list of addresses it will not send to: every permanent bounce and every complaint, from any of its applications. A listed recipient of a message is skipped, kept assuppressed and not charged. A send in the original shape to a listed address answers 422 recipient_suppressed before anything is recorded or charged; any other send whose every recipient is listed answers 202 with the status failed, nothing charged.
Email → Suppressed lists every address with its reason and the message that caused it. An address that bounced by mistake can be removed there; an address that complained cannot.
Webhooks
The application’s webhook receives these four events, and the others of Email its owner adds (sent, delayed, suppressed, scheduled, canceled, opened, clicked), one per recipient:
For a message sent in the original shape,
data carries the message:
data adds recipient and tags after to, and to, error, bounce and occurred_at are that recipient’s:
to and recipient.address carry the full address. Email events carry type (the same as event) and timestamp (when it happened) beside event and data. error is null on email.delivered, and bounce is null on every event but email.bounced. A recipient suppressed by the time the message was due gets email.failed with error.code recipient_suppressed.
Dedupe on the tawked-webhook-id header: one id per event, the same on every retry and on a delivery sent again from the console. A receiver that dedupes on the body uses event, data.id and data.recipient.id when recipient is present, else event and data.id. The event catalog has each event.
Errors
The checks every endpoint shares come first: the rate limit, the key, its access (403 insufficient_scope names email:send or email:read), the account’s state and the request’s shape (400 invalid_request for no recipient, no subject, neither html nor text, a subject over 255 characters, more than 50 recipients, a malformed headers, tags or scheduled_at; beyond the original shape the body adds field and field_index). Then, in this order:
A send, a batch, a reschedule or a cancel that reaches the per-second rate carries
RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (this second’s requests) and Tawked-Daily-Remaining (the e-mails left today): its success, and the refusals from rate_limited down in the table. A replayed Idempotency-Key and the refusals above rate_limited carry none. The per-key limit on the e-mail endpoints is 1,200 requests a minute (429 too_many_requests with Retry-After). GET /v1/email/messages/{id} answers live_key_required and 404 not_found.