➿ Prevent Duplicates
When integrating with our API to automatically generate documents, it is important to consider the possibility of duplicate document creation.
This can occur in various scenarios, especially in asynchronous or retry-based workflows where the remote server may inadvertently repeat a request due to:
- Network timeouts or communication errors
- Server-side logic errors
- Retry mechanisms triggered without verifying previous outcomes
- Lack of idempotency in the integration logic
Why Duplicates Matter?Creating duplicate documents can lead to accounting inconsistencies, reporting mistakes and other issues with the tax authorities. Therefore, preventing duplicates is a critical part of building a robust integration.
Recommended Approach: Idempotency Keys
To address this, we recommend using idempotency keys in your API requests. An idempotency key is a unique identifier (e.g., UUID or hash) that you generate on the client side for each distinct operation.
When the same key is sent multiple times with the same request payload, the server ensures that the operation is only performed once, even if the request is received multiple times.
Methods -
Send in request parameters:
'request_reference'
Send a unique key
'prevent_duplicates = true'
The prevent duplicates mechanism is activated
Best Practices
- Always generate a new key for each unique action.
- Do not re-use keys across unrelated operations.
- You can store the keys and their associated results (if your client may need to reference them later).
- Implement retry logic only when appropriate, and ensure it respects the idempotency mechanism.
Updated 11 days ago