Gateways

This endpoint provides the ability to manage gateways on your Domain and Customers.

Gateways are used to enable outbound calls and call forwarding to PSTN on customer accounts. A single customer may include several gateways, however, a single gateway per customer account is sufficient in most cases.

Important

Your sub-domain may be pre-configured with a single gateway that will be used by default on all customer accounts.

All calls from the PBX to gateways are reflected in Termination CDRs.

The following HTTP method(s) are available:

Relationship to other resources:

Name

Resource Type

Relationship Type

Updatable

Description

customer

customers

To-one

No

Parent customer’s ID that will include this incoming trunk

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, defaults depend on SUB-DOMAIN configuration

Yes, if allowed on SUB-DOMAIN

port

integer

Port used on this gateway

Yes, default is 5060

Yes, if allowed on SUB-DOMAIN

name

string

Gateway’s name

No

Yes, if allowed on SUB-DOMAIN

host

string

Gateway’s host address

No

Yes, if allowed on SUB-DOMAIN

src_rewrite_rule

string

Regex-based rewrite rule for SRC number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

src_rewrite_result

string

Regex-based result rule for SRC number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

dst_rewrite_rule

string

Regex-based rewrite rule for DST number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

dst_rewrite_result

string

Regex-based result rule for DST number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

authorization_name

string

Authorization username

Yes, default is null

Yes, if allowed on SUB-DOMAIN

authorization_password

string

Authorization password

Yes, default is null

Yes, if allowed on SUB-DOMAIN

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 SUB-DOMAIN

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:

http

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

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

response

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": {
      "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"
    }
  }
}

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.

Retrieving 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 for filtering results by resource ID

filter[customer.id]

Customer ID

Used for filtering results by Customer ID

filter[name]

Termination gateway’s name

Used for filtering results by name

filter[host]

Termination gateway’s host

Used for filtering results by host

Request and Response examples:

http

GET /api/rest/public/operator/termination_gateways HTTP/1.1
Host: api.telecom.center
Content-Type: application/vnd.api+json
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

curl

curl -i https://api.telecom.center/api/rest/public/operator/termination_gateways -H 'Content-Type: application/vnd.api+json' --user username:password

response

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": {
        "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:

GET

/api/rest/public/operator/termination_gateways{id}

Updating a Gateway

Use the HTTP PATCH method to retrieve gateways:

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, defaults depend on SUB-DOMAIN configuration

Yes, if allowed on SUB-DOMAIN

port

integer

Port used on this gateway

Yes, default is 5060

Yes, if allowed on SUB-DOMAIN

name

string

Gateway’s name

No

Yes, if allowed on SUB-DOMAIN

host

string

Gateway’s host address

No

Yes, if allowed on SUB-DOMAIN

src_rewrite_rule

string

Regex-based rewrite rule for SRC number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

src_rewrite_result

string

Regex-based result rule for SRC number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

dst_rewrite_rule

string

Regex-based rewrite rule for DST number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

dst_rewrite_result

string

Regex-based result rule for DST number

Yes, default is null

Yes, if allowed on SUB-DOMAIN

authorization_name

string

Authorization username

Yes, default is null

Yes, if allowed on SUB-DOMAIN

authorization_password

string

Authorization password

Yes, default is null

Yes, if allowed on SUB-DOMAIN

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 SUB-DOMAIN

Request and Response examples:

http

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

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

response

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": {
      "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 this deleted gateway.

Request and Response examples:

http

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

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

response

HTTP/2 204 No Content
Content-Type: application/vnd.api+json

The HTTP status code 204 will be the response after a successful deletion of a gateway with an empty response body.