Sample - Twilio SendGrid Mail API
POST/v3/mail/batch

Create a batch ID.

This operation allows you to generate a new mail batch ID.

Once a batch ID is created, you can associate it with a mail send by passing it in the request body of the Mail Send operation. This makes it possible to group multiple requests to the Mail Send operation by assigning them the same batch ID.

A batch ID that's associated with a mail send can be used to access and modify the associated send. For example, you can pause or cancel a send using its batch ID. See the Scheduled Sends API for more information about pausing and cancelling a mail send.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

1 parameter
on-behalf-ofstringoptional
Use the `on-behalf-of` header to make API calls for a particular Subuser through the parent account. You can use this header to automate bulk updates or to administer a Subuser without changing the authentication in your code. You will use the parent account's API key when using this header.

7 status codes
201Batch ID success response.
batch_idstringoptional
A mail batch ID.
400Batch ID bad response.
errorsarray<object>optional
idstringoptional
When applicable, this property value will be an error ID.
401Batch ID unauthorized response.
errorsarray<object>optional
idstringoptional
When applicable, this property value will be an error ID.
403Batch ID forbidden response.
errorsarray<object>optional
idstringoptional
When applicable, this property value will be an error ID.
404Batch ID not found response.
errorsarray<object>optional
idstringoptional
When applicable, this property value will be an error ID.
405Get batch ID method not allowed response.
errorsarray<object>optional
idstringoptional
When applicable, this property value will be an error ID.
500Get batch ID internal server error response.
errorsarray<object>optional
idstringoptional
When applicable, this property value will be an error ID.

Error handling

A 400 is returned: Batch ID bad response. A 401 is returned: Batch ID unauthorized response. A 403 is returned: Batch ID forbidden response. A 404 is returned: Batch ID not found response. A 405 is returned: Get batch ID method not allowed response. A 500 is returned: Get batch ID internal server error response.