Validate batch ID
Using the Cancel Scheduled Sends API, you can cancel or pause sending one or more groups of emails. SendGrid defines these multiple scheduled send requests together as batches identified with a batch_id
.
With this API, you can perform the following tasks on scheduled emails:
- Define and validate the ID for a batch of messages.
- Retrieve, update, pause, resume, or cancel a scheduled send.
Cancelling or pausing a batch of messages include the following conditions:
- You can't pause or cancel more than 10 different batches at one time.
- You can't pause or cancel a batch later than 10 minutes before the scheduled
send_at
time. - When you cancel or pause a batch, all messages associated with that batch stay in your sending queue.
- When a cancelled batch reaches its
send_at
time, SendGrid discards the messages. - When a paused batch reaches its
send_at
time, SendGrid retains the messages. When you resume a paused batch, SendGrid delivers your scheduled send. - When a paused batch passes 72 hours after its
send_at
time, SendGrid discards the messages as Expired.
To cancel a scheduled send of a single message, consult Canceling a Scheduled Send.
GET/v3/mail/batch/{batch_id}
Base url: https://api.sendgrid.com (for global users and subusers)
Base url: https://api.eu.sendgrid.com (for EU regional subusers)
This operation allows you to validate a mail batch ID.
If you provide a valid batch ID, this operation will return a 200
status code and the batch ID itself.
If you provide an invalid batch ID, you will receive a 400
level status code and an error message.
A batch ID does not need to be assigned to a send to be considered valid. A successful response means only that the batch ID has been created, but it does not indicate that the ID has been assigned to a send.
Bearer <<YOUR_API_KEY_HERE>>
Optional
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.
Set this parameter to the batch ID that's associated with the mail send you want to retrieve.
Batch ID success response.
Optional
A mail batch ID.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const batch_id = "batch_id";56const request = {7url: `/v3/mail/batch/${batch_id}`,8method: "GET",9};1011client12.request(request)13.then(([response, body]) => {14console.log(response.statusCode);15console.log(response.body);16})17.catch((error) => {18console.error(error);19});