> For the complete documentation index, see [llms.txt](https://docs.tsgglobal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tsgglobal.com/api-reference/phone-numbers/manage-number-for-voice/update-destination-priority.md).

# Update Destination Priority

Change an existing voice destination priority for a phone number, optionally overriding the dialed number (DNIS) sent to your switch.

## Overview

This method allows you to update existing destination priorities for phone numbers.

## Authentication

{% hint style="info" %}
Authentication is done by passing your TSG Global API key via the Authorization header in the format "Authorization: Bearer \<api\_key>"
{% endhint %}

## Method

## Update a destination priority associated with a phone number.

<mark style="color:purple;">`PATCH`</mark> `https://api-service.tsgglobal.world/v1/did/priority`

#### Request Body

| Name                                           | Type   | Description                                                                                                                                                                   |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| did<mark style="color:red;">\*</mark>          | String | The phone number (e.g. 12022011234)                                                                                                                                           |
| priority<mark style="color:red;">\*</mark>     | String | 1-3 in order of preferred priority.                                                                                                                                           |
| destination<mark style="color:red;">\*</mark>  | String | `192.168.1.1` (for VOIP), `16352321233` (for PSTN)                                                                                                                            |
| call\_type<mark style="color:red;">\*</mark>   | String | `VOIP`, `PSTN`                                                                                                                                                                |
| call\_option<mark style="color:red;">\*</mark> | String | `WP`, `NP`                                                                                                                                                                    |
| dnis                                           | String | Number for TSG to send to your switch as the Dialed Number ID, e.g. `DID == 13605551212` but you want TSG to send you `3605551212` or `14085551212` instead of the DID number |

For VOIP Call Type you need to enter just the IP Address of the Gateway and we will format the rest of the destination. For PSTN Call Type you need to just enter the PSTN Destination in E.164 format, with or without the leading plus.

`call_type` must be exactly one of `VOIP` (VoIP destination) or `PSTN` (PSTN destination). This value is case sensitive.

`call_option`: `NP` = DID sent to the gateway without a plus, `WP` = DID sent to the gateway with a plus. This value is case sensitive.

### Example PATCH

```bash
curl -n https://api-service.tsgglobal.world/v1/did/priority -XPATCH -H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" -d '{
  "did": "12003004000",
  "destination": "16352321233",
  "priority": 2,
  "call_type": "PSTN",
  "call_option": "NP"
}'
```

## **Error Codes**

* `-1000` Invalid or Blank API Key
* `-1001` Invalid or Blank Call Option
* `-1003` Invalid or No DID Provided
* `-1004` Invalid or No Priority Provided
* `-1005` Invalid or No Destination Provided
* `-1006` Invalid or No Call Type Provided
* `-1007` Priority Already Exists Use Another Priority
* `-1008-V` Priority Added to Database as VoIP Destination
* `-1008-P` Priority Added to Database as PSTN Destination
* `-1010` Unknown Error Please Contact TSG Support with URL String for Review
