Overview

Integration

User guide

API reference

Webhooks

Overview

Endpoint URL #

The Postmark API is built on REST principles. Authenticated users can interact with any of our URIs by using the specified HTTP request method. We enforce TLS encryption by issuing requests via HTTPS.

https://api.postmarkapp.com

Authentication #

All requests to Postmark’s API require you to authenticate yourself to the service. In order to do this you must send the correct HTTP header with the correct API token. Postmark has two types of API tokens:

  • Server Token — X-Postmark-Server-Token Used for requests that require server level privileges. Found from the API Tokens tab under your Postmark server. This token is accessible by Account Owners, Account Admins, and users who have Server Admin privileges on a server. 
  • Account Token — X-Postmark-Account-Token Used for requests that require account level privileges. Found from the API Tokens tab of your Postmark account. This token is accessible by the Account Owner and Account Admins.

Each reference page for the different API endpoints will always specify which authentication header to use. The header name and value are case insensitive. In the case that you execute a request with wrong or missing headers, you will receive an HTTP Response 401 (Unauthorized).

Often when implementing your client library or when integrating an existing library into your application you may want to send test emails that don’t actually get delivered to the recipient. In most cases you just need to know if your data is valid. You can do this by passing the POSTMARK_API_TEST value in the X-Postmark-Server-Token header field.

HTTP response codes #

  • 200 — Success Everything went smooth.
  • 401 — Unauthorized Missing or incorrect API token in header.
  • 404 — Entity doesn't exist You made a request for a resource/entity that does not exist. Please ensure the endpoint and ID you are requesting are correct.
  • 413 — Payload Too Large The request exceeded Postmark's size limit of 10 MB for our Email API and 50 MB total payload size for our Batch Email API.
  • 415 — Unsupported Media Type The API request is missing the expected request headers. Please review the documentation for the API endpoint to ensure the required request headers are passed.
  • 422 — Unprocessable Entity Something with the request isn't quite right — malformed JSON or invalid fields, for example. The response body contains JSON with an API error code and a message with the details:
    {
     "ErrorCode": 403,
     "Message": "Invalid request field(s): 'From'."
    }
  • 429 — Rate Limit Exceeded We have detected that you are making requests at a rate that exceeds acceptable use of the API. You should reduce the rate at which you query the API.
  • 500 — Internal Server Error This is an issue with Postmark’s servers processing your request. In most cases the message is lost during the process, and we are notified so that we can investigate the issue.
  • 503 — Service Unavailable During planned service outages, Postmark API services will return this HTTP response and associated JSON body.

API error codes #

When the Postmark API detects a problem with your request, it returns a JSON body with a numeric ErrorCode and a human-readable Message, and echoes the code in the X-PM-ApiErrorCode response header. Most input errors use HTTP 422, but some use a different status — for example, authentication failures return 401 and maintenance returns 503. Each code's status is listed in the HTTP column below. A single ErrorCode can cover several related messages.

{
  "ErrorCode": 403,
  "Message": "Invalid request field(s): 'From'."
}

The ErrorCode field can be used to programmatically detect the type of error. Here are the supported error codes:

 

API error codes
Code HTTP Message
Authentication
10401Request does not contain a valid Server or Account token, or the wrong token type was used for the endpoint.
Global
100503The Postmark API is offline for maintenance.
101500You encountered an error that shouldn't have occurred. The response includes an Error ID for support.
Sending  — batch sends return per-message codes inside an HTTP 200 response
11422Multiple errors occurred. Inspect the Errors property for more information.
12404Bulk send not found.
13422Invalid pagination key.
14422This endpoint requires approval to access. Contact support to use the Bulk API.
300422Send validation. Covers many messages — zero recipients, invalid address, missing TextBody/HtmlBody, and recipient, metadata, attachment, or header limits.
402422Invalid JSON.
403422Invalid request field(s).
406422Inactive recipient.
410422You may only send up to 500 messages in a single batched request.
411422Attachment file type not allowed.
412422While your account is pending approval, all recipient addresses must share the same domain as the From address.
413422This account is not approved to send email.
422422Invalid Server or Account.
1235422The stream provided does not exist on this server.
1236422Sending is not supported for this stream type.
Templates
601422The source or destination server was not found (template push).
1100422Template list paging, or an invalid TemplateType or editorType query parameter.
1101422The request specifies neither TemplateId nor TemplateAlias, or the referenced template, alias, or layout was not found.
1105422A server's active-template limit would be exceeded by this request.
1109422No template data received.
1120422A required field is missing — Name, one of TextBody/HtmlBody, Subject, or TemplateModel.
1121422A field is too long — Name, Alias, HtmlBody, TextBody, Subject, or TemplateModel.
1122422Invalid TemplateType, alias empty/invalid/in-use, unparseable body, or a reserved top-level TemplateModel key.
1123422Template/send mutual-exclusion rules (layout vs. subject/body, templated vs. non-templated).
1124422No templates with aliases found to push, or the per-request push limit was exceeded.
1125422The template types don't match on the source and destination servers.
1130422The layout template cannot be deleted because dependent templates use it.
1131422Layout content-placeholder rules were not met.
Servers
600422Server-list paging — offset/count required or integer; up to 500 servers per call.
602422The specified inbound domain is already registered or in use on another server.
603422This server name already exists.
604422You do not have permission to delete servers using the API.
605422Unable to remove this server. Please contact support.
606422A supplied hook URL (Inbound, Bounce, Open, Delivery, or Click) is not valid.
607422Invalid server color.
608422Server name is invalid or missing, or an inbound domain containing postmarkapp.com was used.
609422No server data received.
610422We could not find an MX record pointing to the expected domain.
611422InboundSpamThreshold value is invalid. Use a number between 0 and 30.
612422The supplied TrackLinks option is not valid.
613422The supplied DeliveryType option is not valid.
614422Entitlement limit reached (inbound, stats, users, servers, streams, or domains).
615422Action is not supported.
Message activity, messages & bounces
700422Paging/parameter validation for messages, opens, clicks, and activity.
701422This message was not found, or cannot be bypassed or retried.
702422Could not bypass this blocked message. Please contact support.
703422Could not retry this failed message. Please contact support.
1000422Bounces query validation (non-negative, up to 500, count+offset, illegal bounce type).
1001422The bounce was not found, or its dump is no longer available.
1002400A bounceID parameter is required.
1003422Due to the type of bounce, this address cannot be reactivated.
Inbound rules / triggers
800422You may only request up to 500 triggers per call, plus parameter validation.
809422No trigger data received.
810422This inbound rule already exists.
811422Unable to remove this inbound rule. Please contact support.
812422This inbound rule was not found.
Message Streams
1220422You do not have permission to use the message streams API.
1221422The MessageStreamType associated with this request was invalid.
1222422A valid ID must be provided.
1223422A valid Name must be provided.
1224422The Name is too long.
1225422You have reached the maximum number of message streams for this server.
1226422The message stream for the provided ID was not found.
1227422The ID must be a non-empty string starting with a letter, up to 30 characters.
1228422A server can only have one inbound stream.
1229422You cannot archive the default transactional and inbound streams.
1230422The ID provided already exists for this server.
1231422The Description is too long.
1232422You cannot unarchive this message stream anymore.
1233422The ID must not start with the pm- prefix.
1234422The Description must not contain HTML tags.
1237422The ID is reserved.
1238422You do not have permission to use Custom Unsubscribe Handling for this stream.
1239422The UnsubscribeHandlingType provided is not supported for this stream type.
1240422The UnsubscribeHandlingType associated with this request is invalid.
1241422Stream is unable to be archived at this time.
Suppressions
1400422Parameter count should be an integer within the allowed range.
1401422Parameter count is required but was left out.
1402422Parameter offset should be an integer greater than or equal to zero.
1403422Parameter offset is required but was left out.
1404422Parameter SuppressionReason is invalid.
1405422Parameter Origin is invalid.
1406200 bodyYou do not have the required authority to change this suppression (per-item result).
1407422Something went wrong when processing the request.
1408422 / 200 bodyAn invalid email address was provided.
1409422A proper request body must be provided.
1410422You cannot provide more than the maximum number of suppressions for this request.
1411422Parameter emailAddress is required but was left out.
Sender Signatures & Domains
500422Signature/domain list paging (count/offset required or integer, up to 500).
501422 / 404 / 500Signature not found (422/404), or the signature has no DKIM info (500).
502422No update data or signature data received.
503422You can't use public domain emails or public domains.
504422This signature already exists, or a similar signature already exists.
505422This DKIM is already being renewed.
506422This Sender Signature has already been confirmed.
507422You do not own this Sender Signature.
508422This DKIM is not being renewed, or a key in a failed state cannot be rotated.
510422This domain was not found.
511422Invalid fields supplied.
512422Domain already exists.
513422You do not own this Domain.
514422Name is a required field to create a Domain.
515422Name field must be ≤ 255 characters.
516422Name format is invalid.
520422FromEmail is a required field to create a Sender Signature.
521422A field is too long (confirmation note, Name, FromEmail, ReplyToEmail, ReturnPathDomain, or CustomTrackingDomain).
522422A value is not a valid email address, domain, or subdomain.
523422You need to add a CNAME record that points to the expected value.
614422Signature/domain entitlement limit reached.
709500DKIM verification failed due to invalid configuration. Please contact support.
SMTP Tokens  — new
1450422Parameter serverId is required but was left out.
1451422This token could not be found.
1452422A request body must be provided.
1453422This server was not found.
1454422A valid MessageStream is required, or the specified stream does not exist.
1455422The request must contain a valid and existing ServerID.
1456422Token length must be within the allowed range.
1457422Tokens cannot be used with inbound streams.
1458422A message stream's token limit would be exceeded by this request.
1459422A token cannot be issued for an archived stream scheduled for deletion.
1460422SMTP is currently disabled for the specified server.
Statistics API
614422You are not entitled to use the stats API. Upgrade to the next tier to add it.
900422A parameter should be a date/time value.
1226422The message stream for the provided ID was not found.
1500422The FromDate field cannot be older than one year ago.
1501422Parameter count should be an integer within the allowed range.
1502422Parameter FromDate must be older than ToDate.
GDPR API
1300422Empty request, or an invalid offset or count.
1301422Missing or incorrect data removal request ID.
1302422You don't have permission to process or review data removal requests through the API.
Webhooks API  — new
1350422You cannot create a webhook using an archived MessageStream.
1351422You cannot create a webhook using an inbound stream.
1352422The webhook for the provided ID was not found.
1353422The webhook trigger is not supported on this message stream.
1354422The request must contain a valid Url field.
1355422A request body must be provided.
1356422A request ID must not be provided when creating a webhook.
1357422You cannot update the ID or MessageStream fields of a webhook.
1358422You must provide a valid HttpHeader Name.
1359422You have reached the maximum number of webhooks for this stream.
1360422You cannot update the integration.
1361422Invalid value provided for a field.
1362422Invalid value provided for status. Must be one of: verified, unverified.
1363422The Status field cannot be provided when creating or updating a webhook.
1364422Webhook verification failed; nothing was saved. Fix the endpoint and retry, or send ?verify=false to save it unverified.