---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/voice/tutorials/how-record-single-side-call#article
headline: How to record a single side of a call
description: Learn to configure Single Party Call Recording with Twilio Programmable Voice for self-service automation, contact centers, sales dialers, and call tracking.
url: https://www.twilio.com/docs/voice/tutorials/how-record-single-side-call
inLanguage: en
dateModified: 2026-08-19T18:30:57.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# How to record a single side of a call

Learn to programmatically record only one side of a call with Twilio Programmable Voice by using the `RecordingTrack` parameter in a `POST` request. You can use this guide to create self-service automation, inbound contact centers, outbound contact centers, sales dialers, call tracking systems, and AI/ML transcription.

See [Related reference documentation](#related-reference-documentation) to learn more about the TwiML and API requests used in this guide.

[All Advanced Programmable Voice features guides](/docs/voice/guides/by-feature-product#advanced-programmable-voice-features)

## How it works

`RecordingTrack` is an optional parameter that can be used to select whether the inbound, outbound or both audio tracks of the call should be recorded. The `inbound` track represents the audio received by Twilio, and the `outbound` track represents the audio that Twilio generates on the call.

For example, if the caller is interacting with an IVR, the inbound track contains the caller's voice and the outbound track contains the audio generated via either `<Say>` or `<Play>`. Alternatively, if the caller is connected to agent via `<Dial>`, then the outbound track will contain the audio spoken by agent.

> \[!WARNING]
>
> When inbound or outbound audio track is recorded, the resulting recording file will always be mono-channel. When audio is recorded using both, you can choose either separate channel (dual) or mixed (mono).

This table illustrates the expected outcome when using `recordingTrack` and attributes together to request a recording:

| **RecordingTrack** | **RecordingChannel** | **Outcome**                                                                                                                                                                                                                                                 |
| ------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -                  | -                    | Records the inbound and the outbound audio of the call mixed in a single channel of the recording file.                                                                                                                                                     |
| -                  | mono                 | Records the inbound and the outbound audio of the call mixed in a single channel of the recording file.                                                                                                                                                     |
| -                  | dual                 | Records the inbound and the outbound audio of the call in two separate channels of the recording file.                                                                                                                                                      |
| inbound            | -                    | Records the inbound audio of the call in a single channel of the recording file. The inbound track is the audio that is received by Twilio from the call.                                                                                                   |
| outbound           | -                    | Records the outbound audio of the call in a single channel of the recording file. The outbound track is the audio that is generated by Twilio.                                                                                                              |
| both               | -                    | Records the inbound and the outbound audio of the call mixed in a single channel of the recording file.                                                                                                                                                     |
| inbound            | mono                 | Records the inbound audio of the call in a single channel of the recording file. The inbound track is the audio that is received by Twilio from the call.                                                                                                   |
| inbound            | dual (→ mono)        | Records the inbound audio of the call in a single channel of the recording file. The inbound track is the audio that is received by Twilio from the call. **Note**: if you set "RecordingChannel=dual", this will be ignored and automatically set to mono. |
| outbound           | mono                 | Records the outbound audio of the call in a single channel of the recording file. The outbound track is the audio that is generated by Twilio.                                                                                                              |
| outbound           | dual (→ mono)        | Records the outbound audio of the call in a single channel of the recording file. The outbound track is the audio that is generated by Twilio. **Note**: if you set "RecordingChannel=dual", this will be ignored and automatically set to mono.            |
| both               | mono                 | Records the inbound and the outbound audio of the call mixed in a single channel of the recording file.                                                                                                                                                     |
| both               | dual                 | Records the inbound and the outbound audio of the call in two separate channels of the recording file                                                                                                                                                       |

## How to configure Single Party Call Recording

You can enable single party recording for any given call using the following Twilio's Programmable Voice APIs:

* [TwiML \<Dial>](/docs/voice/twiml/dial)
* [Outbound Calls API](/docs/voice/api/call-resource)
* [Call Recording Controls API](/docs/video/api/recordings-resource)
* [Conference Participant API](/docs/voice/api/conference-participant-resource)

> \[!NOTE]
>
> This feature is not yet available in TwiML \<Record> or \<Conference>. SIP Trunking calls also do not currently support this functionality.

Set RecordingTrack on a new outbound Call

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createCall() {
  const call = await client.calls.create({
    from: "+14155552344",
    record: true,
    recordingTrack: "outbound",
    to: "+14155552345",
    url: "https://www.example.com",
  });

  console.log(call.sid);
}

createCall();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

call = client.calls.create(
    record=True,
    recording_track="outbound",
    to="+14155552345",
    from_="+14155552344",
    url="https://www.example.com",
)

print(call.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var call = await CallResource.CreateAsync(
            record: true,
            recordingTrack: "outbound",
            to: new Twilio.Types.PhoneNumber("+14155552345"),
            from: new Twilio.Types.PhoneNumber("+14155552344"),
            url: new Uri("https://www.example.com"));

        Console.WriteLine(call.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.net.URI;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Call;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Call call = Call.creator(new com.twilio.type.PhoneNumber("+14155552345"),
                            new com.twilio.type.PhoneNumber("+14155552344"),
                            URI.create("https://www.example.com"))
                        .setRecord(true)
                        .setRecordingTrack("outbound")
                        .create();

        System.out.println(call.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	api "github.com/twilio/twilio-go/rest/api/v2010"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &api.CreateCallParams{}
	params.SetRecord(true)
	params.SetRecordingTrack("outbound")
	params.SetTo("+14155552345")
	params.SetFrom("+14155552344")
	params.SetUrl("https://www.example.com")

	resp, err := client.Api.CreateCall(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$token = $_ENV["TWILIO_AUTH_TOKEN"];
$twilio = new Client($sid, $token);

$call = $twilio->calls->create(
    "+14155552345", // To
    "+14155552344", // From
    [
        "record" => true,
        "recordingTrack" => "outbound",
        "url" => "https://www.example.com",
    ],
);

print $call->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

call = @client
       .api
       .v2010
       .calls
       .create(
         record: true,
         recording_track: 'outbound',
         to: '+14155552345',
         from: '+14155552344',
         url: 'https://www.example.com'
       )

puts call.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:core:calls:create \
   --record \
   --recording-track outbound \
   --to +14155552345 \
   --from +14155552344 \
   --url https://www.example.com
```

```bash
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Calls.json" \
--data-urlencode "Record=true" \
--data-urlencode "RecordingTrack=outbound" \
--data-urlencode "To=+14155552345" \
--data-urlencode "From=+14155552344" \
--data-urlencode "Url=https://www.example.com" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "answered_by": null,
  "api_version": "2010-04-01",
  "caller_name": null,
  "date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
  "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
  "direction": "inbound",
  "duration": "15",
  "end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
  "forwarded_from": "+141586753093",
  "from": "+14155552344",
  "from_formatted": "(415) 867-5308",
  "group_sid": null,
  "parent_call_sid": null,
  "phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "price": "-0.03000",
  "price_unit": "USD",
  "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
  "status": "completed",
  "subresource_uris": {
    "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",
    "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
    "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",
    "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",
    "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",
    "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",
    "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json",
    "user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json",
    "user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json"
  },
  "to": "+14155552345",
  "to_formatted": "(415) 867-5309",
  "trunk_sid": null,
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
  "queue_time": "1000"
}
```

> \[!WARNING]
>
> The default value of the `record` attribute is `do-not-record`. Make sure you set this to `true` as it will not be automatically enabled regardless of `RecordingTrack` property.

Record a side of an ongoing call

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createCallRecording() {
  const recording = await client
    .calls("CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .recordings.create({ recordingTrack: "inbound" });

  console.log(recording.accountSid);
}

createCallRecording();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

recording = client.calls(
    "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).recordings.create(recording_track="inbound")

print(recording.account_sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account.Call;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var recording = await RecordingResource.CreateAsync(
            recordingTrack: "inbound", pathCallSid: "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(recording.AccountSid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.call.Recording;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Recording recording =
            Recording.creator("CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").setRecordingTrack("inbound").create();

        System.out.println(recording.getAccountSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	api "github.com/twilio/twilio-go/rest/api/v2010"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &api.CreateCallRecordingParams{}
	params.SetRecordingTrack("inbound")

	resp, err := client.Api.CreateCallRecording("CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.AccountSid != nil {
			fmt.Println(*resp.AccountSid)
		} else {
			fmt.Println(resp.AccountSid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$token = $_ENV["TWILIO_AUTH_TOKEN"];
$twilio = new Client($sid, $token);

$recording = $twilio
    ->calls("CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->recordings->create(["recordingTrack" => "inbound"]);

print $recording->accountSid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

recording = @client
            .api
            .v2010
            .calls('CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
            .recordings
            .create(recording_track: 'inbound')

puts recording.account_sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:core:calls:recordings:create \
   --call-sid CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --recording-track inbound
```

```bash
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json" \
--data-urlencode "RecordingTrack=inbound" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "api_version": "2010-04-01",
  "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "conference_sid": null,
  "channels": 2,
  "date_created": "Fri, 14 Oct 2016 21:56:34 +0000",
  "date_updated": "Fri, 14 Oct 2016 21:56:34 +0000",
  "start_time": "Fri, 14 Oct 2016 21:56:34 +0000",
  "price": null,
  "price_unit": null,
  "duration": null,
  "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "source": "StartCallRecordingAPI",
  "status": "in-progress",
  "error_code": null,
  "encryption_details": null,
  "track": "both",
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
}
```

Configure recording party when adding a new participant to a conference

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createParticipant() {
  const participant = await client
    .conferences("ConferenceSid")
    .participants.create({
      from: "+14155552344",
      record: true,
      recordingTrack: "inbound",
      to: "+14155552345",
    });

  console.log(participant.accountSid);
}

createParticipant();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

participant = client.conferences("ConferenceSid").participants.create(
    record=True,
    recording_track="inbound",
    from_="+14155552344",
    to="+14155552345",
)

print(participant.account_sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account.Conference;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var participant = await ParticipantResource.CreateAsync(
            record: true,
            recordingTrack: "inbound",
            from: new Twilio.Types.PhoneNumber("+14155552344"),
            to: new Twilio.Types.PhoneNumber("+14155552345"),
            pathConferenceSid: "ConferenceSid");

        Console.WriteLine(participant.AccountSid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.conference.Participant;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Participant participant = Participant
                                      .creator("ConferenceSid",
                                          new com.twilio.type.PhoneNumber("+14155552344"),
                                          new com.twilio.type.PhoneNumber("+14155552345"))
                                      .setRecord(true)
                                      .setRecordingTrack("inbound")
                                      .create();

        System.out.println(participant.getAccountSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	api "github.com/twilio/twilio-go/rest/api/v2010"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &api.CreateParticipantParams{}
	params.SetRecord(true)
	params.SetRecordingTrack("inbound")
	params.SetFrom("+14155552344")
	params.SetTo("+14155552345")

	resp, err := client.Api.CreateParticipant("ConferenceSid",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.AccountSid != nil {
			fmt.Println(*resp.AccountSid)
		} else {
			fmt.Println(resp.AccountSid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$token = $_ENV["TWILIO_AUTH_TOKEN"];
$twilio = new Client($sid, $token);

$participant = $twilio->conferences("ConferenceSid")->participants->create(
    "+14155552344", // From
    "+14155552345", // To
    [
        "record" => true,
        "recordingTrack" => "inbound",
    ],
);

print $participant->accountSid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

participant = @client
              .api
              .v2010
              .conferences('ConferenceSid')
              .participants
              .create(
                record: true,
                recording_track: 'inbound',
                from: '+14155552344',
                to: '+14155552345'
              )

puts participant.account_sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:core:conferences:participants:create \
   --conference-sid ConferenceSid \
   --record \
   --recording-track inbound \
   --from +14155552344 \
   --to +14155552345
```

```bash
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Conferences/ConferenceSid/Participants.json" \
--data-urlencode "Record=true" \
--data-urlencode "RecordingTrack=inbound" \
--data-urlencode "From=+14155552344" \
--data-urlencode "To=+14155552345" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "label": "customer",
  "conference_sid": "ConferenceSid",
  "date_created": "Fri, 18 Feb 2011 21:07:19 +0000",
  "date_updated": "Fri, 18 Feb 2011 21:07:19 +0000",
  "end_conference_on_exit": false,
  "muted": false,
  "hold": false,
  "status": "queued",
  "start_conference_on_enter": true,
  "coaching": false,
  "call_sid_to_coach": null,
  "queue_time": "1000",
  "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
}
```

### Configure recording party using \<Dial>

Use `<Dial>` verb to dial a new participant from an active ongoing call and record the call specifying what audio should be recorded using recordingTrack parameter. The following example illustrates how to record the inbound audio:

> \[!WARNING]
>
> The default value of the `record` attribute is `do-not-record`. Make sure you set this to `true` as it will not be automatically enabled regardless of `RecordingTrack` property.

Record only the inbound track of the call

```js
const VoiceResponse = require('twilio').twiml.VoiceResponse;

const response = new VoiceResponse();
const dial = response.dial({
  record: 'record-from-answer',
  recordingTrack: 'inbound',
  recordingStatusCallback: 'https://www.myexample.com/recording-handler',
});
dial.number('+15551239876');

console.log(response.toString());
```

```py
from twilio.twiml.voice_response import Dial, Number, VoiceResponse

response = VoiceResponse()
dial = Dial(
    record='record-from-answer',
    recording_track='inbound',
    recording_status_callback='https://www.myexample.com/recording-handler'
)
dial.number('+15551239876')
response.append(dial)

print(response)
```

```cs
using System;
using Twilio.TwiML;
using Twilio.TwiML.Voice;


class Example
{
    static void Main()
    {
        var response = new VoiceResponse();
        var dial = new Dial(record: Dial.RecordEnum.RecordFromAnswer, recordingTrack: "inbound", recordingStatusCallback: new Uri("https://www.myexample.com/recording-handler"));
        dial.Number("+15551239876");
        response.Append(dial);

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

```java
import com.twilio.twiml.voice.Dial;
import com.twilio.twiml.voice.Number;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.TwiMLException;


public class Example {
    public static void main(String[] args) {
        Number number = new Number.Builder("+15551239876").build();
        Dial dial = new Dial.Builder().record(Dial.Record.RECORD_FROM_ANSWER)
            .recordingTrack(Dial.RecordingTrack.INBOUND)
            .recordingStatusCallback("https://www.myexample.com/recording-handler").number(number).build();
        VoiceResponse response = new VoiceResponse.Builder().dial(dial).build();

        try {
            System.out.println(response.toXml());
        } catch (TwiMLException e) {
            e.printStackTrace();
        }
    }
}
```

```php
<?php
require_once './vendor/autoload.php';
use Twilio\TwiML\VoiceResponse;

$response = new VoiceResponse();
$dial = $response->dial('', ['record' => 'record-from-answer', 'recordingTrack' => 'inbound', 'recordingStatusCallback' => 'https://www.myexample.com/recording-handler']);
$dial->number('+15551239876');

echo $response;
```

```rb
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new
response.dial(record: 'record-from-answer', recording_track: 'inbound', recording_status_callback: 'https://www.myexample.com/recording-handler') do |dial|
    dial.number('+15551239876')
end

puts response
```

```xml
<Response>
    <Dial record="record-from-answer" 
        recordingTrack="inbound" 
        recordingStatusCallback="https://www.myexample.com/recording-handler">
        <Number>+15551239876</Number>
    </Dial>
</Response>
```

## How to determine which track has been recorded

The request made to [recordingStatusCallback](/docs/voice/api/recording#recordingstatuscallback) contains the `track` attribute to indicate which audio track was recorded. It is recommended to subscribe to the recordings callback in order to know which audio track has been chosen.

You can also check this information from the call recordings log in [Twilio Console](https://1console.twilio.com/go?to=/account/__account__/us1/logs/call-recordings) or the [legacy Console](https://www.twilio.com/console/voice/recordings/recording-logs).

## Use cases for recording a single side of a call with Twilio Programmable Voice

This guide teaches the basics required for the following use cases:

### Create self-service automation with Twilio Programmable Voice

You can use this guide to record only the caller's side of the interaction when they interact with an IVR. This allows you to analyze customer responses without including the automated prompts in the recording file.

To learn more advanced features that you can use with self-service automation, see [Voice self-service automation](/docs/voice/guides/self-service-automation).

### Create an inbound contact center with Twilio Programmable Voice

You can use this guide to record specifically the agent or the customer side of a call. This is useful for quality assurance and training purposes where individual track isolation is required.

To learn more advanced features that you can use with inbound contact centers, see [Voice inbound contact center](/docs/voice/guides/inbound-call-center).

### Create an outbound contact center with Twilio Programmable Voice

You can use this guide to isolate the audio of your agents during outbound campaigns. Recording a single track simplifies the process of reviewing agent performance and compliance.

To learn more advanced features that you can use with outbound contact centers, see [Voice outbound call center](/docs/voice/guides/outbound-call-center).

### Create a sales dialer with Twilio Programmable Voice

You can use this guide to record sales pitches or customer feedback during outbound sales calls. Isolating tracks helps in cleaning up audio for CRM logging and sales coaching.

To learn more advanced features that you can use with sales dialers, see [Voice sales dialer](/docs/voice/guides/sales-dialer).

### Create call tracking with Twilio Programmable Voice

You can use this guide to record and analyze specific participants in a tracked call. This helps in identifying which party initiated specific keywords or sentiments during the conversation.

To learn more advanced features that you can use with call tracking, see [Voice call tracking](/docs/voice/guides/call-tracking).

### Create transcriptions for AI or ML with Twilio Programmable Voice

You can use this guide to capture clean, single-sided audio for high-accuracy AI transcription. By isolating the inbound track, you ensure that the machine learning model only processes the speaker's voice without background noise or Twilio-generated audio.

To learn more advanced features that you can use with AI or ML transcription, see [Voice AI/ML transcription](/docs/voice/guides/ai-ml-transcription).

## Result

After following this guide, you can programmatically record a single side of a call using Twilio Programmable Voice. You can verify this by checking the `track` attribute in your `recordingStatusCallback` or by viewing the recording logs in the Twilio Console to confirm only one audio track was captured.

## Next steps

Explore the following guides to build on what you've learned in this guide:

* [Record phone calls](/docs/voice/tutorials/how-to-record-phone-calls): Learn the fundamentals of recording entire calls with Twilio.
* [Create conference calls](/docs/voice/tutorials/how-to-create-conference-calls): Understand how to manage and record multi-party conversations.
* [Voice recording encryption](/docs/voice/tutorials/voice-recording-encryption): Secure your recording files using public key encryption.

## Related reference documentation

Find reference documentation for the topics on this page.

* [Call resource](/docs/voice/api/call-resource)
* [Conferences Participants subresource](/docs/voice/api/conference-participant-resource)
* [Recordings resource](/docs/voice/api/recording-transcription)
* [TwiML™ Voice: `<Dial>`](/docs/voice/twiml/dial)
