Gateways¶
This endpoint provides the ability to manage gateways on your commercial account and customers.
Gateways are used to enable outbound calls and call forwarding to PSTN on customer accounts. A single customer can have several gateways, however, a single gateway per customer account is sufficient in most cases.
Important
Your commercial account may be pre-configured with a system gateway that will be used by default for
customers with "termination_mode": system
and "termination_mode": system_customer
.
All calls from the PBX to gateways are included in Termination CDRs.
The following HTTP method(s) are available:
GET /termination_gateways - For Fetching Gateways
POST /termination_gateways - For Creating a Gateway
DELETE /termination_gateways/{id} - For Deleting a Gateway
PATCH /termination_gateways/{id} - For Updating a Gateway
Relationship to other resources:
Name |
Resource Type |
Relationship Type |
Updatable |
Description |
---|---|---|---|---|
customer |
customers |
To-one |
No |
Parent customer’s ID that will include this gateway |
Important
Relationships can be used with include
and fields
parameters if the method supports it.
Creating a Gateway¶
Use the HTTP POST method to create a new gateway.
POST
/api/rest/public/operator/termination_gateways
This method supports Sparse fieldsets
Attributes:
Attribute |
Value |
Description |
Optional |
Controlled via UI |
---|---|---|---|---|
codecs |
“g729”, “G722”, “GSM”, “PCMA”, “PCMU”, “OPUS”, “telephone-event/8000” |
Allowed codecs for the gateway |
Yes, default codecs depend on commercial account configuration |
Yes, if allowed on commercial account |
port |
integer |
Port used on this gateway |
Yes, default port is 5060 |
Yes, if allowed on commercial account |
name |
string |
Gateway’s name |
No |
Yes, if allowed on commercial account |
host |
string |
Gateway’s host address |
No |
Yes, if allowed on commercial account |
src_rewrite_rule |
string |
Regex-based rewrite rule for SRC number |
Yes, default is null |
Yes, if allowed on commercial account |
src_rewrite_result |
string |
Regex-based result rule for SRC number |
Yes, default is null |
Yes, if allowed on commercial account |
dst_rewrite_rule |
string |
Regex-based rewrite rule for DST number |
Yes, default is null |
Yes, if allowed on commercial account |
dst_rewrite_result |
string |
Regex-based result rule for DST number |
Yes, default is null |
Yes, if allowed on commercial account |
authorization_name |
string |
Authorization username |
Yes, default is null |
Yes, if allowed on commercial account |
authorization_password |
string |
Authorization password |
Yes, default is null |
Yes, if allowed on commercial account |
network_protocol |
“IPv4_only”, “IPv6_only”, “IPv4_pref”, “IPv6_pref”, “Dualstack” |
Network protocol used on this gateway |
Yes, default is “IPv4_only” |
Yes, if allowed on commercial account |
To-one relationship(s):
Type |
Description |
---|---|
customers |
Parent customer’s ID that will include this gateway |
Other supported parameters:
Parameter |
Value |
Description |
---|---|---|
include |
“customer” |
Used for including linked object details to the response |
Request and Response examples:
POST /api/rest/public/operator/termination_gateways HTTP/1.1
Host: api.telecom.center
Content-Type: application/vnd.api+json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
{
"data": {
"type": "termination_gateways",
"attributes": {
"name": "Gateway",
"host": "testing.api.com"
},
"relationships": {
"customer": {
"data": {
"id": "123",
"type": "customers"
}
}
}
}
}
curl -i -X POST https://api.telecom.center/api/rest/public/operator/termination_gateways -H "Content-Type: application/vnd.api+json" --data-raw '{"data": {"attributes": {"host": "testing.api.com", "name": "Gateway"}, "relationships": {"customer": {"data": {"id": "123", "type": "customers"}}}, "type": "termination_gateways"}}' --user username:password
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json
{
"data": {
"id": "7d952482-1bff-4401-9d46-63126c9bc69d",
"type": "termination_gateways",
"links": {
"self": "https://api.telecom.center/api/rest/public/operator/termination_gateways/7d952482-1bff-4401-9d46-63126c9bc69d"
},
"attributes": {
"operator": true,
"name": "Gateway",
"host": "testing.api.com",
"port": null,
"src_rewrite_rule": null,
"src_rewrite_result": null,
"dst_rewrite_rule": null,
"dst_rewrite_result": null,
"authorization_name": null,
"authorization_password": null,
"codecs": [
"PCMU",
"PCMA",
"telephone-event/8000"
],
"network_protocol": "IPv4_only"
}
}
}
Note
The "operator"
attribute is used to differentiate the creator of a termination gateway. The "operator"
value is true
when the termination gateway is created via API or by telecom.center™ staff (system) and false
if created by customers.
Important
In order for a gateway to receive calls from the PBX, an appropriate route pointing to this gateway should be created. Refer to the Routes section for more details on how to create a route.
Fetching Gateways¶
Use the HTTP GET method to retrieve gateways.
GET
/api/rest/public/operator/termination_gateways
This method supports Sorting, Pagination, Sparse fieldsets and Inclusion of related resources
Other supported parameters:
Parameter |
Value |
Description |
---|---|---|
filter[id] |
Termination gateway ID |
Used to filter results by resource ID |
filter[customer.id] |
Customer ID |
Used to filter results by customer ID |
filter[name] |
Termination gateway’s name |
Used to filter results by name |
filter[host] |
Termination gateway’s host |
Used to filter results by host |
Request and Response examples:
GET /api/rest/public/operator/termination_gateways HTTP/1.1
Host: api.telecom.center
Content-Type: application/vnd.api+json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
curl -i -X GET https://api.telecom.center/api/rest/public/operator/termination_gateways -H "Content-Type: application/vnd.api+json" --user username:password
HTTP/2 200 OK
Content-Type: application/vnd.api+json
{
"data": [
{
"id": "7d952482-1bff-4401-9d46-63126c9bc69d",
"type": "termination_gateways",
"links": {
"self": "https://api.telecom.center/api/rest/public/operator/termination_gateways/7d952482-1bff-4401-9d46-63126c9bc69d"
},
"attributes": {
"operator": true,
"name": "Gateway",
"host": "testing.api.com",
"port": null,
"src_rewrite_rule": null,
"src_rewrite_result": null,
"dst_rewrite_rule": null,
"dst_rewrite_result": null,
"authorization_name": null,
"authorization_password": null,
"codecs": [
"PCMU",
"PCMA",
"telephone-event/8000"
],
"network_protocol": "IPv4_only"
}
}
],
"meta": {
"record_count": 1
},
"links": {
"first": "https://api.telecom.center/api/rest/public/operator/termination_gateways?filter%5Bcustomer.id%5D=187&page%5Bnumber%5D=1&page%5Bsize%5D=50",
"last": "https://api.telecom.center/api/rest/public/operator/termination_gateways?filter%5Bcustomer.id%5D=187&page%5Bnumber%5D=1&page%5Bsize%5D=50"
}
}
The response body will contain an array of all gateways.
Additionally, a customer ID may be included in the request URL in order to retrieve a specific customer. Example below:
GET
/api/rest/public/operator/termination_gateways{id}
Updating a Gateway¶
Use the HTTP PATCH method to update a gateway.
PATCH
/api/rest/public/operator/termination_gateways/{id}
This method supports Sparse fieldsets and Inclusion of related resources
Attributes:
Attribute |
Value |
Description |
Optional |
Controlled via UI |
---|---|---|---|---|
codecs |
“g729”, “G722”, “GSM”, “PCMA”, “PCMU”, “OPUS”, “telephone-event/8000” |
Allowed codecs for the gateway |
Yes, default codecs depend on commercial account configuration |
Yes, if allowed on commercial account |
port |
integer |
Port used on this gateway |
Yes, default is 5060 |
Yes, if allowed on commercial account |
name |
string |
Gateway’s name |
No |
Yes, if allowed on commercial account |
host |
string |
Gateway’s host address |
No |
Yes, if allowed on commercial account |
src_rewrite_rule |
string |
Regex-based rewrite rule for SRC number |
Yes, default is null |
Yes, if allowed on commercial account |
src_rewrite_result |
string |
Regex-based result rule for SRC number |
Yes, default is null |
Yes, if allowed on commercial account |
dst_rewrite_rule |
string |
Regex-based rewrite rule for DST number |
Yes, default is null |
Yes, if allowed on commercial account |
dst_rewrite_result |
string |
Regex-based result rule for DST number |
Yes, default is null |
Yes, if allowed on commercial account |
authorization_name |
string |
Authorization username |
Yes, default is null |
Yes, if allowed on commercial account |
authorization_password |
string |
Authorization password |
Yes, default is null |
Yes, if allowed on commercial account |
network_protocol |
“IPv4_only”, “IPv6_only”, “IPv4_pref”, “IPv6_pref”, “Dualstack” |
Network protocol used on this gateway |
Yes, default is “IPv4_only” |
Yes, if allowed on commercial account |
Request and Response examples:
PATCH /api/rest/public/operator/termination_gateways/7d952482-1bff-4401-9d46-63126c9bc69d HTTP/1.1
Host: api.telecom.center
Content-Type: application/vnd.api+json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
{
"data": {
"id": "7d952482-1bff-4401-9d46-63126c9bc69d",
"type": "termination_gateways",
"attributes": {
"port": 5060,
"codecs": [
"PCMU"
],
"name": "GatewayTest",
"host": "testing.com"
}
}
}
curl -i -X PATCH https://api.telecom.center/api/rest/public/operator/termination_gateways/7d952482-1bff-4401-9d46-63126c9bc69d -H "Content-Type: application/vnd.api+json" --data-raw '{"data": {"attributes": {"codecs": ["PCMU"], "host": "testing.com", "name": "GatewayTest", "port": 5060}, "id": "7d952482-1bff-4401-9d46-63126c9bc69d", "type": "termination_gateways"}}' --user username:password
HTTP/2 200 OK
Content-Type: application/vnd.api+json
{
"data": {
"id": "7d952482-1bff-4401-9d46-63126c9bc69d",
"type": "termination_gateways",
"links": {
"self": "https://api.telecom.center/api/rest/public/operator/termination_gateways/7d952482-1bff-4401-9d46-63126c9bc69d"
},
"attributes": {
"operator": true,
"name": "GatewayTest",
"host": "testing.com",
"port": 5060,
"src_rewrite_rule": null,
"src_rewrite_result": null,
"dst_rewrite_rule": null,
"dst_rewrite_result": null,
"authorization_name": null,
"authorization_password": null,
"codecs": [
"PCMU"
],
"network_protocol": "IPv4_only"
}
}
}
Deleting a Gateway¶
Use the HTTP DELETE method to delete a gateway.
DELETE
/api/rest/public/operator/termination_gateways/{id}
This method will delete the gateway and all Routes that are linked to it.
Request and Response examples:
DELETE /api/rest/public/operator/termination_gateways/7d952482-1bff-4401-9d46-63126c9bc69d HTTP/1.1
Host: api.telecom.center
Content-Type: application/vnd.api+json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
curl -i -X DELETE https://api.telecom.center/api/rest/public/operator/termination_gateways/7d952482-1bff-4401-9d46-63126c9bc69d -H "Content-Type: application/vnd.api+json" --user username:password
HTTP/2 204 No Content
Content-Type: application/vnd.api+json
A successful deletion of a gateway will result with a HTTP status code 204 with an empty response body.