Skip to main content

SDK Identification Headers and Automatic Idempotency Keys in C# v4 SDKs (Beta)

· 3 min read

Generated C# v4 SDKs now identify themselves on every API call. Each request carries a short User-Agent plus a set of structured X-APIMatic-* headers, and non-GET requests automatically include a retry-safe Idempotency-Key.

What's New?

Previously, v4 C# SDKs sent no identification headers, so API providers had no reliable way to attribute incoming traffic to the SDK, its version, the generator, or the runtime it ran on. Generated SDKs now send this information on every request as clean, machine-parseable headers.

SDK identification headers

Every request now includes a short, human-readable User-Agent alongside structured X-APIMatic-* headers, so providers can query attribution by language, version, OS, and runtime as separate fields rather than parsing one packed string.

HeaderExampleSource
User-AgentPaymentClient/1.0.0 CSharpbaked (per client)
X-APIMatic-LangCSharpbaked
X-APIMatic-Package-Version1.0.0baked (per client)
X-APIMatic-Gen-Version4.0.0baked (generator)
X-APIMatic-OSMicrosoft Windows 10.0.x X64runtime
X-APIMatic-Runtime.NET 8.0.4runtime

Baked values are rendered as literal constants at generation time, so they cost nothing at runtime. The OS and runtime values resolve once at client construction and are reused for the client's lifetime.

Automatic, retry-safe Idempotency-Key

Non-GET requests now include an Idempotency-Key header. The SDK mints a UUIDv4 once per logical request and reuses the same key across every retry, so the server can safely detect and drop duplicate retried calls. GET requests are left untouched.

The caller always wins

Consumer-supplied and per-request headers override the generated defaults by key (case-insensitive). If you pass your own User-Agent, any X-APIMatic-* header, or your own Idempotency-Key, the SDK uses yours instead of generating one. If the API spec already declares its own Idempotency-Key, the SDK doesn't add one.

Why This Matters

  • Clean attribution for providers. API providers can attribute traffic to the SDK, its version, the generator, and the runtime using discrete headers they can query, instead of guesswork.
  • Safer retries out of the box. Automatic, retry-stable idempotency keys let servers detect and drop duplicate retried non-GET requests without any extra work from the consumer.
  • No configuration required. The headers are sent automatically with fixed names, and consumers retain full control by overriding any header per request.

This feature is available in the C# v4 SDK (beta). Generate it from the APIMatic CLI:

apimatic sdk generate --language=csharp --codegen-version=v4 --stability=beta

For the full set of flags and options, see the APIMatic CLI documentation.