Python v4 SDKs now identify themselves on every request and protect non-idempotent calls against accidental replay, matching the behavior introduced in C# v4 SDKs in July.
Details
Identification headers
Every request carries a User-Agent and the X-APIMatic-* headers that name the SDK, its version, the operating system and the Python runtime it is running on. The values are seeded at the lowest header layer, so a header you set yourself always wins.
Idempotency keys
Every non-GET request is sent with an Idempotency-Key header holding a UUID minted for that call, and the SDK reuses the same key on every retry of it. An API that honors the header can recognize a retried request and avoid applying it twice. Where an operation declares its own Idempotency-Key header parameter, the SDK sends the value you pass instead of minting one. You can also supply your own key for any call through extra_headers in request_options.
Example Request
A request sent by the SDK carries these headers with no setup:
POST /payments HTTP/1.1
User-Agent: PaymentsClient/1.0.0 Python
X-APIMatic-Lang: Python
X-APIMatic-Package-Version: 1.0.0
X-APIMatic-Gen-Version: 4.0.0
X-APIMatic-OS: Darwin 23.5.0 arm64
X-APIMatic-Runtime: CPython 3.13.14
Idempotency-Key: 6f1c2e8a-4b7d-4a39-9c1e-2f5d8b3a7c41
The first four values are fixed when the SDK is generated, and the OS and runtime are read from the host. A GET request carries the same identification headers but no Idempotency-Key.
This feature is available in the Python v4 SDK (beta). Generate it from the APIMatic CLI:
apimatic sdk generate --language=python --codegen-version=v4 --stability=beta
For the full set of flags and options, see the APIMatic CLI documentation.