Batch messages API – Cordial Knowledge Base

How can we help?

Overview

The batch messages resource sends a message or schedules a message to be sent as a one-time communication. Visit this article for information on creating and sending batch messages via UI.

Batch message API calls contain details on content, channel, send trigger, type of communication (transactional or promotional), subject line, from and reply addresses, and HTML layout.

Additional information

Authentication

Cordial's core APIs use HTTPS Basic Authentication (BA). From within the Cordial platform, you can generate an encoded API key for your account and use it for authorization.

Methods, parameters, and examples

POST/v2/batchmessages

Method URL Path
POST /v2/batchmessages
- Creates a batch message template in the Cordial database using the appropriate JSON body.
- Posting more than one time will cause subsequent batch messages to be created. Use PUT to change or update a batch message that has not yet sent.
Parameter Type Description Example
### Message send information
* channel string Messaging channel key (e.g. email, sms, push). Note that some of your channels may have custom keys. email
* classification string If applicable, classifies the message as transactional or promotional. transactional
name string An optional name given to the message. Jan_Newsletter_2025
tags array An array of string values to identify and categorize the message. Tags are case sensitive. ["birthday","promo"]
audience-key string Defines a saved audience rule "name". 30_day_engaged
schedule date An optional date and time at which the message is to be sent. The date should be in the future and use the ISO 8601 format. 2025-01-09T22:47:12+0000
scheduleType string Enable sending at the scheduled time per the time zone of the contact. If not specified, the template will send using the Cordial account default time zone. contactTZ
transportID string Defines the transportID if overriding the default. Default is used if this parameter is not included. 57d098b66c8766fd53ad19d7
trackLinks string Determines if link performance will be tracked. Default is enabled.
Possible Values:
enabled, disabled
### Message header
* subject string The subject line for the communication. Welcome to myco!
* fromEmail string The email address that the message is from. email@myco.io
* fromDesc string Describes the sender. CS Dept
* replyEmail string The email address that the message's replies will go to. email@example.com
### Message content
* text/html string HTML markup for the message.
content
tests (array)
type String Defines the test to be run. InboxMonster
enabled Boolean Flag to determine if the test is enabled or disabled. The default is disabled. true

The following will create and schedule a new batch message for a promotional email to all contacts using the default transport. The response will include an ID for the newly created batchmessages instance.

{
    "sendtrigger": "manual",
        "channel": "email",
    "classification": "promotional",
    "name": "promo_01_20_2025",
    "schedule": "2025-01-2316:10:08",
    "scheduleType": "contactTZ",
    "message": {
        "headers": {
            "subject": "Buyoneticketandgetsecondhalfprice",
            "fromEmail": "skiguy@example.com",
            "replyEmail": "skiguy@example.com",
            "fromDesc": "SkiPromotionsTeam"
        },
        "content": {
            "text/html": "<div>Some Content</div>"
        }
    },
    "transportID": "57d098b66c8766fd53ad19d7",
    "trackLinks": "enabled",
    "tests": [{
        "type": "InboxMonster",
        "enabled": true
    }]
}

The following URL in conjunction with the JSON will perform the POST of batchmessages.

https://<path>/v2/batchmessages

GET/v2/batchmessages

Method URL Path
GET /v2/batchmessages
- Retrieves all batch messages from the Cordial database.
- Note: Info and stats on daily message automations is retrieved using this API call. You can filter the response for message automations using the triggers parameter, the creation time, or mdtID.
Parameter Type Description Example
sendTime[gt] string Returns records where the send time is greater than the specified date. <br>?sendTime[gt]=2025-01-01T00:00:00.000Z<br>
sendTime[gte] string Returns records where the send time is greater than or equal to the specified date. <br>?sendTime[gte]=2025-01-01T00:00:00.000Z<br>
sendTime[lt] string Returns records where the send time is less than the specified date. <br>?sendTime[lt]=2025-01-01T00:00:00.000Z<br>
sendTime[lte] string Returns records where the send time is less than or equal to the specified date. <br>?sendTime[lte]=2025-01-01T00:00:00.000Z<br>
status string The message status.
Possible Values:
sent, cancelled, paused, sending
<br>?status=paused<br>
triggers[api][enabled] string For message automations: filters results based on whether the API trigger is enabled or disabled.
Possible Values:
true, false
<br>?triggers[api][enabled]=true<br>
triggers[event][enabled] string For message automations: filters results based on whether the event trigger is enabled or disabled.
Possible Values:
true, false
<br>?triggers[event][enabled]=true<br>
triggers[recurring][enabled] string For message automations: filters results based on whether the recurring trigger is enabled or disabled.
Possible Values:
true, false
<br>?triggers[recurring][enabled]=true<br>
tags string Returns results that contain the specified message tags. <br>?tags=welcome<br>
mdtID string The automation template ID. <br>?mdtID=591f1a26ac0c811781bf44ea<br>
ct[gt] string Returns records where the create date is greater than the specified date. <br>?ct[gt]=2025-01-01T00:00:00.000Z<br>
ct[gte] string Returns records where the create date is greater than or equal to the specified date. <br>?ct[gte]=2025-01-01T00:00:00.000Z<br>
ct[lt] string Returns records where the create date is less than the specified date. <br>?ct[lt]=2025-01-01T00:00:00.000Z<br>
ct[lte] string Returns records where the create date is less than or equal to the specified date. <br>?ct[lte]=2025-01-01T00:00:00.000Z<br>
page string Specifies the results page number to be returned. <br>?page=3<br>
per_page string Specifies the number of records returned per page. <br>?per_page=100<br>
sort_by string Specifies the field to sort by. <br>?sort_by=sendTime<br>
sort_dir string Specifies the sort direction as ascending or descending.
Possible Values:
desc, asc
<br>?sort_dir=desc<br>

The following URL will retrieve all batch messages.

https://<path>/v2/batchmessages

The following URL will retrieve all batch messages, starting from the third page and grouping messages by 10. For example, page-1 would have included the first 10, page-2 the second group of 10 and so on.

https://<path>/v2/batchmessages?page=3&per_page=10

PUT/v2/batchmessages/{id}

Method URL Path
PUT /v2/batchmessages/{id}
- Updates an unsent batch message in the Cordial database using the appropriate JSON body.
- The batch message's record is defined by the batch messages's unique ID value (generated by the POST method).
- The PUT method can only be used if the message status is Draft.

The following will change the subject and push the launch schedule date by one day.

{
  "status": "",
  "sendtrigger": "manual",
  "classification": "promotional",
  "name": "promo_01_20_2025",
  "schedule": "2025-01-24 16:10:08",
  "scheduleType": "contactTZ",
  "message": {
    "headers": {
      "subject": "Buy one ticket and get the second half price",
      "fromEmail": "skiguy@example.com",
      "replyEmail": "skiguy@example.com",
      "fromDesc": "Ski Promotions Team"
    },
    "content": {
      "text/html": "<div>Some Content</div>"
    }
  },
  "transportID": "account transportID",
  "trackLinks": "enabled"
}

The following URL in conjunction with the JSON will perform the PUT of the batch message with the ID of 252:58ffed51f0c36063476c1752:ot.

https://<path>/batchmessages/252:58ffed51f0c36063476c1752:ot

GET/v2/batchmessages/{id}

Method URL Path
GET /v2/batchmessages/{id}
- Retrieves a batch message from the Cordial database.
- The batch message's record is defined by the batch message's unique ID value.

The following URL will retrieve a batch message where the ID value is 252:58ffed51f0c36063476c1752:ot.

https://<path>/v2/batchmessages/252:58ffed51f0c36063476c1752:ot

DELETE/batchmessages/{id}

Method URL Path
DELETE /v2/batchmessages/{id}
- Deletes a batch message within the Cordial database.
- The batch message is defined by the batch message's unique ID value.

The following URL will delete a batch message where the ID value is 252:58ffed51f0c36063476c1752:ot.

https://<path>/v2/batchmessages/252:58ffed51f0c36063476c1752:ot

PUT/v2/batchmessages/{id}/send

Method URL Path
PUT /batchmessages/{id}/send
- Sends or schedules a batch message within the Cordial database.
- The batch message record is defined by the batch message's unique ID value.

The following URL perform the PUT to the batch message with the ID 252:58ffed51f0c36063476c1752:ot.

https://<path>/v2/batchmessages/252:58ffed51f0c36063476c1752:ot/send

PUT/v2/batchmessages/{id}/sendtest

Method URL Path
PUT /batchmessages/{id}/sendtest
- Sends a test batch message.
- The batchmessages record is defined by the batchmessages's unique ID value.
Parameter Type Description Example
* contact identifier array An array of contact identifier values to receive the test message. [ "test1@example.com","test2@example.com" ]

Email as identifier

{
  "email": [
    "test1@example.com","test2@example.com"
  ]
}

cID as identifier

{
  "cID": [
 "58d30719ac0c8117814da1f3","39f67345aq0c0276295da1g9"
  ]
}

The following URL in conjunction with the JSON will perform the PUT to the batch message with the ID 252:58ffed51f0c36063476c1752:ot.

https://<path>/batchmessages/252:58ffed51f0c36063476c1752:ot/sendtest

GET/v2/batchmessages/{id}/renderedwip/{contactID}

Method URL Path
GET /v2/batchmessages/{id}/renderedwip/{contactID}
- Retrieves the message headers, the rendered HTML, and the experiment name and variants of a batch message draft for a specified contact from the Cordial database.
- The batch message's record is defined by the batch message's unique ID value.
- The contact record is defined by the contact's unique cID value.

The following URL will perform the GET to the batch message where:

https://<path>/v2/batchmessages/252:594ac3d2f0c360031181a7f0:ot/renderedwip/58d30719ac0c8117814da1f3

PUT/v2/batchmessages/{id}/pause

Method URL Path
PUT /v2/batchmessages/{id}/pause
- Pauses the sending of a batch message.
- The batch message record is defined by the batch message's unique ID value.

The following URL will perform the PUT to the batch message with the ID 252:58ffed51f0c36063476c1752:ot.

https://<path>/v2/batchmessages/252:58ffed51f0c36063476c1752:ot/pause

PUT/v2/batchmessages/{id}/resume

Method URL Path
PUT /v2/batchmessages/{id}/resume
- Resumes the sending of a batch message.
- The batch message record is defined by the batch message's unique ID value.

The following URL will perform the PUT to the batch message with the ID 252:58ffed51f0c36063476c1752:ot.

https://<path>/v2/batchmessages/252:58ffed51f0c36063476c1752:ot/resume

PUT/v2/batchmessages/{id}/cancel

Method URL Path
PUT /v2/batchmessages/{id}/cancel
- Cancels the sending of a batch message. A paused message may also be canceled.
- The batch message record is defined by the batch message's unique "id" value.

The following URL will perform the PUT to the batch message with the ID 252:58ffed51f0c36063476c1752:ot.

https://<path>/v2/batchmessages/252:58ffed51f0c36063476c1752:ot/cancel

PUT/v2/batchmessages/{id}/unschedule

Method URL Path
PUT /v2/batchmessages/{id}/unschedule
- Unschedule a scheduled batch message. Unscheduled messages will revert to draft status and can be edited. Messages that are in the processing status cannot be unscheduled ("Unable to unschedule message" notification will be returned).
- The batch message record is defined by the batch message's unique ID value.

The following URL will perform the PUT to the batch message with the ID 252:58ffed51f0c36063476c1752:ot.

https://<path>/v2/batchmessages/252:58ffed51f0c36063476c1752:ot/unschedule

Error responses

The Cordial API will return an error object with an errorKey and message if there is a problem with an API call. Below is a list of errors specific to the Batch Messages API endpoint, along with suggested modifications to resolve each error. If you receive an error from this API endpoint that is not listed in this table, it is likely recorded within the Global API error responses page.

errorKey Message Modifications
CHANNELS_KEY_NOT_FOUND Incorrect channel for current account The provided channel is not present for the current account.
BATCH_MESSAGES_SMS_TRANSACTIONAL_MESSAGES_NOT_ALLOWED Transactional messages are not allowed for messages of type SMS. SMS messages must be classified as promotional.
BATCH_MESSAGES_AUDIENCE_FILTER_CONFLICT Please use only one from existing filters: 'audience' or 'audience-key' Either audience or audience-key may be used to filter, but not both.
MESSAGE_TRANSPORT_NOT_CONFIGURED Transport must be configured before messages can be created Ensure the transport has been configured and input correctly.
BATCH_MESSAGES_AUDIENCE_NOT_FOUND Audience with name: {} does not exist. The given audience was not found.

Have a question?

Contact support