Pub/Sub push subscription for Sume events: ack codes and dedupe

Pub/Sub push redelivers on any code outside 102, 200, 201, 202 and 204. Fan Sume completions through Pub/Sub safely with run_id and job_id dedupe.

5 min readSume
All posts

If you relay Sume completions into Google Pub/Sub, remember that a push subscription resends any message unless your endpoint answers with 102, 200, 201, 202 or 204, and that the per-message deadline cannot be modified. So the consumer must be idempotent: dedupe on job_id for job events and on run_id for run events. Sume itself retries up to 10 times, so duplicates can occur at two layers.

Pub/Sub push rules

From Google's push documentation:

Pub/Sub push behaviour (read 2026-10-02)
TopicFact
Success codes102, 200, 201, 202, 204
Other codes or deadline expiryMessage is resent
Ack deadline for pushCannot be modified per message
AuthenticationJWT in the Authorization header

Two retry layers, one dedupe key

Sume delivers to a public HTTPS URL and treats a non-2xx or a timeout as a failed attempt. If that URL is a small relay that publishes to a topic, a slow publish can make Sume retry after the message was already published. Downstream, Pub/Sub may then resend to your subscriber.

The key is stable across both layers: job_id for job.completed, job.failed and job.canceled, and run_id or request_id for format.run.terminal, action.run.terminal and agent.run.terminal. Insert it under a unique constraint and ignore conflicts.

Design checklist

Keep the relay and the consumer separate.

  • Relay: verify the Sume HMAC, publish the raw body plus timestamp, return 200 fast.
  • Consumer: check the Pub/Sub JWT, dedupe on the Sume id, then act.
  • Do not return a non-success code for an already-seen id; return 200 so the message is acknowledged.
  • Large run receipts arrive with payload: null and payload_too_large; fetch result_url.

Polling as the backup

Pub/Sub is not a replacement for reading the source of truth. If a message is lost or the subscriber was down for longer than your retention, call GET /v1/jobs/:id/status or /v1/format-runs/:id/status using the ids you stored at create time. Redelivery is also available: POST /v1/jobs/{id}/webhook/redeliver with jobs:write, and POST /v1/format-runs/{id}/webhook/redeliver with formats:write.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume