Update SIP trunk
Required scope: sessions:manage
Changes the fields you send and keeps the others. Send expectedRevision to refuse the change with 409 sip_trunk_revision_conflict when the trunk changed since you read it. Changes apply to new calls within about a minute; calls in progress continue.
curl --request PATCH \
--url https://api.polymorfa.com/platform/sip-trunks/{trunkId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedRevision": 2,
"name": "<string>",
"enabled": true,
"outbound": {
"targetUri": "<string>",
"authUsername": "<string>",
"authPassword": "<string>",
"fromUser": "<string>"
},
"inbound": {
"session": "<string>",
"allowedAddresses": [
"<string>"
],
"allowedDestinations": [
"<string>"
]
},
"codecs": [],
"maxConcurrentCalls": 250
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expectedRevision: 2,
name: '<string>',
enabled: true,
outbound: {
targetUri: '<string>',
authUsername: '<string>',
authPassword: '<string>',
fromUser: '<string>'
},
inbound: {
session: '<string>',
allowedAddresses: ['<string>'],
allowedDestinations: ['<string>']
},
codecs: [],
maxConcurrentCalls: 250
})
};
fetch('https://api.polymorfa.com/platform/sip-trunks/{trunkId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/platform/sip-trunks/{trunkId}"
payload = {
"expectedRevision": 2,
"name": "<string>",
"enabled": True,
"outbound": {
"targetUri": "<string>",
"authUsername": "<string>",
"authPassword": "<string>",
"fromUser": "<string>"
},
"inbound": {
"session": "<string>",
"allowedAddresses": ["<string>"],
"allowedDestinations": ["<string>"]
},
"codecs": [],
"maxConcurrentCalls": 250
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/platform/sip-trunks/{trunkId}"
payload := strings.NewReader("{\n \"expectedRevision\": 2,\n \"name\": \"<string>\",\n \"enabled\": true,\n \"outbound\": {\n \"targetUri\": \"<string>\",\n \"authUsername\": \"<string>\",\n \"authPassword\": \"<string>\",\n \"fromUser\": \"<string>\"\n },\n \"inbound\": {\n \"session\": \"<string>\",\n \"allowedAddresses\": [\n \"<string>\"\n ],\n \"allowedDestinations\": [\n \"<string>\"\n ]\n },\n \"codecs\": [],\n \"maxConcurrentCalls\": 250\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}false{
"success": true,
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"enabled": true,
"direction": "inbound",
"outbound": {
"targetUri": "<string>",
"transport": "udp",
"authUsername": "<string>",
"hasPassword": true,
"fromUser": "<string>"
},
"inbound": {
"username": "<string>",
"realm": "<string>",
"session": "<string>",
"allowedAddresses": [
"<string>"
],
"allowedDestinations": [
"<string>"
]
},
"codecs": [
"PCMU"
],
"maxConcurrentCalls": 123,
"revision": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_parameter",
"message": "Correct the invalid request field.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-parameter"
}{
"error": {
"type": "authentication_error",
"code": "invalid_credential",
"message": "Supply a valid credential.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-credential"
}{
"error": {
"type": "permission_error",
"code": "permission_denied",
"message": "The credential does not have access to this resource.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#permission-denied"
}{
"error": {
"type": "invalid_request_error",
"code": "resource_not_found",
"message": "The resource is unavailable to this caller.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#resource-not-found"
}{
"error": {
"type": "conflict_error",
"code": "sip_trunk_revision_conflict",
"message": "The SIP trunk changed since it was read.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#sip-trunk-revision-conflict"
}{
"error": {
"type": "api_error",
"code": "internal_error",
"message": "An unexpected service failure occurred. Keep the request ID for support.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#internal-error"
}{
"error": {
"type": "api_error",
"code": "sip_unavailable",
"message": "SIP trunks are not available.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#sip-unavailable"
}Authorizations
Send your team API key or project token as Authorization: Bearer <token>. The credential must have the required permissions. Project tokens can access only their own project.
Path Parameters
Identifier for the trunk.
Value constraints
| Constraint | Accepted input |
|---|---|
| Format | uuid |
Body
Apply the change only if the trunk still has this revision.
Value constraints
| Constraint | Accepted input |
|---|---|
| Numeric value | 1 or greater |
x >= 1Display name, 1 to 100 characters.
Value constraints
| Constraint | Accepted input |
|---|---|
| String length | 1 through 100 characters |
1 - 100Whether this feature is enabled.
Specifies direction for this management platform access update sip trunk request.
Allowed values
| Value | Meaning |
|---|---|
inbound | Inbound. |
outbound | Outbound. |
both | Both. |
inbound, outbound, both Specifies outbound for this management platform access update sip trunk request.
Show child attributes
Show child attributes
Specifies inbound for this management platform access update sip trunk request.
Show child attributes
Show child attributes
Distinct codecs in preference order. Defaults to PCMU, PCMA, opus.
Allowed item values
| Item value | Meaning |
|---|---|
PCMU | Pcmu. |
PCMA | Pcma. |
opus | Opus. |
Value constraints
| Constraint | Accepted input |
|---|---|
| Array size | 1 through 3 items |
1 - 3 elementsPCMU, PCMA, opus 1 to 500. Defaults to 30.
Value constraints
| Constraint | Accepted input |
|---|---|
| Numeric value | 1 through 500 (inclusive) |
1 <= x <= 500Was this page helpful?
curl --request PATCH \
--url https://api.polymorfa.com/platform/sip-trunks/{trunkId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedRevision": 2,
"name": "<string>",
"enabled": true,
"outbound": {
"targetUri": "<string>",
"authUsername": "<string>",
"authPassword": "<string>",
"fromUser": "<string>"
},
"inbound": {
"session": "<string>",
"allowedAddresses": [
"<string>"
],
"allowedDestinations": [
"<string>"
]
},
"codecs": [],
"maxConcurrentCalls": 250
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expectedRevision: 2,
name: '<string>',
enabled: true,
outbound: {
targetUri: '<string>',
authUsername: '<string>',
authPassword: '<string>',
fromUser: '<string>'
},
inbound: {
session: '<string>',
allowedAddresses: ['<string>'],
allowedDestinations: ['<string>']
},
codecs: [],
maxConcurrentCalls: 250
})
};
fetch('https://api.polymorfa.com/platform/sip-trunks/{trunkId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/platform/sip-trunks/{trunkId}"
payload = {
"expectedRevision": 2,
"name": "<string>",
"enabled": True,
"outbound": {
"targetUri": "<string>",
"authUsername": "<string>",
"authPassword": "<string>",
"fromUser": "<string>"
},
"inbound": {
"session": "<string>",
"allowedAddresses": ["<string>"],
"allowedDestinations": ["<string>"]
},
"codecs": [],
"maxConcurrentCalls": 250
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/platform/sip-trunks/{trunkId}"
payload := strings.NewReader("{\n \"expectedRevision\": 2,\n \"name\": \"<string>\",\n \"enabled\": true,\n \"outbound\": {\n \"targetUri\": \"<string>\",\n \"authUsername\": \"<string>\",\n \"authPassword\": \"<string>\",\n \"fromUser\": \"<string>\"\n },\n \"inbound\": {\n \"session\": \"<string>\",\n \"allowedAddresses\": [\n \"<string>\"\n ],\n \"allowedDestinations\": [\n \"<string>\"\n ]\n },\n \"codecs\": [],\n \"maxConcurrentCalls\": 250\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}false{
"success": true,
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"enabled": true,
"direction": "inbound",
"outbound": {
"targetUri": "<string>",
"transport": "udp",
"authUsername": "<string>",
"hasPassword": true,
"fromUser": "<string>"
},
"inbound": {
"username": "<string>",
"realm": "<string>",
"session": "<string>",
"allowedAddresses": [
"<string>"
],
"allowedDestinations": [
"<string>"
]
},
"codecs": [
"PCMU"
],
"maxConcurrentCalls": 123,
"revision": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_parameter",
"message": "Correct the invalid request field.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-parameter"
}{
"error": {
"type": "authentication_error",
"code": "invalid_credential",
"message": "Supply a valid credential.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-credential"
}{
"error": {
"type": "permission_error",
"code": "permission_denied",
"message": "The credential does not have access to this resource.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#permission-denied"
}{
"error": {
"type": "invalid_request_error",
"code": "resource_not_found",
"message": "The resource is unavailable to this caller.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#resource-not-found"
}{
"error": {
"type": "conflict_error",
"code": "sip_trunk_revision_conflict",
"message": "The SIP trunk changed since it was read.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#sip-trunk-revision-conflict"
}{
"error": {
"type": "api_error",
"code": "internal_error",
"message": "An unexpected service failure occurred. Keep the request ID for support.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#internal-error"
}{
"error": {
"type": "api_error",
"code": "sip_unavailable",
"message": "SIP trunks are not available.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#sip-unavailable"
}