home

Indirect Tax

Sovos Docs

Idempotent requests

The Indirect Tax API supports idempotency, which lets you safely retry requests without accidentally repeating the same operation.

Idempotent requests are particularly useful when an API call is interrupted and the client doesn't receive a response. For example, suppose there's a POST request to send a Standard Business Document (including an invoice) for clearance. If the request doesn't respond due to a network connection error, the Indirect Tax API lets you retry the request with the same idempotency key, which prevents the invoice from being issued twice.

The idempotency key is a unique value generated by the client application, which the server uses to recognize subsequent retries of the same request. To make an idempotent request using the Indirect Tax API, you must add an additional x-idempotency-Key header to the request.
Important:

How you create unique keys is up to you, but we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. Idempotency keys are up to 255 characters long.

When customers use the idempotency key for the first time in a request, the Indirect Tax API saves the resulting status code and body for 24 hours, whether the request succeeded or failed. This means that subsequent requests with the same key always return the same result, including the errors. After 24 hours, the Indirect Tax API generates a new request for the same idempotency key.

Request results are only saved if a Indirect Tax API endpoint started executing. If a customer retries a request with the same idempotency key before the original request completes, they'll get a 409 error. If incoming parameters failed validation, no idempotent result is saved, as no API endpoint began execution. This means that it's safe to retry these requests.

All POST and PATCH requests accept idempotency keys. Don't send idempotency keys using other methods, as they are idempotent by definition.

Request sample

curl --location --request POST 'https://api-test.sovos.com/v1/documents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer gnE...nEv' \
--header 'x-correlationId: 057b5a5e-520c-4ea0-a948-9d583b4d121c' \
--header 'x-idempotency-Key: 4b27cc7f-1e8d-4b3b-9423-282c0768e4ef' \
--data-raw '{
  "data": "PD94b...VudD4=",
  "dataEncoding" : "base64"
}'