PlatformXeDocs
Get API Key

Email Queue

How the persistent retry queue and dead-letter queue work.

When every route fails at send time, the email enters the PlatformXe persistent retry queue (the send answers queued: true). The queue retries it on a lengthening delay, so a short outage is ridden out without overwhelming the routes.

Backoff schedule

RetryDelay after the previous attempt
130 seconds
21 minute
35 minutes
415 minutes
51 hour
64 hours
724 hours

After 7 failed retries the email moves to the dead-letter queue and is no longer retried. A retry that every route refuses as sent (an invalid recipient, for example) is dead-lettered at once: no later attempt would be accepted.

An email sent by a retry is counted in your email usage, as it would have been had the first send succeeded: against the organisation the first send would have been counted to.

A retry held by the sending limits (too many emails to the recipient this hour, or the same subject today) is not a failed attempt: the email waits until the limit frees a place and is then tried again, with its retries unchanged.

One queued copy per email

A repeat of an email that is already waiting in the queue is not stored again: the send answers queued: true with deduplicated: true, and the queued email is sent once. Only your own identical email counts (same caller service and organisation, recipients, subject and content). A queued copy that is being retried right now, or that has one retry left, never absorbs a repeat: the repeat is queued on its own, with its own retries. See Duplicate sends while queued.

Dead-letter queue

Emails in the dead-letter queue have exhausted all retry attempts. These typically indicate a persistent issue such as:

  • Invalid recipient address (hard bounce)
  • Recipient mailbox full (soft bounce that never resolved)
  • All providers in the fallback chain are down for an extended period

An email whose retry was cut off part-way (the processing run stopped before it recorded the result) is picked up again by a later scheduled run, after at least 15 minutes, so it is never left unsent. The cut-off attempt counts as one of its attempts: an email whose retries are cut off again and again is dead-lettered after the same number of attempts as any other. If the cut-off run had already handed the email to a route, it can be delivered twice. Emails the cut-off run had taken but not yet tried are not charged an attempt: they are retried at once.

Dead-lettered emails are counted as deadLetter in the queue statistics below, and each failed attempt is recorded in the message log.

Queue statistics

Retrieve the current queue counts to monitor delivery health. The counts are your organisation's emails only: a key reads the queue of the organisation it belongs to, across all of its caller services, and never another organisation's. (A PlatformXe platform key, which has no organisation, reads the whole queue.)

GET /api/v1/messaging/queue/stats

Scope: messaging:send

Response

{
  "success": true,
  "data": {
    "pending": 12,
    "processing": 0,
    "sent": 4821,
    "deadLetter": 1
  }
}
FieldDescription
pendingEmails waiting for their next retry
processingEmails a retry run is sending now
sentEmails sent by a retry
deadLetterEmails that used up their retries, or were refused by every route on a retry

Email health

GET /api/v1/messaging/email/health

Scope: messaging:send

The email routes in the order they are tried, each with its circuit-breaker state, and the same queue counts, scoped the same way, under queue. Each route is named by its position in the chain (primary, fallback_1, fallback_2, ...), the label a send answers in its provider field. (A PlatformXe platform key reads the route names.)

{
  "success": true,
  "data": {
    "providerOrder": ["primary", "fallback_1", "fallback_2"],
    "providers": {
      "primary": { "configured": true, "state": "CLOSED", "failures": 0, "position": 1 },
      "fallback_1": { "configured": true, "state": "OPEN", "failures": 5, "position": 2 },
      "fallback_2": { "configured": true, "state": "CLOSED", "failures": 0, "position": 3 }
    },
    "queue": { "pending": 12, "processing": 0, "sent": 4821, "deadLetter": 1 }
  }
}
FieldDescription
configuredThe route is set up
stateCLOSED: in use; OPEN: skipped after repeated failures; HALF_OPEN: being tried again
failuresConsecutive failures
positionIts place in the order, from 1

Manual queue processing

The queue processes automatically on a schedule; you do not need to trigger it. Manual processing is for PlatformXe's own operators after an incident: the queue holds every organisation's emails, so the endpoint takes platform keys only.

POST /api/v1/messaging/queue/process

Scope: messaging:send, on a platform key (one with no organisation). A key with an organisation is answered 403 FORBIDDEN.

Body (optional): { "batchSize": 20 }: how many due emails to process, a positive integer (default 20; at most 100 are processed in one call). Another value is 400 BAD_REQUEST.

Response

{
  "success": true,
  "data": {
    "processed": 15,
    "sent": 13,
    "failed": 2,
    "deadLettered": 0
  }
}

failed counts the emails not sent in this run and left for a later retry: a failed attempt, or one the sending limits held (not charged an attempt).