Schedule an email

Send a transactional email at a set time, up to 7 days ahead, such as a reminder the day before a trial ends. PostHog holds the email and sends it at that time. Scheduling works on PostHog Cloud, US and EU.

Send it later

Add scheduled_at to a send (scheduledAt or ScheduledAt in some SDKs). It works on both kinds of send: an email from your code with template_key, and a template in PostHog with template_id.

const { data, error } = await posthog.emails.send({
to: "ada@example.com",
templateKey: "trial-ending",
subject: "Your trial ends tomorrow",
html,
distinctId: "user_123",
idempotencyKey: "trial-ending-8f14e45f",
scheduledAt: reminderAt,
})

In the REST example, replace <time_in_the_next_7_days> with a time in the next 7 days when you run it, with a UTC offset, in the format YYYY-MM-DDThh:mm:ssZ.

The time needs a UTC offset:

  • In the API: an ISO 8601 time, such as 2026-12-10T09:00:00Z or 2026-12-10T10:00:00+01:00. Seconds and their fraction are optional.
  • In the SDKs: your language's date and time type with a time zone, such as a datetime with tzinfo in Python, a time.Time in Go, or a DateTimeOffset in .NET. Most SDKs also take an ISO 8601 string with an offset.

PostHog keeps the time to the millisecond, and rounds a finer time up to the next millisecond, so the email never goes out early. A time that has already passed sends the email now.

Work out the time once, from data you store, such as when the trial ends. Then send the same time with the same idempotency key on every retry. The key covers the time, so the same key with a different time gets 422 idempotency_key_reused.

The response

PostHog returns 202 with a message ID, as for any send, and two more fields:

JSON
{
"message_id": "0192a4c8-5b2e-7d3f-8a1c-2e4f6b8d0a1c",
"replayed": false,
"status": "scheduled",
"scheduled_at": "2026-12-10T09:00:00Z"
}

statusWhat it means
scheduledThe email waits for scheduled_at.
queuedThe time had already passed, so the email goes out now. scheduled_at is null.

The SDKs check that PostHog confirmed the time. Their result has the confirmed time, or no time when the email goes out now.

A status lookup returns scheduled until the time comes. Then it moves through the usual statuses, such as sent and delivered.

PostHog checks the email again before it goes out, such as its recipient. An email that fails a check doesn't go out, and its status is failed, with a reason.

Limits

  • 7 days ahead. A time more than 7 days after the request gets 400 scheduled_too_far.
  • PostHog Cloud only. The SDKs schedule only through https://us.posthog.com or https://eu.posthog.com. On any other host, such as a self-hosted PostHog, a reverse proxy, or a custom domain, they send nothing and return scheduling_requires_cloud.
  • No changes after you send. You can't cancel, move, or list scheduled emails yet. A send with the same idempotency key and a new time doesn't move the email.
  • One email at a time. A batch send doesn't take scheduled_at. Schedule each email with its own send.

Errors

Scheduled sends can get the same errors as any other send. See retries and errors. These codes are only for scheduled sends:

CodeFromWhat to do
scheduled_too_farPostHog, 400Send a time at most 7 days ahead.
A field code, with attr set to scheduled_atPostHog, 400Send an ISO 8601 time in the next 7 days, with a UTC offset, in the format YYYY-MM-DDThh:mm:ssZ.
invalid_scheduled_atSDKsSend a real date and time with a UTC offset. The SDK sends nothing.
scheduling_requires_cloudSDKsSend through PostHog Cloud. The SDK sends nothing.
schedule_not_confirmedSDKsPostHog accepted the email but didn't confirm its time, so it can go out at another time. The error has the message ID. Read its status before you send it again. If you send it again, use the same idempotency key and the same request, within 24 hours. If the SDK made the key, don't send it again.

Still have questions?

Was this page useful?