idempotencyKey twice, the second request will not create a new task run.
idempotencyKey option
You can provide an idempotencyKey to ensure that a task is only triggered once with the same key. This is useful if you are triggering a task within another task that might be retried:
idempotencyKeys.create SDK function to create an idempotency key before passing it to the options object.
We automatically inject the run ID when generating the idempotency key when running inside a task by default. You can turn it off by passing the scope option to idempotencyKeys.create:
idempotencyKeys.create SDK function to create an idempotency key.
idempotencyKey option, without first creating it with idempotencyKeys.create.
Make sure you provide sufficiently unique keys to avoid collisions.
idempotencyKey when calling batchTrigger as well:
idempotencyKeyTTL option
The idempotencyKeyTTL option defines a time window during which a task with the same idempotency key will only run once. Here’s how it works:
- When you trigger a task with an idempotency key and set
idempotencyKeyTTL: "5m", it creates a 5-minute window. - During this window, any subsequent triggers with the same idempotency key will return the original task run instead of creating a new one.
- Once the TTL window expires, the next trigger with that idempotency key will create a new task run and start a new time window.
By default idempotency keys are stored for 30 days. You can change this by passing the idempotencyKeyTTL option when triggering a task:
idempotencyKeyTTL option:
sfor seconds (e.g.60s)mfor minutes (e.g.5m)hfor hours (e.g.2h)dfor days (e.g.3d)

