# Getting Started

## Setup

The official .NET SDK for Stream covers Chat, Video, Moderation, and Feeds.

|        |                                                                                  |
| ------ | -------------------------------------------------------------------------------- |
| GitHub | [github.com/GetStream/getstream-net](https://github.com/GetStream/getstream-net) |
| NuGet  | [nuget.org/packages/getstream-net](https://www.nuget.org/packages/getstream-net) |

Install the SDK:

```bash
dotnet add package getstream-net
```

Initialize the client with your API key and secret (available on the [Dashboard](https://dashboard.getstream.io/)):

```csharp
using GetStream;

var client = new StreamClient("your-api-key", "your-api-secret");
```

Or use the builder with environment variables (`STREAM_API_KEY`, `STREAM_API_SECRET`):

```csharp
var client = new ClientBuilder().Build();
```

## Server-side Token

Your backend generates a user token that the client SDKs use to authenticate. A typical place to issue this token is during login or registration.

```csharp
var token = client.CreateUserToken("user-id");
// return the token to the client app
```

Tokens with an expiry:

```csharp
var token = client.CreateUserToken("user-id",
    expiration: TimeSpan.FromHours(24));
```

## Making Your First API Call

Create a user, open a channel, and send a message:

```csharp
using GetStream.Models;

// Upsert a user
await client.UpdateUsersAsync(new UpdateUsersRequest
{
    Users = new Dictionary<string, UserRequest>
    {
        ["john"] = new UserRequest { ID = "john", Name = "John" }
    }
});

// Create or join a channel
var chat = new ChatClient(client);
await chat.GetOrCreateChannelAsync("messaging", "hello-world",
    new ChannelGetOrCreateRequest
    {
        Data = new ChannelInput { CreatedByID = "john" }
    });

// Send a message
await chat.SendMessageAsync("messaging", "hello-world",
    new SendMessageRequest
    {
        Message = new MessageRequest
        {
            Text = "Hello, Stream!",
            UserID = "john"
        }
    });
```


---

This page was last updated at 2026-03-13T13:15:52.128Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/dotnet-csharp/](https://getstream.io/chat/docs/dotnet-csharp/).