Idempotency feature is currently not enabled for all organizations. Please contact us at [email protected] to enable it for your organization.
How It Works
When you send a request with an idempotency key:- Novu checks if a request with the same key has been processed before
- If it’s a new key, the request is processed normally and the response is cached
- If the key was seen before, Novu returns the cached response without reprocessing the request
Trigger events and billing
OnPOST /v1/events/trigger, idempotency keys are enforced at the API layer before the request is queued. If you send 100 requests with the same Idempotency-Key, only the first is processed. Once that request completes, subsequent requests receive the cached response and count as one workflow run toward billing. While the first request is still in progress, duplicates receive a 409 Conflict response and are not queued.
This differs from the optional transactionId request field, which is checked for uniqueness during trigger processing rather than at the API boundary. transactionId is useful for tracing and cancellation, but it does not provide the same deduplication or billing protection as an idempotency key. For safe retries, always prefer Idempotency-Key. See the Trigger event API reference and Trigger concepts page for details.
Using Idempotency Keys
To make an idempotent trigger request, pass a unique idempotency key with your request:- Node.js
- Python
- Go
- PHP
- .NET
- Java
- cURL
Key Requirements
- Maximum length: 255 characters
- Uniqueness: Keys should be unique per organization
- Format: Any string value (UUIDs are recommended)
We recommend using UUIDs or other unique identifiers that include context about the operation, such as
order-confirmation-{orderId}-{timestamp}.Supported Methods
Idempotency is supported for the following HTTP methods:GET, PUT, and DELETE methods are inherently idempotent by design and don’t require idempotency keys.
Authentication Requirements
Idempotency is only available when authenticating with an API Key. Include theAuthorization: ApiKey <NOVU_SECRET_KEY> header, as shown in the cURL tab above.
Requests using other authentication methods will be processed normally without idempotency support.
Cache Duration
After the cache expires, the same idempotency key can be reused.
HTTP Response Headers
When making idempotent requests, Novu includes helpful headers in the response:Idempotency-Key
Confirms the idempotency key that was used for the request:Idempotency-Replay
Indicates that the response was served from the cache rather than processing a new request:Error Handling
Request In Progress (409 Conflict)
If you send a request with an idempotency key while a previous request with the same key is still being processed:Retry-After header indicating when to retry:
Key Reused with Different Body (422 Unprocessable Entity)
If you send a request with an idempotency key that was previously used with a different request body:Key Too Long (400 Bad Request)
If the idempotency key exceeds 255 characters:Best Practices
- Generate unique keys: Use UUIDs or combine entity IDs with timestamps to ensure uniqueness
- Store keys: Keep track of idempotency keys you’ve used in case you need to retry requests
- Handle 409 responses: Implement retry logic with exponential backoff when you receive a conflict response
- Don’t reuse keys for different operations: Each unique operation should have its own idempotency key
- Include meaningful context: Consider including the operation type and relevant IDs in your key for easier debugging