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

# C# / .NET SDK

> Build C# and .NET 8 voice apps with the Vobiz SDK - outbound calls, SIP trunks, and VobizXML with native DI for global calling in 130+ countries.

The official C# SDK for the Vobiz Voice API. Make outbound calls, manage SIP trunks, handle phone numbers, and construct programmatic XML workflows natively within .NET Core / .NET 8 applications.

**Source code:** [vobiz-ai/Vobiz-Csharp-sdk](https://github.com/vobiz-ai/Vobiz-Csharp-sdk)

## Installation

Clone the SDK source into your solution directly:

```bash theme={null}
git clone https://github.com/vobiz-ai/Vobiz-Csharp-sdk.git
cd Vobiz-Csharp-sdk
dotnet build
```

## Authentication

The .NET SDK uses standard Dependency Injection (DI) to register your auth credentials with the container host.

```csharp theme={null}
using Microsoft.Extensions.Hosting;
using Vobiz.Client;
using Vobiz.Extensions;

var host = Host.CreateDefaultBuilder(args)
    .ConfigureApi((context, services, options) =>
    {
        options.AddTokens(new ApiKeyToken("YOUR_AUTH_ID", ClientUtils.ApiKeyHeader.X_Auth_ID, ""));
        options.AddTokens(new ApiKeyToken("YOUR_AUTH_TOKEN", ClientUtils.ApiKeyHeader.X_Auth_Token, ""));
    })
    .Build();
```

## Quick start

Fetch your account details:

```csharp theme={null}
using Microsoft.Extensions.DependencyInjection;
using Vobiz.Api;

var accountApi = host.Services.GetRequiredService<IAuthApi>();

var me = await accountApi.ApiV1AuthMeGetAsync(
    xAuthID: "YOUR_AUTH_ID",
    xAuthToken: "YOUR_AUTH_TOKEN",
    contentType: "application/json"
);

Console.WriteLine(me.StatusCode);
```

For real-time call control, inject the `ICallApi` interface and pass your webhook URLs to manage outbound dial states.

## VobizXML module

The SDK includes a fluent XML builder under `Vobiz.Xml` that is natively mapped to the official schema types. Chain elements together and emit the generated string from your API controllers.

```csharp theme={null}
using Vobiz.Xml;

var response = new ResponseElement()
    .AddSpeak("Welcome to Vobiz.", voice: "WOMAN", language: "en-US")
    .AddWait(length: 2)
    .AddHangup();

var xml = response.ToString(pretty: true);
Console.WriteLine(xml);
```

## Common operations

### Queued network polling

```csharp theme={null}
var callApi = host.Services.GetRequiredService<ICallApi>();

var response = await callApi.ApiV1AccountAuthIdCallGetAsync(
    authId: "YOUR_AUTH_ID",
    xAuthID: "YOUR_AUTH_ID",
    xAuthToken: "YOUR_AUTH_TOKEN",
    contentType: "application/json",
    status: "queued"
);

Console.WriteLine(response.StatusCode);
```

### Gather input orchestration

```csharp theme={null}
using Vobiz.Xml;

var gather = new GatherElement(
    action: "https://example.com/gather",
    method: "POST",
    inputType: "speech",
    executionTimeout: 15
).AddSpeak("Say sales or support").AddPlay("https://example.com/menu.mp3");

var response = new ResponseElement().Add(gather);
Console.WriteLine(response.ToString(false));
```

## Resources

* [GitHub repository](https://github.com/vobiz-ai/Vobiz-Csharp-sdk)
* [Vobiz Console](https://console.vobiz.ai)
* [API documentation](/introduction)
* [VobizXML reference](/xml/response)
