> ## Documentation Index
> Fetch the complete documentation index at: https://leadping.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Use the .NET SDK

> Install the Leadping .NET SDK, configure API authentication with a Kiota request adapter, and follow an example to retrieve a lead using typed API routes.

* Package: [`Leadping.OpenApiClient`](https://www.nuget.org/packages/Leadping.OpenApiClient)
* Repository: [`leadpingai/leadping-dotnet`](https://github.com/leadpingai/leadping-dotnet)

## Install

```bash theme={null}
dotnet add package Leadping.OpenApiClient
dotnet add package Microsoft.Kiota.Http.HttpClientLibrary
```

## Prepare the example

Use a console application compatible with the installed SDK and place the example in `Program.cs`. It uses top-level statements and collection expressions. Set `LEADPING_API_KEY` in the application environment and replace `lead-id` with an existing record in that organization.

The request below is read-only. Run it with `dotnet run` from the application directory after adding the packages.

## Create the client

```csharp theme={null}
using Leadping.OpenApiClient;
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;

var credential = Environment.GetEnvironmentVariable("LEADPING_API_KEY")
    ?? throw new InvalidOperationException("LEADPING_API_KEY is not set.");

var authProvider = new ApiKeyAuthenticationProvider(
    $"Bearer {credential}",
    "Authorization",
    ApiKeyAuthenticationProvider.KeyLocation.Header,
    ["api.leadping.ai"]);
var client = new LeadpingOpenApiClient(new HttpClientRequestAdapter(authProvider));
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var lead = await client.Leads["lead-id"].GetAsync(cancellationToken: timeout.Token)
    ?? throw new InvalidOperationException("Leadping returned no lead.");
Console.WriteLine(lead.Id);
```

The client defaults to `https://api.leadping.ai`. Set `LEADPING_API_KEY` to an organization API key. `client.Users.Me` requires a user access token; source keys are only for lead intake.

The SDK does not store or refresh credentials. See [API Authentication](https://leadping.ai/docs/api-authentication.md).

## Call routes

```csharp theme={null}
var source = await client.Sources["source-id"].GetAsync();
```

Use generated request-body and model classes from `Leadping.OpenApiClient` when creating or updating records. Confirm endpoint contracts in the [API Reference](https://leadping.ai/docs/api-reference.md), and handle `429` responses using the [rate-limit guide](https://leadping.ai/docs/rate-limits.md).

## Use in a hosted service

Manage the HTTP client and request adapter with your application’s service lifetime, and pass the job or HTTP request’s cancellation token to SDK methods. Cancellation of a write stops your wait; it does not prove that Leadping rolled back the operation.

Keep API failures visible to your application’s error handler. Distinguish an HTTP error from a null optional property, and review the adapter’s retry middleware before adding retries around write calls.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.