new Client(serverKey, options)
The constructor for the Client
object.
This is the main entry point to the standard Postmark API.
var client = new Client('<server key>');
// You can now use any of the methods associated with the client.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
serverKey |
string | The server key is required, and specifies which Server you wish to use when making API calls from this Client. |
|
options |
ClientOptions |
<optional> |
The configuration options for this client. If not specified, the global defaults will be used. |
Returns:
Client
Methods
-
activateBounce(id, callback) → {Promise}
-
Cause an email address that was deactivated due to a Bounce to be reactivated.
Parameters:
Name Type Description id
number The ID of the Bounce for which you wish to activate the associated email.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
batch(messages, callback) → {Promise}
-
Send a batch of email messages.
Parameters:
Name Type Description messages
Array.<PostmarkMessage> An array of
PostmarkMessage
you wish to send using this Client.callback
PostmarkCallback A standard callback that is called when the API request completes.
- Deprecated:
-
- Consider using
Client#sendEmailBatch
instead of this method.
- Consider using
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
bypassBlockedInboundMessage(id, callback) → {Promise}
-
Cause an Inbound Message to bypass filtering rules defined on this Client's associated Server.
Parameters:
Name Type Description id
number The ID of the Inbound Message for which you wish to bypass the filtering rules.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
createInboundRuleTrigger(options, callback) → {Promise}
-
Create an Inbound Rule Trigger.
Parameters:
Name Type Description options
object The configuration options to used when creating this Trigger.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
createTagTrigger(options, callback) → {Promise}
-
Create a new Tag Trigger.
Parameters:
Name Type Description options
object Configuration options to be used in creating the trigger.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
createTemplate(template, callback) → {Promise}
-
Create a new template on the associated server.
Parameters:
Name Type Argument Description template
object <optional>
The template you wish to create.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
deleteInboundRuleTrigger(id, callback) → {Promise}
-
Delete an Inbound Rule Trigger.
Parameters:
Name Type Description id
number The ID of the Inbound Rule Trigger you wish to delete.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
deleteTagTrigger(id, callback) → {Promise}
-
Delete an existing Tag Trigger.
Parameters:
Name Type Description id
number The ID of the Tag Trigger you wish to delete.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
deleteTemplate(id, callback) → {Promise}
-
Delete a template associated with this server.
Parameters:
Name Type Argument Description id
int <optional>
The templateid you wish to delete.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
editServer(options, callback) → {Promise}
-
Modify the Server associated with this Client.
Parameters:
Name Type Description options
object The options you wish to modify for this server.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
editTagTrigger(id, options, callback) → {Promise}
-
Modify an existing Tag Trigger.
Parameters:
Name Type Description id
number The ID of the Tag Trigger you wish to modify.
options
object The updated configuration options for this Tag Trigger.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
editTemplate(id, template, callback) → {Promise}
-
Update a template on the associated server.
Parameters:
Name Type Description id
number The id of the template you wish to update.
template
object The values on the template you wish to update.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getBounce(id, callback) → {Promise}
-
Get a information for a specific Bounce.
Parameters:
Name Type Description id
number The ID of the Bounce you wish to retrieve.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getBounceCounts(filter, callback) → {Promise}
-
Get statistiscs on emails that bounced after being sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getBounceDump(id, callback) → {Promise}
-
Get a Bounce Dump for a specific Bounce.
Parameters:
Name Type Description id
number The ID of the Bounce for which you wish to retrieve a dump.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getBounces(filter, callback) → {Promise}
-
Retrieve a batch of bounces. The default batch size is 100, and the offset is 0.
Parameters:
Name Type Argument Description filter
object <optional>
An optional filter for which bounces to retrieve.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getBounceTags(callback) → {Promise}
-
Get an array of tags associated with bounces.
Parameters:
Name Type Description callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getBrowserPlatforms(filter, callback) → {Promise}
-
Get browser platform statistics for tracked links for messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getBrowserUsage(filter, callback) → {Promise}
-
Get browser family statistics for tracked links for messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getClickCounts(filter, callback) → {Promise}
-
Get total clicks statistics for tracked links for messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getClickLocation(filter, callback) → {Promise}
-
Get click location statistics for tracked links for messages sent from the Server associated with this Client. (Shows whether a tracked link was clicked from "HTML" or "Text" body of the email)
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getDeliveryStatistics(callback) → {Promise}
-
Retrieve delivery statistic information for the associated Server.
Parameters:
Name Type Description callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getEmailClientUsage(filter, callback) → {Promise}
-
Get statistics on which Email Clients were used to open messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getEmailOpenCounts(filter, callback) → {Promise}
-
Get Open statistics for messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getEmailPlatformUsage(filter, callback) → {Promise}
-
Get Email Client Platform statistics for messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getEmailReadTimes(filter, callback) → {Promise}
-
Get Read Time statistics for messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getInboundMessageDetails(id, callback) → {Promise}
-
Get details for a specific Inbound Message.
Parameters:
Name Type Description id
number The ID of the Inbound Message for which you wish to retrieve details.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getInboundMessages(filter, callback) → {Promise}
-
Retrieve a batch of Inbound Messages. The default batch size is 100, and the offset is 0. You can make successive calls to the API to retrieve additional Inbound Messages.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getInboundRuleTriggers(filter, callback) → {Promise}
-
Get a list of Inbound Rule Triggers. The default batch count is 100, and the offset is 0. You may retrieve additional Inbound Rule Tag Triggers by making successive calls to the API.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getMessageOpens(filter, callback) → {Promise}
-
Get the Opens for Outbound Messages. The default batch size is 100, and offset is 0. You can make successive calls to the API to retrieve additional Opens information.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getMessageOpensForSingleMessage(id, filter, callback) → {Promise}
-
Get Open information for a single Outbound Message. The default batch size is 100, and offset is 0.
Parameters:
Name Type Argument Description id
number The ID of the Message for which you wish to retrieve Opens.
filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getOuboundOverview(filter, callback) → {Promise}
-
Get overview statistics on Outbound Messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getOutboundMessageDetails(id, callback) → {Promise}
-
Get details for a specific Outbound Message.
Parameters:
Name Type Description id
number The ID of the Outbound Message for which you wish to retrieve details.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getOutboundMessages(filter, callback) → {Promise}
-
Retrieve a batch of Outbound Messages. The default batch size is 100, and the offset is 0. You can make successive calls to the API to retrieve additional Outbound Messages.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getSentCounts(filter, callback) → {Promise}
-
Get statistics on email sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getServer(callback) → {Promise}
-
Get the information for the Server associated with this Client.
Parameters:
Name Type Description callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getSpamComplaints(filter, callback) → {Promise}
-
Get SPAM complaint statistics for email sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getTagTrigger(id, callback) → {Promise}
-
Get a specific Tag Trigger.
Parameters:
Name Type Description id
number The ID of the Tag Trigger you wish to retrieve.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getTagTriggers(filter, callback) → {Promise}
-
Get a list of Tag Trigger. The default batch count is 100, and the offset is 0. You may retrieve additional Tag Triggers by making successive calls to the API.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getTemplate(id, callback) → {Promise}
-
Get the a specific template assoicated with this server.
Parameters:
Name Type Argument Description id
int <optional>
The templateid for the template you wish to retrieve.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getTemplates(options, callback) → {Promise}
-
Get the list of templates assoicated with this server.
Parameters:
Name Type Argument Description options
object <optional>
Optional paging/filtering options.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
getTrackedEmailCounts(filter, callback) → {Promise}
-
Get email tracking statistics for messages sent from the Server associated with this Client.
Parameters:
Name Type Argument Description filter
object <optional>
Optional filtering parameters.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
retryInboundHookForMessage(id, callback) → {Promise}
-
Request that Postmark retry POSTing to the Inbound Hook for the specified message.
Parameters:
Name Type Description id
number The ID of the Inbound Message for which you wish to retry the inbound hook.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
send(message, callback) → {Promise}
-
Send a single email message.
Parameters:
Name Type Description message
PostmarkMessage The message you wish to send.
callback
PostmarkCallback A standard callback that is called when the API request completes.
- Deprecated:
-
- Consider using
Client#sendEmail
instead of this method.
- Consider using
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
sendEmail(message, callback) → {Promise}
-
Send a single email message.
Parameters:
Name Type Description message
PostmarkMessage The message you wish to send.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
sendEmailBatch(messages, callback) → {Promise}
-
Send a batch of email messages.
Parameters:
Name Type Description messages
Array.<PostmarkMessage> An array of
PostmarkMessage
you wish to send using this Client.callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
sendEmailWithTemplate(message, callback) → {Promise}
-
Send a message using a template.
Parameters:
Name Type Description message
PostmarkTemplateMessage The message you wish to send.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise
-
validateTemplate(templateContent, callback) → {Promise}
-
Validate template markup to verify that it will be parsed. Also provides a recommended template model to be used when sending using the specified template content.
Parameters:
Name Type Argument Description templateContent
object <optional>
The template you wish to update.
callback
PostmarkCallback A standard callback that is called when the API request completes.
Returns:
If no callback is passed, returns a Promise with the JSON response from the API (or error).
- Type
- Promise