Solvimon supports idempotency which allows for requests to be retried while ensuring only one of those requests will take effect. This means that when using idempotency, the API will not perform the same operation more than once when the same request is sent. In the scenario where a connection error occurs, the request can be repeated, knowing that there is no risk of performing the same operation again.
How the Idempotency-Key is generated is up to the sender. Solvimon advises using V4 UUIDs, or any other method such that collisions of keys are unlikely. The maximum length of an Idempotency-Key is 255 characters.
Idempotency is handled the same way for all resources except for event handling.
Solvimon implements idempotency in two forms. Namely:
When using the events end-point, idempotency is enforced by the unique resource reference. This is achieved by adding a unique identifier value in the reference field of an event object for a POST request. See an example below:
If multiple requests with the same reference is sent to the events end-point, a 201 Created response will be returned for each of them. However, only one of those created events will take effect. To get notified that duplicate requests with the same reference as been sent, a Webhook can be configured in Solvimon.
When requests to the events end-point are unsuccessful, the usual status code and response messages will be returned. These unsuccessful requests do not affect idempotency.
Using the unique reference of events for idempotency is only accessible when actively choose to opt-in.
To use idempotency in the Solvimon API that applies to all end-points except events, an Idempotency-Key can be added to the header of an API request. Although not mandatory, Solvimon advises the use of an Idempotency-Key in a POST request.
An idempotent request can be performed by adding Idempotency-Key: UNIQUE ID to the header of a POST request. Idempotent requests are allowed for all Solvimon API users. Idempotency-Keys for different API users will be treated as a unique key.
When the Idempotency-Key was used in a previous request, and the hash of the resubmitted request message is the same as the previous request, the response of the previous request will be returned. To indicate that an idempotent request was returned, the Idempotent-Replayed key in the header is set:
An idempotency key is stored for a maximum of 48 hours after which it expires. A new submission of the same key value will lead to a new request being processed.
When using the same Idempotency-Key, Solvimon guarantees that processing is idempotent. Additionally, depending on the scenario, it might be safe to retry a request with a new idempotency key. If this is possible, the Idempotency-Retryable header will be true.
A request is retryable if theIdempotency-Retryable header istrue
Not always retryable
Idempotency-Retryable header is set and is true. If not, check with Solvimon to continue processing.Safe to retry, use the same Idempotency-Key:
If, by any chance, a server-side error occurs, we might return one of two responses:
Idempotency-Retryable=true: this means we have not yet stored the event in our database and the request can safely be retried.Idempotency-Retryable=false (or header/value not available): we have already stored the event in our database and also stored the idempotency cache. This means that retrying it with the same key will result in the same 500 responses. When this happens, retrying will have no effect. In such a case, contact Solvimon. Depending on the cause of the error, we can continue processing and/or determine whether it’s safe to resend the same request with a new Idempotency-Key.When a request has already been processed successfully and is resent with the same Idempotency-Key , we will return the same response as when the request was first processed. Additionally, we will return a Idempotency-Replayed header to indicate that the request has already been processed. This request can be retried and will return the same result each time.
A request to our API will be validated before we process it. This validation can fail for multiple reasons, e.g:
For 4xx status codes, it is safe to retry this request with the sameIdempotency-Key
When a request is changed but an existing Idempotency-Key is used, the server will return a 409 conflict response. It is safe to retry this and will result in the same 409 conflict response.
When a request is retried with the same Idempotency-Key but the previous request has not finished processing yet, we will return a 422 Unprocessable Entity status code. It is safe to retry this request. When the request hasn’t finished processing yet we will again return a 422 status code. If it has finished, we will return the result of the processing.
When one of our APIs or other components is temporarily unavailable, a request might get a 503 response. This can always be retried with the sameIdempotency-Key
Additionally, when the idempotency layer itself is unavailable, we will return a 503 status code with a Transient-error header. This request can also be retried with the sameIdempotency-Key