*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`*

Sinch Voice API: Choosing between v1 and v2
For all new projects, please use Voice API v2. This is especially important for projects involving:

- AI capabilities like Streams and Voice Relay
- Voice campaigns like Batch calling


You should only use the older Voice API v1 if one of the following is a strict requirement:

- The project must be in General Availability (GA).
- The project requires In-App voice or Conferencing (until these features are available in v2).


# Getting started

Account required!
Using the Voice API v2 requires [signing up for a free account](https://support.sinch.com/hc/en-us/articles/53501378504467-How-to-sign-up-for-your-free-Sinch-account) 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 v2:

## 1. Accept the terms and conditions

In the Sinch Build Dashboard, navigate to the **Programmable Voice** and accept the terms and conditions. When you sign up for an account, a default Voice service is automatically created and now it will be available to use.

## 2. Get and assign 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). In the modal window that is displayed when activating your number, you can add Voice configuration to the number. Select your Programmable Voice default service.

## 3. 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.

## 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!):

Try It
To initiate an outbound call, send a POST request to the `/v2/projects/{projectId}/calls` endpoint. You can use the panel below to make your request:

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

To quickly get started setting up a simple client application using the Node SDK:

1. If you haven't already, clone the [sinch-sdk-node](https://github.com/sinch/sinch-sdk-node) repository.
2. Navigate to the `examples/snippets/` folder.
3. Open a command prompt or terminal and run the following command to install the necessary dependencies:

```shell
npm install
```
4. Rename the `.env.example` [file](https://github.com/sinch/sinch-sdk-node/blob/main/examples/snippets/.env.example) to `.env`. Using the [access key credentials](https://dashboard.sinch.com/settings/access-keys) from your Sinch Build Dashboard, populate the following fields with your values:
| Field | Description |
|  --- | --- |
| SINCH_PROJECT_ID | The unique ID of your Project. |
| SINCH_KEY_ID | The unique ID of your access key. |
| SINCH_KEY_SECRET | The secret that goes with your access key.  **Note:** For security reasons, this secret is only visible right after access key creation. |


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

1. Save the file.
2. Navigate to `examples/snippets/voice/v2/calls/start.js`.


start.js
```javascript start.js
//This code makes a phone call to a specified number using the Sinch Voice API v2. 
/**
 * Sinch Node.js Snippet
 * See: https://github.com/sinch/sinch-sdk-node/examples/snippets
 */
import { SinchClient, Voice } from '@sinch/sdk-core';
import * as dotenv from 'dotenv';
dotenv.config();

async function main() {
  const projectId = process.env.SINCH_PROJECT_ID ?? 'MY_PROJECT_ID';
  const keyId = process.env.SINCH_KEY_ID ?? 'MY_KEY_ID';
  const keySecret = process.env.SINCH_KEY_SECRET ?? 'MY_KEY_SECRET';

  // The phone number to be used as the caller ID, in E.164 format (e.g., +12025550123)
  const sinchPhoneNumber = process.env.SINCH_PHONE_NUMBER || 'MY_SINCH_PHONE_NUMBER';
  // The phone number you want to call, in E.164 format (e.g., +12025550123)
  const recipientPhoneNumber = 'RECIPIENT_PHONE_NUMBER';

  const sinch = new SinchClient({ projectId, keyId, keySecret });

  try {
    const response = await sinch.voice.v2.calls.start({
      createCallRequestBody: {
        commands: new Voice.v2.CommandsSequenceCreator()
          .dial((dialCreator) => {
            dialCreator
              .name('Node_SDK_Snippet_Call')
              .from(Voice.v2.Destination.of(sinchPhoneNumber))
              .to(Voice.v2.Destination.of(recipientPhoneNumber))
              .onAnswer((sequence) => {
                sequence.text('Hello, your call is now connected.', 'Emma', {
                  onFinish: Voice.v2.Calls.hangup(),
                });
              });
          })
          .build(),
      },
    });
    console.log(`✅ Successfully started a Voice v2 call to ${recipientPhoneNumber}.`);
    console.log(`Response:\n${JSON.stringify(response, null, 2)}`);
  } catch (err) {
    console.error(`❌ Failed to start a Voice v2 call to ${recipientPhoneNumber}:`);
    console.error(err);
  }
}

main();
```

1. The code provided in **start.js** includes placeholder values for some parameter. You should replace the following values for these parameters with your own values:


| Parameter | Your value |
|  --- | --- |
| `recipientPhoneNumber` | The phone number you want to call. This should be a number you've verified in your Build Dashboard. |
| `sinchPhoneNumber` | This is your Sinch number that you have assigned to your voice service. |


1. Save the file.


#### Run the code

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

```shell
npm run voice:v2:calls:start
```

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 v2 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 21 or later](https://www.oracle.com/java/technologies/downloads/) and a familiarity with how to create a new Java application. (The SDK itself only requires JDK 8 or later, but this quickstart guide uses JDK 21 as it is the latest version with long term support.)


To quickly get started setting up a simple client application using the Java SDK:

1. If you haven't already, clone the [sinch-sdk-java](https://github.com/sinch/sinch-sdk-java) repository.
2. Navigate to the `examples/snippets/src/main/resources` folder.
3. Open the `config.properties` [file](https://github.com/sinch/sinch-sdk-java/blob/main/examples/snippets/src/main/resources/config.properties). Using the [access key credentials](https://dashboard.sinch.com/settings/access-keys) from your Sinch Build Dashboard, populate the following fields with your values:
| Field | Description |
|  --- | --- |
| `SINCH_PROJECT_ID` | The unique ID of your Project. |
| `SINCH_KEY_ID` | The unique ID of your access key. |
| `SINCH_KEY_SECRET` | The secret that goes with your access key.  **Note:** For security reasons, this secret is only visible right after access key creation. |
| `SINCH_PHONE_NUMBER` | Your Sinch virtual phone number, available on the [Sinch Build Dashboard](https://dashboard.sinch.com/numbers/your-numbers). |
4. Save the file.


### Modify your Java application

1. Navigate to the `examples/snippets/src/main/java/voice/v2/calls` folder and open the `Start.java` file.


Start.java
```java Start.java
/**
 * Sinch Java Snippet
 *
 * <p>This snippet is available at https://github.com/sinch/sinch-sdk-java
 *
 * <p>See https://github.com/sinch/sinch-sdk-java/blob/main/examples/snippets/README.md for details
 */
package voice.v2.calls;

import com.sinch.sdk.SinchClient;
import com.sinch.sdk.domains.voice.api.v2.CallsService;
import com.sinch.sdk.domains.voice.models.v2.calls.request.StartCallRequest;
import com.sinch.sdk.domains.voice.models.v2.calls.response.StartCallResponse;
import com.sinch.sdk.domains.voice.models.v2.helpers.Calls;
import com.sinch.sdk.domains.voice.models.v2.helpers.CommandsSequenceCreator;
import com.sinch.sdk.models.Configuration;
import java.util.logging.Logger;
import utils.Settings;

public class Start {

  private static final Logger LOGGER = Logger.getLogger(Start.class.getName());

  public static void main(String[] args) {

    String projectId = Settings.getProjectId().orElse("MY_PROJECT_ID");
    String keyId = Settings.getKeyId().orElse("MY_KEY_ID");
    String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");

    // The phone number to be used as the caller ID, in E.164 format (e.g., +12025550123)
    String sinchPhoneNumber = Settings.getPhoneNumber().orElse("MY_SINCH_PHONE_NUMBER");
    // The phone number you want to call, in E.164 format (e.g., +12025550123)
    String recipientPhoneNumber = "RECIPIENT_PHONE_NUMBER";

    Configuration configuration =
        Configuration.builder()
            .setProjectId(projectId)
            .setKeyId(keyId)
            .setKeySecret(keySecret)
            .build();

    SinchClient client = new SinchClient(configuration);

    CallsService callsService = client.voice().v2().calls();

    // Dial the recipient: once the call is answered, play a greeting, then hang up
    StartCallRequest request =
        StartCallRequest.builder()
            .setCommands(
                CommandsSequenceCreator.create()
                    .dial(
                        recipientPhoneNumber,
                        dial ->
                            dial.name("Java_SDK_Snippet_Call")
                                .from(sinchPhoneNumber)
                                .onAnswer(
                                    answered ->
                                        answered.text(
                                            "Hello, your call is now connected.",
                                            "Emma",
                                            greeting -> greeting.onFinish(Calls.hangup()))))
                    .build())
            .build();

    LOGGER.info("Start a call to: " + recipientPhoneNumber);

    StartCallResponse response = callsService.start(request);

    LOGGER.info("Response: " + response);
  }
}
```

1. The code provided in **Start.java** includes placeholder parameters. Replace the following placeholder values for these parameters with your values:
| Placeholder value | Your value |
|  --- | --- |
| `RECIPIENT_PHONE_NUMBER` | This is the phone number you want to call. If you are using a trial account, this must be a phone number you have verified in the Sinch Build Dashboard. |
2. Save your file.


### Make your first call using the Java SDK

Now you can make a call. Open a command prompt to `examples/snippets` and run the following code:

```Shell
launcher voice/v2/calls/Start
```

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();

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

    string json = JsonSerializer.Serialize(new
    {
      commands = new object[] {
        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 object[] {
              new {
                command = "messages",
                messages = new object[] {
                  new {
                    type = "SAY",
                    say = new {
                      text = "Hello, your call is now connected.",
                      voiceName = "Emma_3"
                    }
                  }
                },
              }
            },
            onHangup = new object[] {
              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", 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 SDK

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

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

- Before you can get started, you need [Python](https://www.python.org/) already installed.
- Note that this tutorial uses basic authentication for testing purposes. We recommend OAuth 2.0 authentication in a production environment. Read more about [authentication methods](/docs/voice-2.0/api-reference/authentication/basic).


To quickly get started setting up a simple client application using the Python SDK:

1. If you haven't already, clone the [sinch-sdk-python](https://github.com/sinch/sinch-sdk-python) repository.
2. Navigate to the `examples/snippets` folder.
3. Copy the example `.env` file by running the following command:


Linux/Mac
```bash
cp .env.example .env
```

Windows (Command Prompt)
```cmd
copy .env.example .env
```

Windows (Powershell)
```powershell
Copy-Item .env.example .env
```

1. Open the `.env` [file](https://github.com/sinch/sinch-sdk-python/blob/main/examples/snippets/.env.example) you just created. Using the [access key credentials](https://dashboard.sinch.com/settings/access-keys) from your Sinch Build Dashboard, populate the following fields with your values:


| Field | Description |
|  --- | --- |
| SINCH_PROJECT_ID | The unique ID of your Project. |
| SINCH_KEY_ID | The unique ID of your access key. |
| SINCH_KEY_SECRET | The secret that goes with your access key.  **Note:** For security reasons, this secret is only visible right after access key creation. |


1. Save the file.
2. The Python SDK uses [Poetry](https://python-poetry.org/) to manage packages and dependencies, so install those dependencies using the following command:


```cmd
poetry install
```

1. Navigate to the `/examples/snippets/voice/calls/start/` directory and open `snippet.py`. This code makes a phone call to a specified number using the Sinch Voice v2 API.


snippet.py
```python snippet.py
"""
Sinch Python Snippet

This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
"""

import os

from dotenv import load_dotenv

from sinch import SinchClient
from sinch.domains.voice.helpers.v2.svaml import (
    Calls,
    CommandsSequenceCreator,
)

load_dotenv()

sinch_client = SinchClient(
    project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
    key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
    key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
)

# The phone number to be used as the caller ID, in E.164 format (e.g., +12025550123)
sinch_phone_number = (
    os.environ.get("SINCH_PHONE_NUMBER") or "MY_SINCH_PHONE_NUMBER"
)

# The phone number you want to call, in E.164 format (e.g., +12025550123)
recipient_phone_number = "RECIPIENT_PHONE_NUMBER"

# The SVAML commands describing the call flow: dial out to the recipient
commands = CommandsSequenceCreator().dial(
    recipient_phone_number,
    from_=sinch_phone_number,
    name="Python_SDK_Snippet_Call",
    on_answer=CommandsSequenceCreator().text(
        "Hello, your call is now connected.",
        "Emma",
        on_finish=Calls.hangup(),
    ),
)

response = sinch_client.voice.v2.calls.start(commands=commands)

print(f"Call Successfully started.\n{response}")
```

#### Fill in your parameters

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


| Placeholder value | Your value |
|  --- | --- |
| `MY_SINCH_PHONE_NUMBER` | This is your test number that you activated in a previous step and assigned to your Voice service. |
| `RECIPIENT_PHONE_NUMBER` | 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 a test call. Open a command prompt or terminal to the `/examples/snippets/voice/calls/start/` directory and run the following command:

```shell
python snippet.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.


Setting up your own server to listen for incoming requests takes more steps than this guide covers in the languages below — if you want to skip that setup, see the **Sinch Functions** tab instead, or continue on and 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_3"
              }
            }
          ],
          "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
/**
 * Sinch Node.js Snippet
 * See: https://github.com/sinch/sinch-sdk-node/examples/snippets
 */
import { SinchClient } from '@sinch/sdk-core';
import * as dotenv from 'dotenv';
dotenv.config();

async function main() {
  const projectId = process.env.SINCH_PROJECT_ID ?? 'MY_PROJECT_ID';
  const keyId = process.env.SINCH_KEY_ID ?? 'MY_KEY_ID';
  const keySecret = process.env.SINCH_KEY_SECRET ?? 'MY_KEY_SECRET';

  // The ID of the service to update
  const serviceId = 'SERVICE_ID';

  const sinch = new SinchClient({ projectId, keyId, keySecret });

  try {
    const response = await sinch.voice.v2.services.update({
      serviceId,
      updateServiceRequestBody: {
        name: 'Updated service name',
      },
    });
    console.log(`✅ Successfully updated the Voice v2 service with ID ${serviceId}.`);
    console.log(`Response:\n${JSON.stringify(response, null, 2)}`);
  } catch (err) {
    console.error(`❌ Failed to update the Voice v2 service with ID ${serviceId}:`);
    console.error(err);
  }
}

main();
```

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
/**
 * Sinch Java Snippet
 *
 * <p>This snippet is available at https://github.com/sinch/sinch-sdk-java
 *
 * <p>See https://github.com/sinch/sinch-sdk-java/blob/main/examples/snippets/README.md for details
 */
package voice.v2.services;

import com.sinch.sdk.SinchClient;
import com.sinch.sdk.domains.voice.api.v2.ServicesService;
import com.sinch.sdk.domains.voice.models.v2.services.request.UpdateServiceRequest;
import com.sinch.sdk.domains.voice.models.v2.services.response.ServiceResponse;
import com.sinch.sdk.models.Configuration;
import java.util.logging.Logger;
import utils.Settings;

public class Update {

  private static final Logger LOGGER = Logger.getLogger(Update.class.getName());

  public static void main(String[] args) {

    String projectId = Settings.getProjectId().orElse("MY_PROJECT_ID");
    String keyId = Settings.getKeyId().orElse("MY_KEY_ID");
    String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");

    // The ID of the service to update
    String serviceId = "SERVICE_ID";
    String name = "Updated from Java SDK snippet";

    Configuration configuration =
        Configuration.builder()
            .setProjectId(projectId)
            .setKeyId(keyId)
            .setKeySecret(keySecret)
            .build();

    SinchClient client = new SinchClient(configuration);

    ServicesService servicesService = client.voice().v2().services();

    UpdateServiceRequest request = UpdateServiceRequest.builder().setName(name).build();

    LOGGER.info(String.format("Update voice service with ID '%s'", serviceId));

    ServiceResponse response = servicesService.update(serviceId, request);

    LOGGER.info("Response: " + 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 `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();

    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 object[] {
            new {
              command = "answer"
            },
            new {
              command = "messages",
              messages = new object[] {
                new {
                  type = "SAY",
                  say = new {
                    text = "Your call is working fine! This call will be disconnected.",
                    voiceName = "Emma_3"
                  }
                }
              },
              events = new {
                onFinish = new object[] {
                  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
"""
Sinch Python Snippet

This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
"""

import os

from dotenv import load_dotenv

from sinch import SinchClient

load_dotenv()

sinch_client = SinchClient(
    project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
    key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
    key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
)

# The ID of the service
service_id = "SERVICE_ID"

# The new name of the service
name = "Updated from Python SDK snippet"

response = sinch_client.voice.v2.services.update(service_id=service_id, name=name)

print(f"Successfully updated service.\n{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 `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.

Sinch Functions
### Handle an incoming call with Sinch Functions

Skip writing and hosting your own server. [Sinch Functions](/docs/functions/functions/quickstart) run your handler for you and expose it to Sinch without a tunnel.

**[Deploy this template from the dashboard](https://dashboard.sinch.com/functions/templates/node/simple-voice-ivr/deploy)** if you prefer to work in a dashboard UI instead of a terminal: use the same template with a guided assistant. The rest of this section gives CLI instructions using a terminal.

1. If you haven't already, install the CLI with and then authenticate the CLI using your Sinch credentials with the following commands:

```shell
npm install -g @sinch/cli
sinch auth login
```
2. Next, initialize the `simple-voice-ivr` template:

```shell
sinch functions init simple-voice-ivr --name my-first-function
```
`init` writes the Voice service you pick as `VOICE_SERVICE_ID` and points its inbound webhook at the function once you deploy. The template's handler already answers `call.incoming` with a menu:

```typescript
import { commands, onCall } from '@sinch/functions-runtime';

const companyName = process.env.COMPANY_NAME || 'Your Company';

export const voiceWebhook = onCall({
  incoming: () =>
    commands()
      .answer()
      .menu('main', (menu) =>
        menu
          .prompt(`Welcome to ${companyName}. Press 1 for yes, or press 2 for no.`)
          .repeatPrompt('Please press 1 for yes, or 2 for no.')
          .inputTimeout(5)
          .repeatCount(2)
          .maxLength(1)
          .match('1', (c) => c.say('You pressed yes. Thank you, goodbye.').hangup())
          .match('2', (c) => c.say('You pressed no. Thank you, goodbye.').hangup())
          .onFail((c) => c.say('No input received. Goodbye.').hangup())
      )
      .build(),

  manage: () => commands().say('Sorry, I did not get that. Goodbye.').hangup().build(),
});
```
3. Run the server locally and Sinch reaches your laptop directly, no tunnel necessary:

```shell
cd my-first-function
sinch functions dev
```
4. Call your Sinch number — the call is answered by the code running on your machine. When you're ready, `sinch functions deploy` puts the same code into production.


## 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).