Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: clarify cancel and pause capabilities for scheduled sends #1100

Merged
merged 4 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/use-cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This documentation provides examples for specific Twilio SendGrid v3 API use cas
* [Attachments](attachments.md)
* [Customization Per Recipient](customization.md)
* [Manually Providing Content](manual-content.md)
* [Specifying Time to Send At](time-to-send.md)
* [Scheduled Send](scheduled-send.md)
* [Specifying Custom Headers](custom-headers.md)
* [Specifying Categories](categories.md)
* [Timeout](timeout.md)
Expand Down
38 changes: 38 additions & 0 deletions docs/use-cases/scheduled-send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Creating a Scheduled Send

Use the `sendAt` property to specify when to send the emails (in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) seconds, not milliseconds):

```js
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello delayed email',
html: '<p>Some email content</p>',
sendAt: 1500077141,
};

await sgMail.send(msg);
```

## Limitations

1. Emails can only be scheduled, at most, 72 hours in advance.
2. If successful, without a `batchId` set, the call to `sgMail.send()` returns a 202 status code with an empty response body. Currently, cancelling a scheduled email without a `batchId` set [requires a change of password or contacting our support team](https://sendgrid.com/docs/for-developers/sending-email/stopping-an-in-progress-send/#stopping-transactional-email).

## [To Cancel or Pause Your Scheduled Send](https://sendgrid.com/docs/for-developers/sending-email/stopping-a-scheduled-send/#canceling-transactional-email):

1. Create a [Batch ID](https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/client/USAGE.md#create-a-batch-id).
2. Assign Batch ID to a `msg` object:
```js
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello delayed email',
html: '<p>Some email content</p>',
sendAt: 1500077141,
batchId: 'YOUR_BATCH_ID'
};

await sgMail.send(msg);
```
3. [Update your Batch ID](https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/client/USAGE.md#post-userscheduled_sends) with a `cancel` or `pause` status.
20 changes: 0 additions & 20 deletions docs/use-cases/time-to-send.md

This file was deleted.