# OriginationUrl Resource

The OriginationUrl Resource represents the Origination SIP URL(s) of your [Trunk](/docs/sip-trunking/api/trunk-resource). OriginationUrls identify the network element entry point(s) into your communications infrastructure (e.g. IP-PBX, SBC). See [Origination Settings in the SIP Trunking configuration page](/docs/sip-trunking/sample-configuration)\
for more information.

## OriginationUrl Properties

```json
{"type":"object","refName":"trunking.v1.trunk.origination_url","modelName":"trunking_v1_trunk_origination_url","properties":{"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](/docs/iam/api/account) that created the OriginationUrl resource."},"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^OU[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the OriginationUrl resource."},"trunk_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^TK[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Trunk that owns the Origination URL."},"weight":{"type":"integer","default":0,"description":"The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority."},"enabled":{"type":"boolean","nullable":true,"description":"Whether the URL is enabled. The default is `true`."},"sip_url":{"type":"string","format":"uri","nullable":true,"description":"The SIP address you want Twilio to route your Origination calls to. This must be a `sip:` schema.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"friendly_name":{"type":"string","nullable":true,"description":"The string that you assigned to describe the resource."},"priority":{"type":"integer","default":0,"description":"The relative importance of the URI. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format."},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the resource."}}}
```

## Create an OriginationUrl resource

`POST https://trunking.twilio.com/v1/Trunks/{TrunkSid}/OriginationUrls`

### Path parameters

```json
[{"name":"TrunkSid","in":"path","description":"The SID of the Trunk to associate the resource with.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^TK[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateOriginationUrlRequest","required":["Weight","Priority","Enabled","FriendlyName","SipUrl"],"properties":{"Weight":{"type":"integer","description":"The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority."},"Priority":{"type":"integer","description":"The relative importance of the URI. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI."},"Enabled":{"type":"boolean","description":"Whether the URL is enabled. The default is `true`."},"FriendlyName":{"type":"string","description":"A descriptive string that you create to describe the resource. It can be up to 64 characters long."},"SipUrl":{"type":"string","format":"uri","description":"The SIP address you want Twilio to route your Origination calls to. This must be a `sip:` schema.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"Enabled\": true,\n  \"FriendlyName\": \"friendly_name\",\n  \"Priority\": 1,\n  \"Weight\": 1,\n  \"SipUrl\": \"sip://sip-box.com:1234\"\n}","meta":"","code":"{\n  \"Enabled\": true,\n  \"FriendlyName\": \"friendly_name\",\n  \"Priority\": 1,\n  \"Weight\": 1,\n  \"SipUrl\": \"sip://sip-box.com:1234\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Enabled\"","#7EE787"],[":","#C9D1D9"]," ",["true","#79C0FF"],[",","#C9D1D9"],"\n  ",["\"FriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"friendly_name\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Priority\"","#7EE787"],[":","#C9D1D9"]," ",["1","#79C0FF"],[",","#C9D1D9"],"\n  ",["\"Weight\"","#7EE787"],[":","#C9D1D9"]," ",["1","#79C0FF"],[",","#C9D1D9"],"\n  ",["\"SipUrl\"","#7EE787"],[":","#C9D1D9"]," ",["\"sip://sip-box.com:1234\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create Origination Url

```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 createOriginationUrl() {
  const originationUrl = await client.trunking.v1
    .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .originationUrls.create({
      enabled: false,
      friendlyName: "FriendlyName",
      priority: 42,
      sipUrl: "https://www.example.com",
      weight: 42,
    });

  console.log(originationUrl.accountSid);
}

createOriginationUrl();
```

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

origination_url = client.trunking.v1.trunks(
    "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).origination_urls.create(
    weight=42,
    priority=42,
    enabled=False,
    friendly_name="FriendlyName",
    sip_url="https://www.example.com",
)

print(origination_url.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Trunking.V1.Trunk;
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 originationUrl = await OriginationUrlResource.CreateAsync(
            weight: 42,
            priority: 42,
            enabled: false,
            friendlyName: "FriendlyName",
            sipUrl: new Uri("https://www.example.com"),
            pathTrunkSid: "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import java.net.URI;
import com.twilio.Twilio;
import com.twilio.rest.trunking.v1.trunk.OriginationUrl;

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);
        OriginationUrl originationUrl = OriginationUrl
                                            .creator("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                                                42,
                                                42,
                                                false,
                                                "FriendlyName",
                                                URI.create("https://www.example.com"))
                                            .create();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	trunking "github.com/twilio/twilio-go/rest/trunking/v1"
	"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 := &trunking.CreateOriginationUrlParams{}
	params.SetWeight(42)
	params.SetPriority(42)
	params.SetEnabled(false)
	params.SetFriendlyName("FriendlyName")
	params.SetSipUrl("https://www.example.com")

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

$origination_url = $twilio->trunking->v1
    ->trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->originationUrls->create(
        42, // Weight
        42, // Priority
        false, // Enabled
        "FriendlyName", // FriendlyName
        "https://www.example.com" // SipUrl
    );

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

origination_url = @client
                  .trunking
                  .v1
                  .trunks('TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                  .origination_urls
                  .create(
                    weight: 42,
                    priority: 42,
                    enabled: false,
                    friendly_name: 'FriendlyName',
                    sip_url: 'https://www.example.com'
                  )

puts origination_url.account_sid
```

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

twilio api:trunking:v1:trunks:origination-urls:create \
   --trunk-sid TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --weight 42 \
   --priority 42 \
   --enabled \
   --friendly-name FriendlyName \
   --sip-url https://www.example.com
```

```bash
curl -X POST "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls" \
--data-urlencode "Weight=42" \
--data-urlencode "Priority=42" \
--data-urlencode "Enabled=false" \
--data-urlencode "FriendlyName=FriendlyName" \
--data-urlencode "SipUrl=https://www.example.com" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "weight": 42,
  "date_updated": "2018-05-07T20:50:58Z",
  "enabled": false,
  "friendly_name": "FriendlyName",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "priority": 42,
  "sip_url": "https://www.example.com",
  "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2018-05-07T20:50:58Z",
  "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Fetch an OriginationUrl resource

`GET https://trunking.twilio.com/v1/Trunks/{TrunkSid}/OriginationUrls/{Sid}`

### Path parameters

```json
[{"name":"TrunkSid","in":"path","description":"The SID of the Trunk from which to fetch the OriginationUrl.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^TK[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The unique string that we created to identify the OriginationUrl resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^OU[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch Origination Url

```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 fetchOriginationUrl() {
  const originationUrl = await client.trunking.v1
    .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .originationUrls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(originationUrl.accountSid);
}

fetchOriginationUrl();
```

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

origination_url = (
    client.trunking.v1.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .origination_urls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch()
)

print(origination_url.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Trunking.V1.Trunk;
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 originationUrl = await OriginationUrlResource.FetchAsync(
            pathTrunkSid: "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.trunking.v1.trunk.OriginationUrl;

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);
        OriginationUrl originationUrl =
            OriginationUrl.fetcher("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"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()

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

$origination_url = $twilio->trunking->v1
    ->trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->originationUrls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

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

origination_url = @client
                  .trunking
                  .v1
                  .trunks('TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                  .origination_urls('OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                  .fetch

puts origination_url.account_sid
```

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

twilio api:trunking:v1:trunks:origination-urls:fetch \
   --trunk-sid TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "weight": 1,
  "date_updated": "2018-05-07T20:20:46Z",
  "enabled": false,
  "friendly_name": "friendly_name",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "priority": 1,
  "sip_url": "sip://sip-box.com:1234",
  "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2018-05-07T20:20:46Z",
  "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Read multiple OriginationUrl resources

`GET https://trunking.twilio.com/v1/Trunks/{TrunkSid}/OriginationUrls`

### Path parameters

```json
[{"name":"TrunkSid","in":"path","description":"The SID of the Trunk from which to read the OriginationUrl.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^TK[0-9a-fA-F]{32}$"},"required":true}]
```

### Query parameters

```json
[{"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"}}]
```

Read Origination Url

```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 listOriginationUrl() {
  const originationUrls = await client.trunking.v1
    .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .originationUrls.list({ limit: 20 });

  originationUrls.forEach((o) => console.log(o.accountSid));
}

listOriginationUrl();
```

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

origination_urls = client.trunking.v1.trunks(
    "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).origination_urls.list(limit=20)

for record in origination_urls:
    print(record.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Trunking.V1.Trunk;
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 originationUrls = await OriginationUrlResource.ReadAsync(
            pathTrunkSid: "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", limit: 20);

        foreach (var record in originationUrls) {
            Console.WriteLine(record.AccountSid);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.trunking.v1.trunk.OriginationUrl;
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<OriginationUrl> originationUrls =
            OriginationUrl.reader("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").limit(20).read();

        for (OriginationUrl record : originationUrls) {
            System.out.println(record.getAccountSid());
        }
    }
}
```

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

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

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

$originationUrls = $twilio->trunking->v1
    ->trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->originationUrls->read(20);

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

origination_urls = @client
                   .trunking
                   .v1
                   .trunks('TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                   .origination_urls
                   .list(limit: 20)

origination_urls.each do |record|
   puts record.account_sid
end
```

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

twilio api:trunking:v1:trunks:origination-urls:list \
   --trunk-sid TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "meta": {
    "first_page_url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls?PageSize=50&Page=0",
    "key": "origination_urls",
    "next_page_url": null,
    "page": 0,
    "page_size": 50,
    "previous_page_url": null,
    "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls?PageSize=50&Page=0"
  },
  "origination_urls": [
    {
      "weight": 1,
      "date_updated": "2018-05-09T20:47:35Z",
      "enabled": true,
      "friendly_name": "friendly_name",
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "priority": 1,
      "sip_url": "sip://sip-box.com:1234",
      "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "date_created": "2018-05-09T20:47:35Z",
      "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    }
  ]
}
```

## Update an OriginationUrl resource

`POST https://trunking.twilio.com/v1/Trunks/{TrunkSid}/OriginationUrls/{Sid}`

### Path parameters

```json
[{"name":"TrunkSid","in":"path","description":"The SID of the Trunk from which to update the OriginationUrl.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^TK[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The unique string that we created to identify the OriginationUrl resource to update.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^OU[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateOriginationUrlRequest","properties":{"Weight":{"type":"integer","description":"The value that determines the relative share of the load the URI should receive compared to other URIs with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. URLs with higher values receive more load than those with lower ones with the same priority."},"Priority":{"type":"integer","description":"The relative importance of the URI. Can be an integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important URI."},"Enabled":{"type":"boolean","description":"Whether the URL is enabled. The default is `true`."},"FriendlyName":{"type":"string","description":"A descriptive string that you create to describe the resource. It can be up to 64 characters long."},"SipUrl":{"type":"string","format":"uri","description":"The SIP address you want Twilio to route your Origination calls to. This must be a `sip:` schema. `sips` is NOT supported.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"FriendlyName\": \"updated_name\",\n  \"Weight\": 2,\n  \"Priority\": 2,\n  \"SipUrl\": \"sip://sip-updated.com:4321\",\n  \"Enabled\": false\n}","meta":"","code":"{\n  \"FriendlyName\": \"updated_name\",\n  \"Weight\": 2,\n  \"Priority\": 2,\n  \"SipUrl\": \"sip://sip-updated.com:4321\",\n  \"Enabled\": false\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"updated_name\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Weight\"","#7EE787"],[":","#C9D1D9"]," ",["2","#79C0FF"],[",","#C9D1D9"],"\n  ",["\"Priority\"","#7EE787"],[":","#C9D1D9"]," ",["2","#79C0FF"],[",","#C9D1D9"],"\n  ",["\"SipUrl\"","#7EE787"],[":","#C9D1D9"]," ",["\"sip://sip-updated.com:4321\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Enabled\"","#7EE787"],[":","#C9D1D9"]," ",["false","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update Origination Url

```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 updateOriginationUrl() {
  const originationUrl = await client.trunking.v1
    .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .originationUrls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .update({ weight: 42 });

  console.log(originationUrl.accountSid);
}

updateOriginationUrl();
```

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

origination_url = (
    client.trunking.v1.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .origination_urls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .update(weight=42)
)

print(origination_url.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Trunking.V1.Trunk;
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 originationUrl = await OriginationUrlResource.UpdateAsync(
            weight: 42,
            pathTrunkSid: "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

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

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

import com.twilio.Twilio;
import com.twilio.rest.trunking.v1.trunk.OriginationUrl;

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);
        OriginationUrl originationUrl =
            OriginationUrl.updater("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .setWeight(42)
                .update();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	trunking "github.com/twilio/twilio-go/rest/trunking/v1"
	"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 := &trunking.UpdateOriginationUrlParams{}
	params.SetWeight(42)

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

$origination_url = $twilio->trunking->v1
    ->trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->originationUrls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->update(["weight" => 42]);

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

origination_url = @client
                  .trunking
                  .v1
                  .trunks('TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                  .origination_urls('OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                  .update(weight: 42)

puts origination_url.account_sid
```

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

twilio api:trunking:v1:trunks:origination-urls:update \
   --trunk-sid TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --weight 42
```

```bash
curl -X POST "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--data-urlencode "Weight=42" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "weight": 42,
  "date_updated": "2018-05-07T20:50:58Z",
  "enabled": false,
  "friendly_name": "updated_name",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "priority": 2,
  "sip_url": "sip://sip-updated.com:4321",
  "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2018-05-07T20:50:58Z",
  "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Delete an OriginationUrl resource

`DELETE https://trunking.twilio.com/v1/Trunks/{TrunkSid}/OriginationUrls/{Sid}`

### Path parameters

```json
[{"name":"TrunkSid","in":"path","description":"The SID of the Trunk from which to delete the OriginationUrl.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^TK[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"The unique string that we created to identify the OriginationUrl resource to delete.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^OU[0-9a-fA-F]{32}$"},"required":true}]
```

Delete Origination Url

```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 deleteOriginationUrl() {
  await client.trunking.v1
    .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .originationUrls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .remove();
}

deleteOriginationUrl();
```

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

client.trunking.v1.trunks(
    "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).origination_urls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete()
```

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

using System;
using Twilio;
using Twilio.Rest.Trunking.V1.Trunk;
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);

        await OriginationUrlResource.DeleteAsync(
            pathTrunkSid: "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.trunking.v1.trunk.OriginationUrl;

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);
        OriginationUrl.deleter("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete();
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"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()

	err := client.TrunkingV1.DeleteOriginationUrl("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

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

$twilio->trunking->v1
    ->trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->originationUrls("OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->delete();
```

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

@client
  .trunking
  .v1
  .trunks('TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .origination_urls('OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

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

twilio api:trunking:v1:trunks:origination-urls:remove \
   --trunk-sid TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X DELETE "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
