DocumentationAPI Reference
API ChangelogOpenAPI SpecStatus

Idempotence

The Persona API supports idempotency for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. For example, if a request to create an inquiry does not respond due to a network connection error, you can retry the request with the same idempotency key to guarantee that no more than one inquiry is created.

To perform an idempotent request, provide an additional Idempotency-Key header to the request.

Idempotency-Key: <key>

Persona's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key, regardless of whether it succeeded or failed. Subsequent requests with the same key return the same result, including 500 errors.

Keys are eligible to be removed from the system after they're at least 1 hour old, and a new request is generated if a key is reused after the original has been pruned. The idempotency layer compares incoming parameters to those of the original request and errors unless they're the same to prevent accidental misuse

All POST requests accept idempotency keys. Sending idempotency keys in GET and DELETE requests has no effect and should be avoided, as these requests are idempotent by definition.

Handling Errors with Idempotency Keys

In the event that you make API requests with reused idempotency keys and it results in an error, there will not be additional API logs beyond the initial failure. When a request first fails due to the reuse of an idempotency key, we log a 400 error in the API log. This log entry with the Idempotency error is only created on the first reuse of the idempotency key, like so:

{
  "errors": [  
    {  
      "title": "Idempotency error",  
      "details": "Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'abc_123' if you meant to execute a different request."  
    }  
  ]
}

This means that subsequent attempts with the same malformed or reused idempotency key will not generate additional log entries, helping to prevent log clutter and making it easier to diagnose and correct the initial issue.