# Make a call with .NET SDK

This guide shows how to make a Text-to-speech phone call in a .NET application using the Voice API and .NET SDK.

Note:
Before you can get started, you need the following already set up:

- Set all Voice API [configuration settings](/docs/voice/getting-started).
- [ASP.NET Core 7.0](https://dotnet.microsoft.com/en-us/download/) or later SDK and ASP.NET Core Runtime and a familiarity with how to create an app.
- A mobile handset that can receive phone calls.


## Step 1. Set up your ASP.NET Core application

Create a new project folder and open a command prompt. Execute the following command to create a new ASP.NET Core console application:

```shell
dotnet new console
```

This creates a new console application and project.

The easiest way to install the SDK is using the [`dotnet` CLI](https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net70):

1. Open a command prompt or terminal to the local repository folder.
2. Execute the following command:

```shell
dotnet add package Sinch
```


### Modify your application

In your project folder, open the `Program.cs` file and paste the provided "Program.cs" code into the file, replacing all the existing content.

Program.cs
```cpp Program.cs
// Use this code to make a Text-to-speech phone call using the Voice API and .NET SDK. 
using System.Text.Json;
using Sinch;
using Sinch.Voice.Callouts.Callout;

var sinch = new SinchClient("YOUR_access_key", 
                            "YOUR_access_secret", 
                            "YOUR_project_id");

var voice = sinch.Voice("YOUR_application_key", "YOUR_application_secret");

CalloutResponse response = await voice.Callouts.Tts(new TextToSpeechCalloutRequest{
    Destination = new Destination{
        Type = DestinationType.Number,
        Endpoint = "YOUR_phone_number"
    },
    Text = "This is a Text to speech callout to test the Sinch dotnet Voice SDK."
});
    
Console.WriteLine(JsonSerializer.Serialize(response, new JsonSerializerOptions()
{
    WriteIndented = true
}));
```

The code provided includes placeholder parameters. You'll need to update the parameters detailed in the following subsections with your values.

#### Initialize the client

To start using the Voice API with the SDK, you need to initialize the main client class with your credentials from your Sinch [dashboard](https://dashboard.sinch.com) and additionally create a Voice client object that uses your [Voice app credentials](https://dashboard.sinch.com/voice/apps).

Note:
For testing purposes on your local environment it's fine to use hardcoded values, but before deploying to production we strongly recommend using environment variables to store the credentials.

```cpp Initialize client
using Sinch;

var sinch = new SinchClient("YOUR_access_key", 
                            "YOUR_access_secret", 
                            "YOUR_project_id");

var voice = sinch.Voice("YOUR_application_key", "YOUR_application_secret");
```

Or, if you only need to use Voice API:

```cpp Initialize client for only Voice
using Sinch;

var sinch = new SinchClient(default, default, default);

var voice = sinch.Voice("YOUR_application_key", "YOUR_application_secret");
```

#### Set your Destination number parameter

In this example you want to call a phone number. Change the value of the `YOUR_phone_number` parameter to the phone number you verified in your [dashboard](https://dashboard.sinch.com) in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format.

Note:
When your account is in trial mode, you can only call your [verified numbers](https://dashboard.sinch.com/numbers/verified-numbers). If you want to call any number, you need to upgrade your account!

Save the file.

## Step 2. Make your phone call

1. Now you can execute the code and make your phone call. Run the following command:


```shell
dotnet run
```

You should receive a phone call to your mobile handset with a voice speaking the words in the request. You should also see the JSON response in the console.

## Next steps

Now that you know how to make a call, learn how to [handle an incoming call](/docs/voice/getting-started/dotnet_sdk/incoming-call).

## Additional resources

- [API specification](/docs/voice/api-reference/voice)