*If you want to use the content of this page with an AI tool, or if you are an AI agent, use the Markdown version of this page: `https://developers.sinch.com/docs/voice-2.0/getting-started.md`*

*You may also connect to our documentation MCP server by clicking the **Connect MCP** button: *

# Getting started

Account required!
Using the Voice API v2 requires [signing up for a free account](https://community.sinch.com/t5/Customer-Dashboard/How-to-sign-up-for-your-free-Sinch-account/ta-p/8058) on the Sinch Build Dashboard. If you haven't already done so, [sign up now](https://dashboard.sinch.com/signup)!

Follow the steps below to learn how to quickly start making calls using the Sinch Voice API:

## 1. Get your number

**Get your free Sinch testing number.** When you sign up for a Sinch Build Dashboard account, you get a free virtual number for testing. You must activate your test number before you can use it. To activate your number, simply click the [link](https://dashboard.sinch.com/numbers/buy-numbers?show=get-test-number&redirect=numbers/overview).

## 2. Get your credentials

Then, create your access key. Access keys are used to authenticate calls when using Voice API v2. Access keys are generated in the [Sinch Build Dashboard](https://dashboard.sinch.com/settings/access-keys).

You'll need this info later!
Make sure you have your access key, access key secret, and project ID readily available. This information will be required when making the API request to make a phone call. The access key and access key secret must be recorded during access key creation. The project ID can be found on the Sinch Build Dashboard's [Project Settings](https://dashboard.sinch.com/settings/project-settings) page.

## 3. Assign your number

In the Sinch Build dashboard, navigate to the **Numbers** section and locate [*Your virtual numbers*](https://dashboard.sinch.com/numbers/your-numbers).

Click on your number to go into the details for that number. Scroll down to the *Voice Configuration* section and click **Edit**. There you can select your default service. Make sure to save your settings.

## 4. Make a call

Now you're ready to get started making a phone call using the Voice API v2.

If you already have experience making API requests, you can create an application that makes the phone call in your preferred coding language.

The payload, along with instructions on how to populate placeholder variables, is below. Alternatively, each tab features a guide that will walk you through setting up a simple application in the identified coding language (make sure you bring all the information you gathered during this process!):

Payload
To initiate an outbound call, send a POST request to the `/v2/projects/{projectId}/calls` endpoint. The SVAML payload should be included in the `commands` field:

```json Payload application/json
{
  "commands": [
    {
      "command": "dial",
      "callName": "origin",
      "from": {
        "type": "PHONE",
        "phone": {
          "number": "+15551234567"
        }
      },
      "to": {
        "type": "PHONE",
        "phone": {
          "number": "+15559876543"
        }
      },
      "dialTimeoutDurationSeconds": 30,
      "maxCallDurationSeconds": 3600,
      "events": {
        "onAnswer": [
          {
            "command": "messages",
            "messages": [
              {
                "type": "SAY",
                "say": {
                  "text": "Hello, your call is now connected.",
                  "voiceName": "Emma"
                }
              }
            ]
          }
        ],
        "onHangup": [
          {
            "command": "hangup"
          }
        ]
      }
    }
  ]
}
```

The placeholder values included in the payload above are detailed in the table below:

| Placeholder value | Your value |
|  --- | --- |
| {YOUR_Number} | This is your test number that you activated in a previous step. |
| {YOUR_Destination_number} | This is a number you have verified in the Build dashboard. |


When you make the request, don't forget to include your project ID, and your access key and secret. Since this guide is intended for testing purposes, you can use your access key and access secret to authenticate using [basic authentication](/docs/voice-2.0/api-reference/authentication/basic).

Congratulations! You have successfully initiated your first outbound call.

Node.js
### Make a call with Node.js

You can quickly see how the Voice API works by calling yourself using the API.

#### What you need to know before you start

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

* [Node.js](https://nodejs.org/en/) and a familiarity with how to create a new app.


#### Set up your Node.js application

First we'll create a Node project using npm. This creates a package.json and the core dependencies necessary to start coding.

To create the project, do the following steps:

1. Create a project folder to hold your application.
2. Navigate into the folder you created and open a terminal, then run the following command.


```shell
npm init
```

This command adds the node_modules folder and the package.json file. You will be prompted to provide values for the fields. For this tutorial, you can simply accept the default values and press enter at each stage.

1. Add the node-fetch package with npm to generate the necessary dependencies.


```shell
npm install 'node-fetch'
```

#### Create your file

Create a new file named **index.js** in the project and paste the provided code into the file.

Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```javascript Node.js
import fetch from 'node-fetch';

async function run() {
  const query = new URLSearchParams({
    serviceId: '6e124178-c29d-46a5-943c-5c2ae544aade'
  }).toString();

  const projectId = 'YOUR_projectId_PARAMETER';
  const resp = await fetch(
    `https://voice.api.sinch.com/v2/projects/${projectId}/calls?${query}`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Idempotency-Key': 'stringstringstri',
        Authorization: 'Basic ' + Buffer.from('<username>:<password>').toString('base64')
      },
      body: JSON.stringify({
        commands: [
          {
            command: 'dial',
            callName: 'origin',
            from: {
              type: 'PHONE',
              phone: {number: '+15551234567'}
            },
            to: {
              type: 'PHONE',
              phone: {number: '+15559876543'}
            },
            dialTimeoutDurationSeconds: 30,
            maxCallDurationSeconds: 3600,
            events: {
              onAnswer: [
                {
                  command: 'messages',
                  messages: [
                    {
                      type: 'SAY',
                      say: {
                        text: 'Hello, your call is now connected.',
                        voiceName: 'Emma'
                      }
                    }
                  ]
                }
              ],
              onHangup: [{command: 'hangup'}]
            }
          }
        ]
      })
    }
  );

  const data = await resp.json();
  console.log(data);
}

run();
```

This code makes a phone call to a specified number using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `Index.js` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `projectId` | This is your project ID from your dashboard. |
| `X-Service-Id` | This is the ID of the service you created. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |
| `from` | This is your test number that you activated in a previous step and assigned to your Voice service. |
| `to` | This is a number you have verified in the Build dashboard. |


1. Save the file.


#### Run the code

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

```shell
node index.js
```

You should receive a phone call to the number you specified.

Troubleshooting tip
If after running your app you receive a 5000 error response, you may have forgotten to save your file after adding your authentication values. This is an easy mistake to make! Try saving the file and running the app again.

Java
### Make a call with Java

You can quickly see how the Voice API works by calling yourself using the API.

#### What you need to know before you start

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

* [JDK 8](https://www.oracle.com/java/technologies/downloads/) or later and a familiarity with how to create a new Java application.
* [Gradle](https://gradle.org/install/) and a familiarity with how use the Gradle build tools.


#### Set up your Java application

1. Create a new folder where you want to keep your app project. Then, open a terminal or command prompt to that location.
2. Create a new Java application using Gradle with the following command:


```shell
gradle init
```

In the prompts, select that you want to create an application, name your project and source package `app`, and then accept the defaults for the rest of the options.

#### Modify your file

1. Open the `App.java` file in your project folder, located in `\app\scr\main\java\app`. Populate that file code found on this page and save the file.


Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```java Java
import java.net.*;
import java.net.http.*;
import java.util.*;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;

public class App {
  public static void main(String[] args) throws Exception {
    var httpClient = HttpClient.newBuilder().build();

    var payload = String.join("\n"
      , "{"
      , " \"commands\": ["
      , "  {"
      , "   \"command\": \"dial\","
      , "   \"callName\": \"origin\","
      , "   \"from\": {"
      , "    \"type\": \"PHONE\","
      , "    \"phone\": {"
      , "     \"number\": \"+15551234567\""
      , "    }"
      , "   },"
      , "   \"to\": {"
      , "    \"type\": \"PHONE\","
      , "    \"phone\": {"
      , "     \"number\": \"+15559876543\""
      , "    }"
      , "   },"
      , "   \"dialTimeoutDurationSeconds\": 30,"
      , "   \"maxCallDurationSeconds\": 3600,"
      , "   \"events\": {"
      , "    \"onAnswer\": ["
      , "     {"
      , "      \"command\": \"messages\","
      , "      \"messages\": ["
      , "       {"
      , "        \"type\": \"SAY\","
      , "        \"say\": {"
      , "         \"text\": \"Hello, your call is now connected.\","
      , "         \"voiceName\": \"Emma\""
      , "        }"
      , "       }"
      , "      ]"
      , "     }"
      , "    ],"
      , "    \"onHangup\": ["
      , "     {"
      , "      \"command\": \"hangup\""
      , "     }"
      , "    ]"
      , "   }"
      , "  }"
      , " ]"
      , "}"
    );

    HashMap<String, String> params = new HashMap<>();
    params.put("serviceId", "6e124178-c29d-46a5-943c-5c2ae544aade");

    var query = params.keySet().stream()
      .map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))
      .collect(Collectors.joining("&"));

    var host = "https://voice.api.sinch.com";
    var projectId = "YOUR_projectId_PARAMETER";
    var pathname = "/v2/projects/%7BprojectId%7D/calls";
    var request = HttpRequest.newBuilder()
      .POST(HttpRequest.BodyPublishers.ofString(payload))
      .uri(URI.create(host + pathname + '?' + query))
      .header("Content-Type", "application/json")
      .header("Idempotency-Key", "stringstringstri")
      .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(("<username>:<password>").getBytes()))
      .build();

    var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());

    System.out.println(response.body());
  }
}
```

This code makes a phone call to a specified number using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `App.java` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `projectId` | This is your project ID from your dashboard. |
| `X-Service-Id` | This is the ID of the service you created. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |
| `from` | This is your test number that you activated in a previous step and assigned to your Voice service. |
| `to` | This is a number you have verified in the Build dashboard. |


1. Save the file.


#### Run the code

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

```shell
gradle run
```

You should receive a phone call to the number you specified.

Troubleshooting tip
If after running your app you receive a 5000 error response, you may have forgotten to save your file after adding your authentication values. This is an easy mistake to make! Try saving the file and running the app again.

.NET
### Make a call with .NET

You can quickly see how the Voice API works by calling yourself using the API.

#### What you need to know before you start

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

* [The latest version of .Net Core with **Long Term Support**](https://dotnet.microsoft.com/download) and a familiarity with how to create a new console application.


#### Set up your .NET console application

1. Create a new folder where you want to keep your app project. Then, open a terminal or command prompt to that location.
2. Create a new .Net Core console app with the following command:


```shell
dotnet new console
```

#### Modify your file

Open the `Program.cs` file in your project folder. Replace all of the code with the following code:

Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```csharp C#
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
using System.Net.Http.Headers;

public class Program
{
  public static async Task Main()
  {
    System.Net.Http.HttpClient client = new()
    {
      DefaultRequestHeaders =
      {
        {"Idempotency-Key", "stringstringstri"},
      }
    };

    string base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("<username>:<password>"));
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(@"Basic", base64String);

    string json = JsonSerializer.Serialize(new
    {
      commands = new[] {
        new {
          command = "dial",
          callName = "origin",
          from = new {
            type = "PHONE",
            phone = new {
              number = "+15551234567"
            }
          },
          to = new {
            type = "PHONE",
            phone = new {
              number = "+15559876543"
            }
          },
          dialTimeoutDurationSeconds = "30",
          maxCallDurationSeconds = "3600",
          events = new {
            onAnswer = new[] {
              new {
                command = "messages",
                messages = new[] {
                  new {
                    type = "SAY",
                    say = new {
                      text = "Hello, your call is now connected.",
                      voiceName = "Emma"
                    }
                  }
                },
              }
            },
            onHangup = new[] {
              new {
                command = "hangup"
              }
            },
          }
        }
      },
    });

    using StringContent postData = new(json, Encoding.UTF8, "application/json");
      var ProjectId = "YOUR_projectId_PARAMETER";
    using HttpResponseMessage request = await client.PostAsync("https://voice.api.sinch.com/v2/projects/" + ProjectId + "/calls?serviceId=6e124178-c29d-46a5-943c-5c2ae544aade", postData);
    string response = await request.Content.ReadAsStringAsync();

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

This code makes a phone call to a specified number using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `Program.cs` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `ProjectId` | This is your project ID from your dashboard. |
| `X-Service-Id` | This is the ID of the service you created. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |
| `from` | This is your test number that you activated in a previous step and assigned to your Voice service. Replace the `number` value in the object. |
| `to` | This is a number you have verified in the Build dashboard. Replace the `number` value in the object. |


1. Save the file.


#### Run the code

Before executing your code, you must first compile your application. Execute the following command:

```shell
dotnet build
```

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 the number you specified.

Troubleshooting tip
If after running your app you receive a 5000 error response, you may have forgotten to save your file after adding your authentication values. This is an easy mistake to make! Try saving the file and running the app again.

Python
### Make a call with Python

You can quickly see how the Voice API works by calling yourself using the API.

#### What you need to know before you start

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

* [Python](https://www.python.org/) and a familiarity with how to create a new file.


#### Set up your Python application

Create a new file named `make-call.py` and paste the provided code found on this page into the file.

Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```python Python
import requests

project_id = "YOUR_projectId_PARAMETER"
url = "https://voice.api.sinch.com/v2/projects/" + project_id + "/calls"

query = {
  "serviceId": "6e124178-c29d-46a5-943c-5c2ae544aade"
}

payload = {
  "commands": [
    {
      "command": "dial",
      "callName": "origin",
      "from": {
        "type": "PHONE",
        "phone": {
          "number": "+15551234567"
        }
      },
      "to": {
        "type": "PHONE",
        "phone": {
          "number": "+15559876543"
        }
      },
      "dialTimeoutDurationSeconds": 30,
      "maxCallDurationSeconds": 3600,
      "events": {
        "onAnswer": [
          {
            "command": "messages",
            "messages": [
              {
                "type": "SAY",
                "say": {
                  "text": "Hello, your call is now connected.",
                  "voiceName": "Emma"
                }
              }
            ]
          }
        ],
        "onHangup": [
          {
            "command": "hangup"
          }
        ]
      }
    }
  ]
}

headers = {
  "Content-Type": "application/json",
  "Idempotency-Key": "stringstringstri"
}

response = requests.post(url, json=payload, headers=headers, params=query, auth=('<username>','<password>'))

data = response.json()
print(data)
```

This code makes a phone call to a specified number using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `make-call.py` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `project_id` | This is your project ID from your dashboard. |
| `X-Service-Id` | This is the ID of the service you created. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |
| `from` | This is your test number that you activated in a previous step and assigned to your Voice service. |
| `to` | This is a number you have verified in the Build dashboard. |


1. Save the file.


#### Run the code

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

```shell
python make-call.py
```

You should receive a phone call to the number you specified.

Troubleshooting tip
If after running your app you receive a 5000 error response, you may have forgotten to save your file after adding your authentication values. This is an easy mistake to make! Try saving the file and running the app again.

## 5. Handle an incoming call

You can also call the phone number assigned to your Voice service and handle that incoming call. The Voice API v2 can respond to incoming calls in one of two ways:

- Sending an event to the webhook configured on your Voice service when a call is received
- Configuring static SVAML code to your Voice service which triggers when a call is received.


Since setting up your own server to listen for incoming requests can be a bit intensive, this guide will show you how to configure your Voice service with static SVAML code.

If you already have experience making API requests, you can create an application that updates your service in your preferred coding language.

The payload, along with instructions on how to populate placeholder variables, is below. Alternatively, each tab features a guide that will walk you through setting up a simple application in the identified coding language (make sure you bring all the information you gathered during this process!):

Payload
To update your service with static SVAML, send a PATCH request to the `/v2/projects/{projectId}/services/{serviceId}` endpoint. You will update the call behavior of the service as shown below:

```json Payload application/json
{
  "description": "Service with static SVAML",
  "callBehavior": {
    "type": "STATIC",
    "static": {
      "callName": "incoming",
      "commands": [
        {
          "command": "answer"
        },
        {
          "command": "messages",
          "messages": [
            {
              "type": "SAY",
              "say": {
                "text": "Your call is working fine! This call will be disconnected.",
                "voiceName": "Emma"
              }
            }
          ],
          "events": {
            "onFinish": [
              {
                "command": "hangup"
              }
            ]
          }
        }
      ]
    }
  }
}
```

When you make the request, don't forget to include your project ID, and your access key and secret. Since this guide is intended for testing purposes, you can use your access key and access secret to authenticate using [basic authentication](/docs/voice-2.0/api-reference/authentication/basic).

Now that you've updated your service, call the phone number assigned to your Voice service. The call should be answered and you'll hear the text of the `SAY` command in the SVAML.

Node.js
### Handle an incoming call with Node.js

You can quickly see how the Voice API works by handling incoming calls using the API.

#### What you need to know before you start

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

* [Node.js](https://nodejs.org/en/) and a familiarity with how to create a new app.


#### Set up your Node.js application

First we'll create a Node project using npm. This creates a package.json and the core dependencies necessary to start coding.

To create the project, do the following steps:

1. Create a project folder to hold your application.
2. Navigate into the folder you created and open a terminal, then run the following command.


```shell
npm init
```

This command adds the node_modules folder and the package.json file. You will be prompted to provide values for the fields. For this tutorial, you can simply accept the default values and press enter at each stage.

1. Add the node-fetch package with npm to generate the necessary dependencies.


```shell
npm install 'node-fetch'
```

#### Create your file

Create a new file named **index.js** in the project and paste the provided code into the file.

Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```javascript Node.js
import fetch from 'node-fetch';

async function run() {
  const projectId = 'YOUR_projectId_PARAMETER';
  const serviceId = 'YOUR_serviceId_PARAMETER';
  const resp = await fetch(
    `https://voice.api.sinch.com/v2/projects/${projectId}/services/${serviceId}`,
    {
      method: 'PATCH',
      headers: {
        'Content-Type': 'application/json',
        'Idempotency-Key': 'stringstringstri',
        Authorization: 'Basic ' + Buffer.from('<username>:<password>').toString('base64')
      },
      body: JSON.stringify({
        description: 'Service with static SVAML',
        callBehavior: {
          type: 'STATIC',
          static: {
            callName: 'incoming',
            commands: [
              {command: 'answer'},
              {
                command: 'messages',
                messages: [
                  {
                    type: 'SAY',
                    say: {
                      text: 'Your call is working fine! This call will be disconnected.',
                      voiceName: 'Emma'
                    }
                  }
                ],
                events: {
                  onFinish: [{command: 'hangup'}]
                }
              }
            ]
          }
        }
      })
    }
  );

  const data = await resp.json();
  console.log(data);
}

run();
```

This code updates your service by adding static SVAML to the call behavior using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `Index.js` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `projectId` | This is your project ID from your dashboard. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |


1. Save the file.


#### Run the code

Now you can execute the code and update your service. Run the following command:

```shell
node index.js
```

You should receive a response detailing your updated service.

#### Call your Sinch number

Now you can call the phone number you've assigned to your Voice service. The call should be answered and you'll hear a message played.

Java
### Handle an incoming call with Java

You can quickly see how the Voice API works by handling incoming calls using the API.

#### What you need to know before you start

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

* [JDK 8](https://www.oracle.com/java/technologies/downloads/) or later and a familiarity with how to create a new Java application.
* [Gradle](https://gradle.org/install/) and a familiarity with how use the Gradle build tools.


#### Set up your Java application

1. Create a new folder where you want to keep your app project. Then, open a terminal or command prompt to that location.
2. Create a new Java application using Gradle with the following command:


```shell
gradle init
```

In the prompts, select that you want to create an application, name your project and source package `app`, and then accept the defaults for the rest of the options.

#### Modify your file

1. Open the `App.java` file in your project folder, located in `\app\scr\main\java\app`. Populate that file code found on this page and save the file.


Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```java Java
import java.net.*;
import java.net.http.*;
import java.util.*;

public class App {
  public static void main(String[] args) throws Exception {
    var httpClient = HttpClient.newBuilder().build();

    var payload = String.join("\n"
      , "{"
      , " \"description\": \"Service with static SVAML\","
      , " \"callBehavior\": {"
      , "  \"type\": \"STATIC\","
      , "  \"static\": {"
      , "   \"callName\": \"incoming\","
      , "   \"commands\": ["
      , "    {"
      , "     \"command\": \"answer\""
      , "    },"
      , "    {"
      , "     \"command\": \"messages\","
      , "     \"messages\": ["
      , "      {"
      , "       \"type\": \"SAY\","
      , "       \"say\": {"
      , "        \"text\": \"Your call is working fine! This call will be disconnected.\","
      , "        \"voiceName\": \"Emma\""
      , "       }"
      , "      }"
      , "     ],"
      , "     \"events\": {"
      , "      \"onFinish\": ["
      , "       {"
      , "        \"command\": \"hangup\""
      , "       }"
      , "      ]"
      , "     }"
      , "    }"
      , "   ]"
      , "  }"
      , " }"
      , "}"
    );

    var host = "https://voice.api.sinch.com";
    var projectId = "YOUR_projectId_PARAMETER";
    var serviceId = "YOUR_serviceId_PARAMETER";
    var pathname = "/v2/projects/%7BprojectId%7D/services/%7BserviceId%7D";
    var request = HttpRequest.newBuilder()
      .method("PATCH", HttpRequest.BodyPublishers.ofString(payload))
      .uri(URI.create(host + pathname ))
      .header("Content-Type", "application/json")
      .header("Idempotency-Key", "stringstringstri")
      .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(("<username>:<password>").getBytes()))
      .build();

    var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());

    System.out.println(response.body());
  }
}
```

This code updates your service by adding static SVAML to the call behavior using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `App.java` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `projectId` | This is your project ID from your dashboard. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |


1. Save the file.


#### Run the code

Now you can execute the code and update your service. Run the following command:

```shell
gradle run
```

You should receive a response detailing your updated service.

#### Call your Sinch number

Now you can call the phone number you've assigned to your Voice service. The call should be answered and you'll hear a message played.

.NET
### Handle an incoming call with .NET

You can quickly see how the Voice API works by handling incoming calls using the API.

#### What you need to know before you start

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

* [The latest version of .Net Core with **Long Term Support**](https://dotnet.microsoft.com/download) and a familiarity with how to create a new console application.


#### Set up your .NET console application

1. Create a new folder where you want to keep your app project. Then, open a terminal or command prompt to that location.
2. Create a new .Net Core console app with the following command:


```shell
dotnet new console
```

#### Modify your file

Open the `Program.cs` file in your project folder. Replace all of the code with the following code:

Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```csharp C#
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
using System.Net.Http.Headers;

public class Program
{
  public static async Task Main()
  {
    System.Net.Http.HttpClient client = new()
    {
      DefaultRequestHeaders =
      {
        {"Idempotency-Key", "stringstringstri"},
      }
    };

    string base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("<username>:<password>"));
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(@"Basic", base64String);

    string json = JsonSerializer.Serialize(new
    {
      description = "Service with static SVAML",
      callBehavior = new {
        type = "STATIC",
        static = new {
          callName = "incoming",
          commands = new[] {
            new {
              command = "answer"
            },
            new {
              command = "messages",
              messages = new[] {
                new {
                  type = "SAY",
                  say = new {
                    text = "Your call is working fine! This call will be disconnected.",
                    voiceName = "Emma"
                  }
                }
              },
              events = new {
                onFinish = new[] {
                  new {
                    command = "hangup"
                  }
                },
              }
            }
          },
        }
      }
    });

    using StringContent postData = new(json, Encoding.UTF8, "application/json");
      var ProjectId = "YOUR_projectId_PARAMETER";
      var ServiceId = "YOUR_serviceId_PARAMETER";
    using HttpResponseMessage request = await client.PatchAsync("https://voice.api.sinch.com/v2/projects/" + ProjectId + "/services/" + ServiceId, postData);
    string response = await request.Content.ReadAsStringAsync();

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

This code updates your service by adding static SVAML to the call behavior using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `Program.cs` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `ProjectId` | This is your project ID from your dashboard. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |


1. Save the file.


#### Run the code

Before executing your code, you must first compile your application. Execute the following command:

```shell
dotnet build
```

Now you can execute the code and update your Voice service. Run the following command:

```shell
dotnet run
```

You should receive a response detailing your updated service.

#### Call your Sinch number

Now you can call the phone number you've assigned to your Voice service. The call should be answered and you'll hear a message played.

Python
### Handle an incoming call with Python

You can quickly see how the Voice API works by handling incoming calls using the API.

#### What you need to know before you start

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

* [Python](https://www.python.org/) and a familiarity with how to create a new file.


#### Set up your Python application

Create a new file named `update-service.py` and paste the provided code found on this page into the file.

Note:
This tutorial uses basic authentication for testing purposes. We recommend using OAuth token-based authentication for production.

```python Python
import requests

project_id = "YOUR_projectId_PARAMETER"
service_id = "YOUR_serviceId_PARAMETER"
url = "https://voice.api.sinch.com/v2/projects/" + project_id + "/services/" + service_id

payload = {
  "description": "Service with static SVAML",
  "callBehavior": {
    "type": "STATIC",
    "static": {
      "callName": "incoming",
      "commands": [
        {
          "command": "answer"
        },
        {
          "command": "messages",
          "messages": [
            {
              "type": "SAY",
              "say": {
                "text": "Your call is working fine! This call will be disconnected.",
                "voiceName": "Emma"
              }
            }
          ],
          "events": {
            "onFinish": [
              {
                "command": "hangup"
              }
            ]
          }
        }
      ]
    }
  }
}

headers = {
  "Content-Type": "application/json",
  "Idempotency-Key": "stringstringstri"
}

response = requests.patch(url, json=payload, headers=headers, auth=('<username>','<password>'))

data = response.json()
print(data)
```

This code updates your service by adding static SVAML to the call behavior using the Sinch Voice API.

#### Fill in your parameters

1. Before you can run the code, you need to update some more values in the `update-service.py` file so you can connect to your Sinch account. Update the following parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `project_id` | This is your project ID from your dashboard. |
| `<username>` | The access key you created in a previous step. |
| `<password>` | The access secret for the access key. |


1. Save the file.


#### Run the code

Now you can execute the code and update your service. Run the following command:

```shell
python update-service.py
```

You should receive a response detailing your updated service.

#### Call your Sinch number

Now you can call the phone number you've assigned to your Voice service. The call should be answered and you'll hear a message played.

## Next steps

Now that you know how to make an outbound call and handle an incoming call, you can start to build more complex solutions. Check out the following guides to see what you can do with Voice API v2:

* [Outbound Text to speech Appointment Reminder](/docs/voice-2.0/tutorials/outbound-tts)
* [Voicemail detection and webhooks](/docs/voice-2.0/tutorials/amd)
* [Agentic Voice Relay](/docs/voice-2.0/tutorials/voice-relay)


## Additional resources

[View the whole API Reference](/docs/voice-2.0/api-reference/voice).