# Regulation Resource

## Regulations Response Properties

The Twilio Regulatory Compliance REST API allows you to view and understand Regulations. Regulations are requirements based on [End-Users](/docs/phone-numbers/regulatory/api/end-users) and [Supporting Documents](/docs/phone-numbers/regulatory/api/supporting-documents) set for by each country's government.

A Regulation dictates the [Regulatory Bundles](/docs/phone-numbers/regulatory/api/bundles) composition of [Item Assignments](/docs/phone-numbers/regulatory/api/item-assignments).

> \[!CAUTION]
>
> Regulations can and do change. Please make sure not to hardcode any regulation within your application. The Regulation resource is for you to call and populate the values required for regulatory compliance.

```json
{"type":"object","refName":"numbers.v2.regulatory_compliance.regulation","modelName":"numbers_v2_regulatory_compliance_regulation","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RN[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that identifies the Regulation resource."},"friendly_name":{"type":"string","nullable":true,"description":"A human-readable description that is assigned to describe the Regulation resource. Examples can include Germany: Mobile - Business."},"iso_country":{"type":"string","nullable":true,"description":"The ISO country code of the phone number's country."},"number_type":{"type":"string","nullable":true,"description":"The type of phone number restricted by the regulatory requirement. For example, Germany mobile phone numbers provisioned by businesses require a business name with commercial register proof from the Handelsregisterauszug and a proof of address from Handelsregisterauszug or a trade license by Gewerbeanmeldung."},"end_user_type":{"type":"string","enum":["individual","business"],"description":"The type of End User the regulation requires - can be `individual` or `business`.","refName":"regulation_enum_end_user_type","modelName":"regulation_enum_end_user_type"},"requirements":{"nullable":true,"description":"The SID of an object that holds the regulatory information of the phone number country, phone number type, and end user type."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the Regulation resource."}}}
```

## Fetch a Regulation Instance

`GET https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations/{Sid}`

A Regulation instance details the [End-User Types](/docs/phone-numbers/regulatory/api/end-user-types) and values along with [Supporting Document Types](/docs/phone-numbers/regulatory/api/supporting-document-types).

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The unique string that identifies the Regulation resource.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^RN[0-9a-fA-F]{32}$"},"required":true}]
```

### Query parameters

```json
[{"name":"IncludeConstraints","in":"query","description":"A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields","schema":{"type":"boolean"},"examples":{"fetch":{"value":true}}}]
```

Fetch a Regulation Instance

```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 fetchRegulation() {
  const regulation = await client.numbers.v2.regulatoryCompliance
    .regulations("RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(regulation.sid);
}

fetchRegulation();
```

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

regulation = client.numbers.v2.regulatory_compliance.regulations(
    "RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).fetch()

print(regulation.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Numbers.V2.RegulatoryCompliance;
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 regulation =
            await RegulationResource.FetchAsync(pathSid: "RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.numbers.v2.regulatorycompliance.Regulation;

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);
        Regulation regulation = Regulation.fetcher("RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch();

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

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

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

	resp, err := client.NumbersV2.FetchRegulation("RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		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 = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$regulation = $twilio->numbers->v2->regulatoryCompliance
    ->regulations("RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

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

regulation = @client
             .numbers
             .v2
             .regulatory_compliance
             .regulations('RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
             .fetch

puts regulation.sid
```

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

twilio api:numbers:v2:regulatory-compliance:regulations:fetch \
   --sid RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations/RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "friendly_name": "Australia: Local - Individual",
  "iso_country": "AU",
  "number_type": "local",
  "end_user_type": "individual",
  "requirements": {
    "end_user": [
      {
        "name": "Individual",
        "type": "individual",
        "requirement_name": "individual_info",
        "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations/individual",
        "fields": [
          "first_name",
          "last_name"
        ],
        "detailed_fields": [
          {
            "machine_name": "first_name",
            "friendly_name": "First Name",
            "description": "First name of the Individual"
          },
          {
            "machine_name": "last_name",
            "friendly_name": "Last Name",
            "description": "Last name of the Individual"
          }
        ]
      }
    ],
    "supporting_document": [
      [
        {
          "name": "Address",
          "type": "document",
          "requirement_name": "proof_of_address",
          "description": "The physical location of the individual or business. Must be within locality or region covered by the phone numbers prefix; a PO Box is not acceptable where a local address is required.",
          "accepted_documents": [
            {
              "name": "Address Validation",
              "type": "address",
              "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/DocumentTypes/address",
              "fields": [
                "address_sids"
              ],
              "detailed_fields": [
                {
                  "machine_name": "address_sids",
                  "friendly_name": "Address sid(s)",
                  "description": "Address sid of the individual"
                }
              ]
            }
          ]
        }
      ]
    ]
  },
  "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations/RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Retrieve a list of regulations

`GET https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations`

The Regulations list is extensive and covers all Twilio's countries in the [Phone Number Regulations Guidelines](https://www.twilio.com/en-us/guidelines/regulatory).

The Regulations `LIST` endpoint is filterable by `IsoCountry`, `NumberType`, and `EndUserType` so you can select the correct instance of the collection of regulatory requirements.

### Query parameters

```json
[{"name":"EndUserType","in":"query","description":"The type of End User the regulation requires - can be `individual` or `business`.","schema":{"type":"string","enum":["individual","business"],"description":"The type of End User the regulation requires - can be `individual` or `business`.","refName":"regulation_enum_end_user_type","modelName":"regulation_enum_end_user_type"},"examples":{"readEmpty":{"value":"business"}}},{"name":"IsoCountry","in":"query","description":"The ISO country code of the phone number's country.","schema":{"type":"string"},"examples":{"readEmpty":{"value":"US"}}},{"name":"NumberType","in":"query","description":"The type of phone number that the regulatory requiremnt is restricting.","schema":{"type":"string"},"examples":{"readEmpty":{"value":"mobile"}}},{"name":"IncludeConstraints","in":"query","description":"A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields","schema":{"type":"boolean"},"examples":{"readEmpty":{"value":true}}},{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 1000.","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"}}]
```

Retrieve a list of regulations

```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 listRegulation() {
  const regulations =
    await client.numbers.v2.regulatoryCompliance.regulations.list({
      endUserType: "individual",
      isoCountry: "au",
      numberType: "local",
      limit: 20,
    });

  regulations.forEach((r) => console.log(r.sid));
}

listRegulation();
```

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

regulations = client.numbers.v2.regulatory_compliance.regulations.list(
    end_user_type="individual", iso_country="au", number_type="local", limit=20
)

for record in regulations:
    print(record.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Numbers.V2.RegulatoryCompliance;
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 regulations = await RegulationResource.ReadAsync(
            endUserType: RegulationResource.EndUserTypeEnum.Individual,
            isoCountry: "au",
            numberType: "local",
            limit: 20);

        foreach (var record in regulations) {
            Console.WriteLine(record.Sid);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.numbers.v2.regulatorycompliance.Regulation;
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<Regulation> regulations = Regulation.reader()
                                                  .setEndUserType(Regulation.EndUserType.INDIVIDUAL)
                                                  .setIsoCountry("au")
                                                  .setNumberType("local")
                                                  .limit(20)
                                                  .read();

        for (Regulation record : regulations) {
            System.out.println(record.getSid());
        }
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	numbers "github.com/twilio/twilio-go/rest/numbers/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 := &numbers.ListRegulationParams{}
	params.SetEndUserType("individual")
	params.SetIsoCountry("au")
	params.SetNumberType("local")
	params.SetLimit(20)

	resp, err := client.NumbersV2.ListRegulation(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].Sid != nil {
				fmt.Println(*resp[record].Sid)
			} else {
				fmt.Println(resp[record].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 = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$regulations = $twilio->numbers->v2->regulatoryCompliance->regulations->read(
    [
        "endUserType" => "individual",
        "isoCountry" => "au",
        "numberType" => "local",
    ],
    20
);

foreach ($regulations as $record) {
    print $record->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)

regulations = @client
              .numbers
              .v2
              .regulatory_compliance
              .regulations
              .list(
                end_user_type: 'individual',
                iso_country: 'au',
                number_type: 'local',
                limit: 20
              )

regulations.each do |record|
   puts record.sid
end
```

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

twilio api:numbers:v2:regulatory-compliance:regulations:list \
   --end-user-type individual \
   --iso-country au \
   --number-type local
```

```bash
curl -X GET "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations?EndUserType=individual&IsoCountry=au&NumberType=local&PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "results": [
    {
      "sid": "RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "friendly_name": "Australia: Local - Individual",
      "iso_country": "AU",
      "number_type": "local",
      "end_user_type": "individual",
      "requirements": {
        "end_user": [
          {
            "name": "Individual",
            "type": "individual",
            "requirement_name": "individual_info",
            "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations/individual",
            "fields": [
              "first_name",
              "last_name"
            ],
            "detailed_fields": [
              {
                "machine_name": "first_name",
                "friendly_name": "First Name",
                "description": "First name of the Individual"
              },
              {
                "machine_name": "last_name",
                "friendly_name": "Last Name",
                "description": "Last name of the Individual"
              }
            ]
          }
        ],
        "supporting_document": [
          [
            {
              "name": "Address",
              "type": "document",
              "requirement_name": "proof_of_address",
              "description": "The physical location of the individual or business. Must be within locality or region covered by the phone numbers prefix; a PO Box is not acceptable where a local address is required.",
              "accepted_documents": [
                {
                  "name": "Address Validation",
                  "type": "address",
                  "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/DocumentTypes/address",
                  "fields": [
                    "address_sids"
                  ],
                  "detailed_fields": [
                    {
                      "machine_name": "address_sids",
                      "friendly_name": "Address sid(s)",
                      "description": "Address sid of the individual"
                    }
                  ]
                }
              ]
            }
          ]
        ]
      },
      "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations/RNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://numbers.twilio.com/v2/RegulatoryCompliance/Regulations?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "results"
  }
}
```
