Transactional Mailing API Methods

Table of Contents:

Intro

(info) Note: Notice that in each API call you must provide the List ID that you are working on, otherwise the default List ID will be used. 

Methods Summary

GET /api/transactional

Description 

This method fetches a collection of transactional campaigns.

Request

list_id

Optional number - List ID

sort

Optional string - Column name

order

Optional string - "ASC" or "DESC"

offset

Optional int

limit

Optional int

POST /api/transactional

Description 

This method creates a new transactional campaign.

Request

name

Required string

The transactional campaign internal friendly name. For your use only.

description

Required string

The transactional campaign description. For your use only

list_id

Optional int

id of list to which this transactional campaign should be attached to.

POST URL: https://api.ongage.net/<list_id>/api/transactional

Response

The response will include a newly created transactional campaign array of fields.

PUT /api/transactional/<Transactional Campaign ID>

Description 

This method updates an existing transactional campaign.

Request

name

Required string

The transactional campaign internal friendly name. For your use only.

description

Required string

The transactional campaign description. For your use only

list_id

Optional int

id of list to which this transactional campaign should be attached to.

PUT URL: https://api.ongage.net/<list_id>/api/transactional/<transactional_campaign_id>

POST /api/transactional/send

Description 

This method is used to send transactional message.

(info) Note: Not all ESPs/SMTP relays support transactional calls.

Request

message_id

Required number

The message (email or SMS) that will be used for delivery.

recipients

Required array of strings

Recipients for delivery. This must be array of emails.

Note that for transactional SMS, array of emails is also required.

campaign_id

Optional number

Related transactional campaign for delivery. If not provided the default transactional campaign will be used.

sending_connection_id

Optional number

The connection (ESP/SMS) that will be used in the transactional sending. If not provided the connection that was defined in the default transactional campaign will be used

check_status

Optional boolean - Default "false"

When set to true, this takes into account the contact’s status (unsubscribe, bounced, etc.) and don't send transactional email if status is not active.

check_global_and_list_suppression

Optional boolean - Default "false"

When set true take into account if email resides in any applicable suppression list (only in global or list scope), and if so-- don't send

message_dynamic_fields

Optional Object

You can pass in key/values, e.g., "message_dynamic_fields": { "receipt_id": 12345, "uid": 6789 }, so that you can use the keys as dynamic variables in the body of the message. e.g., This is your receipt {{receipt_id}}.

message_dynamic_fields_per_recipient

Optional array with recipient and key_value_collection - e.g., "message_dynamic_fields_per_recipient":[ { "recipient":"email@email.com", "key_value_collection":{ "receipt_id": 12345, "uid": 6789 } } ], so that you can use the keys as dynamic variables in the body of the message e.g., This is your receipt {{receipt_id}}.

campaign_suppression_list_ids

Optional array with campaign level suppression list IDs - e.g., "campaign_suppression_list_ids":[ 4060001, 4060002 ]

cc_whitelist_segment_id

Optional integer

This feature enables marketers to send an exact copy as Cc, to a list of staff members/stake holders, for legal or monitoring purposes. For each message sent via this Transactional campaign, a Cc (copy), will be sent to those email addresses associated with the selected Whitelist Segment. Not all SMTPs support the Cc feature, see our online help for a list of those that do.

bcc_whitelist_segment_id

Optional integer

This feature enables marketers to send an exact copy as Bcc, to a list of staff members/stake holders, for legal or monitoring purposes. For each message sent via this Transactional campaign, a Bcc (copy), will be sent to those email addresses associated with the selected Whitelist Segment. Not all SMTPs support the Bcc feature, see our online help for a list of those that do.

create_contact

Optional boolean - Default "false"

This feature enables marketers to add contacts in list when the respective contact used in request is not part of the sending list.


Example - Basic usage

POST URL: https://api.ongage.net/<list_id/api/transactional/send

(info) Transactional Emails have a flag, that indicate if you want the transactional email to take into account the contact’s status (unsubscribed, bounced, etc.) or not. If yes, then set check_status: true. Similarly there's a flag check_suppression: true to check and take into account if the email resides in a suppression list or not. Here's an example of how to use these:

POST /api/transactional/send_embed_content

Description 

This method is used to send a transactional message with embedded content (without message ID).

(info) Note: Not all ESPs/SMTP relays support transactional calls.

Request

message_id

Required object - Email content for delivery. Must contain the following keys:

*subject - Required string
*content_html - Required string - Only for transactional email
*content_text - Required string - Only for transactional SMS / plaintext emails
*addresses - Required object - must have the following fields:

*from_name - Required string
*from_address - Required string when transactional is of email type
*reply_address - Required string when transactional is of email type

recipients

Required array of strings

Recipients for delivery. This must be an array of emails.

Note that for transactional SMS, array of emails is also required.

campaign_id

Optional number

Related transactional campaign for delivery. If not provided the default transactional campaign will be used.

sending_connection_id

Optional number

The connection (ESP/SMS) that will be used in the transactional sending. If not provided the connection that was defined in the default transactional campaign will be used

disable_unsubscribe

Optional boolean

The email message will not include unsubscribe link. Default - False

schedule_date

Optional number or string

String of delivery date or time as Unix timestamp

delay_send

Optional number or string

String of delay time (HH:MM) or number of seconds to delay (e.g. 3600 stands for 1 hour of delay).

check_status

Optional boolean - Default "false"

When set to true, this takes into account the contact’s status (unsubscribe, bounced, etc.) and don't send a transactional email if the status is not active.

check_global_and_list_suppression

Optional boolean - Default "false"

When set true take into account if email resides in any applicable suppression list (only in global or list scope), and if so-- don't send

message_dynamic_fields

Optional Object

You can pass in key/values, e.g., "message_dynamic_fields": { "receipt_id": 12345, "uid": 6789 }, so that you can use the keys as dynamic variables in the body of the message. e.g., This is your receipt {{receipt_id}}.

message_dynamic_fields_per_recipient

Optional array with recipient and key_value_collection - e.g., "message_dynamic_fields_per_recipient":[ { "recipient":"email@email.com", "key_value_collection":{ "receipt_id": 12345, "uid": 6789 } } ], so that you can use the keys as dynamic variables in the body of the message e.g., This is your receipt {{receipt_id}}.

campaign_suppression_list_ids

Optional array with campaign level suppression list IDs - e.g., "campaign_suppression_list_ids":[ 4060001, 4060002 ]

cc_whitelist_segment_id

Optional integer

This feature enables marketers to send an exact copy as Cc, to a list of staff members/stake holders, for legal or monitoring purposes. For each message sent via this Transactional campaign, a Cc (copy), will be sent to those email addresses associated with the selected Whitelist Segment. Not all SMTPs support the Cc feature, see our online help for a list of those that do.

bcc_whitelist_segment_id

Optional integer

This feature enables marketers to send an exact copy as Bcc, to a list of staff members/stake holders, for legal or monitoring purposes. For each message sent via this Transactional campaign, a Bcc (copy), will be sent to those email addresses associated with the selected Whitelist Segment. Not all SMTPs support the Bcc feature, see our online help for a list of those that do.

create_contact

Optional boolean - Default "false"

This feature enables marketers to add contacts in list when the respective contact used in request is not part of the sending list.

Example - Regular embedded transactional email sending

POST URL: https://api.ongage.net/<list_id>/api/transactional/send_embed_content

POST /api/notify_transactions

Description 

This method is used to send a new request for an ongoing transactional mailing.

Note: Not all ESPs/SMTP relays support transactional calls.

Request

recipients

Required array of strings

Recipients for delivery. This must be array of emails.

Note that for transactional SMS, array of emails is also required.

mailing_id

Optional number

Related transactional campaign for delivery. If not provided the default transactional campaign will be used.

email_message_id

Required number

Existing email for delivery. You must provide email_message_id or email_message

disable_unsubscribe

Optional boolean

The email message will not include unsubscribe link. Default - False

schedule_date

Optional number or string

String of delivery date or time as Unix timestamp

delay_send

Optional number or string

String of delay time (HH:MM) or number of seconds to delay (e.g. 3600 stands for 1 hour of delay).

check_status

Optional boolean - Default "false"

When set to true, this takes into account the contact’s status (unsubscribe, bounced, etc.) and don't send transactional email if status is not active.

check_global_and_list_suppression

Optional boolean - Default "false"

When set true take into account if email resides in any applicable suppression list (only in global or list scope), and if so-- don't send

email_message

Optional array of key/value - Email content for delivery. Providing a email_message_id will override this parameter

*subject string

*name string

*content_html string

*content_text string

*addresses array

addresses

Required if sent 'email_message' array of arrays:

*from_name: From name

*from_address: From address

*reply_address: Reply address

*esp_connection_id

distribution

Optional one of the next options:

Empty: Will use current default ESP distribution configuration, in case there is no default configured, an error will be raised

ID: Numeric id of the ECID (ESP Connection ID) you want to use. That would be the number that appears in the ECID column next to that ESP connection, in your My Connections screen.

Array: Will use given ESP array:

*esp_connection_id: Numeric ID (Note that esp_id is deprecated)

*domain: String of domain name or "default"

*percent: Percentage of contacts to send through this ESP

message_dynamic_fields

Optional Object

You can pass in key/values, e.g., "message_dynamic_fields": { "receipt_id": 12345, "uid": 6789 }, so that you can use the keys as dynamic variables in the body of the message. e.g., This is your receipt {{receipt_id}}.

message_dynamic_fields_per_recipient

Optional array with recipient and key_value_collection - e.g., "message_dynamic_fields_per_recipient":[ { "recipient":"email@email.com", "key_value_collection":{ "receipt_id": 12345, "uid": 6789 } } ], so that you can use the keys as dynamic variables in the body of the message e.g., This is your receipt {{receipt_id}}.

campaign_suppression_list_ids

Optional array with campaign level suppression list IDs - e.g., "campaign_suppression_list_ids":[ 4060001, 4060002 ]

Example - Using email/sms message ID

POST URL: https://api.ongage.net/<list_id>/api/notify_transactions

(info) Transactional Emails have a flag, that indicates if you want the transactional email to take into account the contact’s status (unsubscribed, bounced, etc.) or not. If yes, then set check_status: true. Similarly, there's a flag check_suppression: true to check and take into account if the email resides in a suppression list or not. Here's an example of how to use these:

Response

Same as provided request

Error codes

  • 403 - Permission error
  • 404 - Email/Campaign not found

DELETE /API/transactional/<Transactional Campaign ID>

Description

This method deletes a transactional campaign.

Additional Examples

Request Example - Transactional Send - Using specific transactional campaign and specific connection

POST URL: https://api.ongage.net/<list_id>/api/transactional_send

Request Example - Transactional Send - using dynamic fields per recipient

POST URL: https://api.ongage.net/<list_id>/api/transactional_send

Request Example - Transactional Send - Using SMS message content

POST URL: https://api.ongage.net/<list_id>/api/transactional_send

Request Example - Embedded content - Regular embedded transactional SMS sending

POST URL: https://api.ongage.net/<list_id>/api/transactional/send_embed_content

Request Example - Embedded content - Embedded transactional email with "message_dynamic_fields"

POST URL: https://api/ongage.net/<list_id>/api/transactional/send_embed_content

Request Example - Notify Transactions - Using email message content

POST URL: https://api.ongage.net/<list_id>/api/notify_transactions

Request Example - Notify Transactions - Using dynamic fields per recipient

POST URL: https://api.ongage.net/<list_id>/api/notify_transactions

Request Example - Notify Transactions - Using SMS message content

POST URL: https://api.ongage.net/<list_id>/api/notify_transactions

Appendix

SMTPs that support Cc and Bcc

  • MailGun

  • Amazon SES

  • MailJet

  • mySMTP

  • Oracle Dyn (On Request)

  • SocketLabs

  • SparkPost

  • Sendgrid