Skip to content
Skip to main content

Scheduling messages to send in the future

Last updated:

The Nylas Messages API allows you to schedule messages to be sent in the future. This means you can draft a message in advance and schedule it to send when the time is just right, for example when you want to announce a new version of your product.

When you make a request to the Send Message endpoint, you can define your preferred send time (in seconds using the Unix timestamp format) in the send_at field.

If the user’s provider is Google or Microsoft, you can choose to store the scheduled message in their Drafts folder on the provider. In this case, you can schedule it to send any time in the future.

You can also choose to have Nylas store the message until its send time, which must be between 2 minutes and 30 days in the future.

Before you start scheduling messages, you need the following prerequisites:

  • A Nylas application.
  • A working authentication configuration. Either…
    • A Nylas Dashboard Sandbox application which includes a demonstration auth config, OR
    • A provider auth app (Google or Azure), and a connector for that auth app.
  • A Google or Microsoft grant with at least the following scopes:
    • Google: gmail.send
    • Microsoft: Mail.ReadWrite and Mail.Send

To schedule a message to be sent in the future, make a Send Message request that includes the send_at field, and provide the time (in Unix timestamp format) when you want the message to be sent. Nylas returns a schedule_id that you can use to reference the scheduled message.

The --schedule flag in the Nylas CLI accepts relative times ("in 2 hours", "tomorrow 9am") and absolute timestamps. See nylas email send for supported formats.

If you’re storing the message on Nylas, you can schedule it to be sent between 2 minutes and 30 days in the future. If you’re storing it on the provider, you can schedule it to be sent any time in the future.

To store the message as a draft on the provider, set use_draft to true.

Use a custom tracking hostname for a scheduled message

Section titled “Use a custom tracking hostname for a scheduled message”

Add tracking_options.domain_name to a scheduled send when you want rewritten links and tracking images to use an active organization-owned hostname. Register the hostname first by following the custom tracking hostname setup.

Nylas validates the hostname when it creates the schedule, so malformed, unowned, inactive, deleted, or blocked values fail synchronously with a generic 400 response. Nylas checks the normalized hostname again immediately before delivery because its ownership, certificate, or blocklist status can change while the message waits.

The execution path depends on the scheduled send family:

Scheduled send familyTracking and revalidation behavior
Grant-based message, including a provider-stored scheduled draftNylas injects tracking when it creates the schedule. Before the provider call, Nylas checks the custom hostname again without rewriting the tracking URLs a second time.
Pure Transactional SendNylas injects tracking when it creates the schedule. Immediately before the SES call, Nylas checks the custom hostname again without rewriting the tracking URLs a second time. The route domain remains the sender domain, and the body field remains the tracking hostname.
Agent Account message or draftNylas validates and stores domain_name when it creates the schedule. Inbox preserves the field during replay, then the normal send path checks the hostname again and injects tracking at execution.

Scheduled drafts follow the behavior for their provider family. If the hostname becomes inactive, is deleted, changes ownership, or is blocked before execution, the send fails through the existing asynchronous failure path. Nylas doesn’t fall back to its regional tracking hostname. Use the message.send_failed notification to monitor delivery failures.

If you want to schedule a message to be sent later, but you’re not quite set on what you want the content to be yet, you can schedule a draft. To do this, make a Send Message request that includes the send_at field, and specify "use_draft": true.

Nylas saves the message in the user’s Drafts folder until the defined send_at time.

You can edit a scheduled draft until 10 seconds before the defined send_at time. To do this, make an Update Draft request that includes the draft_id and the fields you want to modify.

If you want to update a draft’s scheduled send time, you must delete the schedule and create a new one.

You can make a Get Scheduled Messages request or use the Nylas SDKs to get information about all of your scheduled messages. Nylas returns a list of schedule instructions, including their schedule IDs and information about their status.

See nylas email scheduled list for full options. If you see a schedule instruction that you’re interested in, you can pass its schedule_id in a Get Scheduled Message request or using the Nylas SDKs to get information about it.

Sometimes, you might decide you don’t want to send a scheduled message. When this happens, make a Cancel Scheduled Message request at least 10 seconds before the send_at time.