# Inbound Phone Number Report Resource

## Overview

> \[!NOTE]
>
> **Not a HIPAA Eligible Service**
>
> Voice Insights Reports API is not a HIPAA Eligible Service and should not be used in workflows that are subject to HIPAA.

An **Inbound Phone Number Report** aggregates Voice Insights metrics for calls received by a specific phone number handle.

## Inbound Phone Number Report Properties

<OperationTable
  type="body"
  data={{
    encodingType: "application/json",
    schema: {
      type: "object",
      properties: {
        handle: {
          type: "string",
          'x-twilio': {
            shortDescription: "Inbound callee.",
            pii: { handling: "standard", deleteSla: 30 },
          },
          description: "Inbound phone number handle represented in the report.",
        },
        total_calls: {
          type: "integer",
          description: "Total number of inbound calls observed during the report period.",
        },
        call_answer_score: {
          type: "number",
          format: "float",
          description: "Score (0-100) representing how often inbound calls were answered.",
        },
        call_state_percentage: {
          type: "object",
          description: "Percentage of calls by call state (completed, fail, busy, no-answer, canceled).",
          properties: {
            completed: {
              type: "number",
              format: "float",
              description: "Percentage of completed state inbound calls.",
            },
            fail: {
              type: "number",
              format: "float",
              description: "Percentage of failed state inbound calls.",
            },
            busy: {
              type: "number",
              format: "float",
              description: "Percentage of inbound calls that received a busy signal.",
            },
            noanswer: {
              type: "number",
              format: "float",
              description: "Percentage of inbound calls that were rejected or not answered.",
            },
            canceled: {
              type: "number",
              format: "float",
              description: "Percentage of inbound calls which were hung up while it’s still ringing or in a queue.",
            },
          },
        },
        silent_calls_percentage: {
          type: "number",
          format: "float",
          description: "Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio.",
        },
      },
    },
  }}
/>

## Create Inbound Phone Numbers Report properties

> \[!NOTE]
>
> A Voice Insights Report will be available for 5 days after it is created.

```json
{"type":"object","refName":"insights.v2.create_report_response","modelName":"insights_v2_create_report_response","properties":{"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","description":"The unique SID identifier of the Account."},"report_id":{"type":"string","description":"The report identifier as Voice Insights Report TTID."},"status":{"type":"string","enum":["created","running","completed"],"description":"The status of the report.","refName":"report_status","modelName":"report_status"},"request_meta":{"type":"object","refName":"report_metadata","modelName":"report_metadata","properties":{"start_time":{"type":"string","format":"date-time","description":"Start time of the report"},"end_time":{"type":"string","format":"date-time","description":"End time of the report"},"filters":{"type":"array","default":[],"description":"Filter values applied to the report","items":{"type":"object","refName":"report_filter","modelName":"report_filter","properties":{"key":{"type":"string","description":"The name of the filter\n'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent'\n"},"values":{"type":"array","description":"List of supported filter values for the field name","items":{"type":"string"}}}}}}},"url":{"type":"string","format":"uri","nullable":true,"description":"The URL of this resource."}}}
```

## Create Inbound Phone Number Reports

`POST https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound`

### Request body parameters

```json
{"schema":{"type":"object","refName":"insights.v2.create_phone_numbers_report_request","modelName":"insights_v2_create_phone_numbers_report_request","properties":{"time_range":{"type":"object","properties":{"start_time":{"type":"string","format":"date-time","description":"Start time of the report","example":"2024-01-01T00:00:00Z","x-twilio":{"shortDescription":"Start time of the report"}},"end_time":{"type":"string","format":"date-time","description":"End time of the report","example":"2024-01-07T00:00:00Z","x-twilio":{"shortDescription":"Start time of the report"}}}},"filters":{"type":"array","items":{"type":"object","refName":"phone_number_report_filter","modelName":"phone_number_report_filter","properties":{"key":{"type":"string","description":"The name of the filter\n"},"values":{"type":"array","description":"List of supported filter values for the field name","items":{"type":"string"}}}}},"size":{"type":"integer","default":1000,"minimum":1,"maximum":6000,"description":"The number of max available top Phone Numbers to generate."}}},"encodingType":"application/json","conditionalParameterMap":{}}
```

The recent 7 days report can be created without any parameters.

Create Inbound Phone Number Reports

```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 createInboundPhoneNumbersReport() {
  const inbound = await client.insights.v2.inbound().create();

  console.log(inbound.accountSid);
}

createInboundPhoneNumbersReport();
```

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

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

inbound = client.insights.v2.inbound().create()

print(inbound.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Insights.V2;
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 inbound = await InboundResource.CreateAsync();

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

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

import com.twilio.Twilio;
import com.twilio.rest.insights.v2.Inbound;

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);
        Inbound inbound = Inbound.creator().create();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	insights "github.com/twilio/twilio-go/rest/insights/v2"
	"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 := &insights.CreateInboundPhoneNumbersReportParams{}

	resp, err := client.InsightsV2.CreateInboundPhoneNumbersReport(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} 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;
use Twilio\Rest\Insights\V2\InboundPhoneNumbersReportModels;

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

$inbound = $twilio->insights->v2->inbound()->create();

print $inbound->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)

inbound = @client
          .insights
          .v2
          .inbound
          .create

puts inbound.account_sid
```

```bash
# This endpoint is not currently supported by the Twilio CLI. You can open an issue to request it on https://github.com/twilio/twilio-cli/issues
  # For an alternative low-code solution, check out https://www.twilio.com/docs/openapi/using-twilio-postman-collections
```

```bash
curl -X POST "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "report_id": "voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av",
  "status": "created",
  "request_meta": {
    "start_time": "2024-11-01T00:00:00Z",
    "end_time": "2024-11-07T00:00:00Z",
    "filters": []
  },
  "url": "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound/voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av"
}
```

Generate inbound reports for a specific period by providing the `time_range` parameter.

Create Inbound Phone Number Reports with Date Time Range

```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 createInboundPhoneNumbersReport() {
  const inbound = await client.insights.v2.inbound().create({
    time_range: {
      start_datetime: "2024-10-15T00:00:00Z",
      end_datetime: "2024-11-07T00:00:00Z",
    },
  });

  console.log(inbound.accountSid);
}

createInboundPhoneNumbersReport();
```

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

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

inbound = client.insights.v2.inbound().create(
    insights_v2_create_phone_numbers_report_request=InboundPhoneNumbersReportList.InsightsV2CreatePhoneNumbersReportRequest(
        {
            "time_range": InboundPhoneNumbersReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange(
                {
                    "start_datetime": "2024-10-15T00:00:00Z",
                    "end_datetime": "2024-11-07T00:00:00Z",
                }
            )
        }
    )
)

print(inbound.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Insights.V2;
using System.Threading.Tasks;
using System.Collections.Generic;

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 inbound = await InboundResource.CreateAsync(
            insightsV2CreatePhoneNumbersReportRequest: new InboundResource
                .InsightsV2CreatePhoneNumbersReportRequest.Builder()
                .WithTimeRange(
                    new InboundResource.InsightsV2CreatePhoneNumbersReportRequestTimeRange.Builder()
                        .WithStartDatetime("2024-10-15T00:00:00Z")
                        .WithEndDatetime("2024-11-07T00:00:00Z")
                        .Build())
                .Build());

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

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

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.insights.v2.Inbound;

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

        Inbound.InsightsV2CreatePhoneNumbersReportRequestTimeRange timeRange =
            new Inbound.InsightsV2CreatePhoneNumbersReportRequestTimeRange();
        timeRange.setStartDatetime("2024-10-15T00:00:00Z");
        timeRange.setEndDatetime("2024-11-07T00:00:00Z");

        Inbound.InsightsV2CreatePhoneNumbersReportRequest insightsV2CreatePhoneNumbersReportRequest =
            new Inbound.InsightsV2CreatePhoneNumbersReportRequest();
        insightsV2CreatePhoneNumbersReportRequest.setTimeRange(insightsV2CreatePhoneNumbersReportRequestTimeRange);

        Inbound inbound = Inbound.creator(insightsV2CreatePhoneNumbersReportRequest).create();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	insights "github.com/twilio/twilio-go/rest/insights/v2"
	"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 := &insights.CreateInboundPhoneNumbersReportParams{}
	params.SetInsightsV2CreatePhoneNumbersReportRequest(insights.insights_v2_create_phone_numbers_report_request{
		TimeRange: insights.InsightsV2CreatePhoneNumbersReportRequestTimeRange{
			StartDatetime: "2024-10-15T00:00:00Z",
			EndDatetime:   "2024-11-07T00:00:00Z",
		},
	})

	resp, err := client.InsightsV2.CreateInboundPhoneNumbersReport(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} 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;
use Twilio\Rest\Insights\V2\InboundPhoneNumbersReportModels;

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

$inbound = $twilio->insights->v2->inbound()->create(
    InboundPhoneNumbersReportModels::createInsightsV2CreatePhoneNumbersReportRequest(
        [
            "timeRange" => InboundPhoneNumbersReportModels::createInsightsV2CreatePhoneNumbersReportRequestTimeRange(
                [
                    "startDatetime" => "2024-10-15T00:00:00Z",
                    "endDatetime" => "2024-11-07T00:00:00Z",
                ]
            ),
        ]
    )
);

print $inbound->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)

inbound = @client
          .insights
          .v2
          .inbound
          .create(
            insights_v2_create_phone_numbers_report_request: {
              'time_range' => {
                'start_datetime' => '2024-10-15T00:00:00Z',
                'end_datetime' => '2024-11-07T00:00:00Z'
              }
            }
          )

puts inbound.account_sid
```

```bash
# This endpoint is not currently supported by the Twilio CLI. You can open an issue to request it on https://github.com/twilio/twilio-cli/issues
  # For an alternative low-code solution, check out https://www.twilio.com/docs/openapi/using-twilio-postman-collections
```

```bash
INSIGHTS_V2_CREATE_PHONE_NUMBERS_REPORT_REQUEST_OBJ=$(cat << EOF
{
  "time_range": {
    "start_datetime": "2024-10-15T00:00:00Z",
    "end_datetime": "2024-11-07T00:00:00Z"
  }
}
EOF
)
curl -X POST "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound" \
--json "$INSIGHTS_V2_CREATE_PHONE_NUMBERS_REPORT_REQUEST_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "report_id": "voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av",
  "status": "created",
  "request_meta": {
    "start_time": "2024-11-01T00:00:00Z",
    "end_time": "2024-11-07T00:00:00Z",
    "filters": []
  },
  "url": "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound/voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av"
}
```

Generate a specific number of outbound reports by providing the `size` parameter.

Create Inbound Phone Number Reports with Specific Size

```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 createInboundPhoneNumbersReport() {
  const inbound = await client.insights.v2.inbound().create({
    time_range: {
      start_datetime: "2024-10-15T00:00:00Z",
      end_datetime: "2024-11-07T00:00:00Z",
    },
    size: 100,
  });

  console.log(inbound.accountSid);
}

createInboundPhoneNumbersReport();
```

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

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

inbound = client.insights.v2.inbound().create(
    insights_v2_create_phone_numbers_report_request=InboundPhoneNumbersReportList.InsightsV2CreatePhoneNumbersReportRequest(
        {
            "time_range": InboundPhoneNumbersReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange(
                {
                    "start_datetime": "2024-10-15T00:00:00Z",
                    "end_datetime": "2024-11-07T00:00:00Z",
                }
            ),
            "size": 100,
        }
    )
)

print(inbound.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Insights.V2;
using System.Threading.Tasks;
using System.Collections.Generic;

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 inbound = await InboundResource.CreateAsync(
            insightsV2CreatePhoneNumbersReportRequest: new InboundResource
                .InsightsV2CreatePhoneNumbersReportRequest.Builder()
                .WithTimeRange(
                    new InboundResource.InsightsV2CreatePhoneNumbersReportRequestTimeRange.Builder()
                        .WithStartDatetime("2024-10-15T00:00:00Z")
                        .WithEndDatetime("2024-11-07T00:00:00Z")
                        .Build())
                .WithSize(100)
                .Build());

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

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

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.insights.v2.Inbound;

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

        Inbound.InsightsV2CreatePhoneNumbersReportRequestTimeRange timeRange =
            new Inbound.InsightsV2CreatePhoneNumbersReportRequestTimeRange();
        timeRange.setStartDatetime("2024-10-15T00:00:00Z");
        timeRange.setEndDatetime("2024-11-07T00:00:00Z");

        Inbound.InsightsV2CreatePhoneNumbersReportRequest insightsV2CreatePhoneNumbersReportRequest =
            new Inbound.InsightsV2CreatePhoneNumbersReportRequest();
        insightsV2CreatePhoneNumbersReportRequest.setTimeRange(insightsV2CreatePhoneNumbersReportRequestTimeRange);
        insightsV2CreatePhoneNumbersReportRequest.setSize(100);

        Inbound inbound = Inbound.creator(insightsV2CreatePhoneNumbersReportRequest).create();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	insights "github.com/twilio/twilio-go/rest/insights/v2"
	"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 := &insights.CreateInboundPhoneNumbersReportParams{}
	params.SetInsightsV2CreatePhoneNumbersReportRequest(insights.insights_v2_create_phone_numbers_report_request{
		TimeRange: insights.InsightsV2CreatePhoneNumbersReportRequestTimeRange{
			StartDatetime: "2024-10-15T00:00:00Z",
			EndDatetime:   "2024-11-07T00:00:00Z",
		},
		Size: 100,
	})

	resp, err := client.InsightsV2.CreateInboundPhoneNumbersReport(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} 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;
use Twilio\Rest\Insights\V2\InboundPhoneNumbersReportModels;

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

$inbound = $twilio->insights->v2->inbound()->create(
    InboundPhoneNumbersReportModels::createInsightsV2CreatePhoneNumbersReportRequest(
        [
            "timeRange" => InboundPhoneNumbersReportModels::createInsightsV2CreatePhoneNumbersReportRequestTimeRange(
                [
                    "startDatetime" => "2024-10-15T00:00:00Z",
                    "endDatetime" => "2024-11-07T00:00:00Z",
                ]
            ),
            "size" => 100,
        ]
    )
);

print $inbound->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)

inbound = @client
          .insights
          .v2
          .inbound
          .create(
            insights_v2_create_phone_numbers_report_request: {
              'time_range' => {
                'start_datetime' => '2024-10-15T00:00:00Z',
                'end_datetime' => '2024-11-07T00:00:00Z'
              },
              'size' => 100
            }
          )

puts inbound.account_sid
```

```bash
# This endpoint is not currently supported by the Twilio CLI. You can open an issue to request it on https://github.com/twilio/twilio-cli/issues
  # For an alternative low-code solution, check out https://www.twilio.com/docs/openapi/using-twilio-postman-collections
```

```bash
INSIGHTS_V2_CREATE_PHONE_NUMBERS_REPORT_REQUEST_OBJ=$(cat << EOF
{
  "time_range": {
    "start_datetime": "2024-10-15T00:00:00Z",
    "end_datetime": "2024-11-07T00:00:00Z"
  },
  "size": 100
}
EOF
)
curl -X POST "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound" \
--json "$INSIGHTS_V2_CREATE_PHONE_NUMBERS_REPORT_REQUEST_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "report_id": "voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av",
  "status": "created",
  "request_meta": {
    "start_time": "2024-11-01T00:00:00Z",
    "end_time": "2024-11-07T00:00:00Z",
    "filters": []
  },
  "url": "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound/voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av"
}
```

## Fetch Inbound Phone Number Reports

`GET https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound/{reportId}`

### Path parameters

```json
[{"name":"reportId","in":"path","description":"A unique Report Id.","schema":{"type":"string"},"required":true}]
```

### Query parameters

```json
[{"name":"PageSize","in":"query","description":"How many resources to return in each list page.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":1000}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

Fetch Inbound Phone Number Reports

```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 listInboundPhoneNumbersReport() {
  const inbounds = await client.insights.v2
    .inbound("voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av")
    .list({ limit: 20 });

  inbounds.forEach((i) => console.log(i.handle));
}

listInboundPhoneNumbersReport();
```

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

inbounds = client.insights.v2.inbound(
    "voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av"
).list(limit=20)

for record in inbounds:
    print(record.handle)
```

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

using System;
using Twilio;
using Twilio.Rest.Insights.V2;
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 inbounds = await InboundResource.ReadAsync(
            pathReportId: "voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av", limit: 20);

        foreach (var record in inbounds) {
            Console.WriteLine(record.Handle);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.insights.v2.Inbound;
import com.twilio.base.ResourceSet;

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);
        ResourceSet<Inbound> inbounds =
            Inbound.reader("voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av").limit(20).read();

        for (Inbound record : inbounds) {
            System.out.println(record.getHandle());
        }
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	insights "github.com/twilio/twilio-go/rest/insights/v2"
	"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 := &insights.ListInboundPhoneNumbersReportParams{}
	params.SetLimit(20)

	resp, err := client.InsightsV2.ListInboundPhoneNumbersReport("voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			fmt.Println(resp[record].Handle)
		}
	}
}
```

```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 = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$inbounds = $twilio->insights->v2
    ->inbound("voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av")
    ->read(20);

foreach ($inbounds as $record) {
    print $record->handle;
}
```

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

inbounds = @client
           .insights
           .v2
           .inbound('voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av')
           .list(limit: 20)

inbounds.each do |record|
   puts record.handle
end
```

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

twilio api:insights:v2:voice:reports:phone-numbers:inbound:list \
   --report-id voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av
```

```bash
curl -X GET "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound/voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound/voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://insights.twilio.com/v2/Voice/Reports/PhoneNumbers/Inbound/voiceinsights_report_01jmzm99cte5rrbbhv8bctd4av?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "reports"
  },
  "reports": []
}
```
