C# Getting Started
This guide walks you through installing the Kard .NET SDK, authenticating with the Kard API, and making your first request.
KARD_CLIENT_ID and KARD_CLIENT_SECRETImport and instantiate the KardClient using your credentials.
If KARD_CLIENT_ID and KARD_CLIENT_SECRET are set in your runtime environment, the SDK will automatically use them, so you can initialize the client without passing credentials explicitly.
The client automatically handles authentication, retries, and timeouts.
You can configure a custom base URL by setting BaseUrl on ClientOptions.
1. Creating a User:
To enhance offer targeting and attribution, you can include a hashed email (HEM) when creating users. The SDK includes a built-in Hem.GenerateHEM utility that normalizes and hashes email addresses:
The function normalizes the email before hashing (removes whitespace, lowercases, and handles Gmail-specific rules like dot and + suffix removal). It throws an ArgumentException for invalid inputs.
2. Fetching Offers for User with Extended API:
3. Submitting Transaction for User:
All SDK methods return typed responses and throw typed errors.
If an API request fails (4xx or 5xx), the SDK throws a KardApiException.
Retries are enabled by default (max 2 attempts) with exponential backoff. The SDK retries on status codes 408, 429, and 5xx. Configure with the MaxRetries request option:
The SDK defaults to a 30 second timeout. Override it with the Timeout request option.
Use the AdditionalHeaders request option to send extra headers.
Use the AdditionalQueryParameters request option to send extra query params.
To inspect status codes, headers, or the URL, use .WithRawResponse().
This SDK uses forward-compatible enums that handle unknown values gracefully.