Add a SIP Trunk

Add and configure a SIP trunk.

Request URL

POST {base_url}/{api_path}/trunk/create?access_token={access_token}

Request parameters

Send different request parameters according to different types of SIP trunk.
Add a Register trunk
Table 1.
Parameter Required Type Description
name Yes String Trunk name.
enable No Integer Whether to enable the trunk.

Valid value:

  • 0: Disable

  • 1: Enable

country Yes String The country of the ITSP.
Note: You can query the desired ITSP using Query ITSP of SIP Trunks.
itsp No String The name of the ITSP.
Note: You can query the desired ITSP using Query ITSP of SIP Trunks.
type Yes String Trunk type.

Valid value: register

transport Yes String Transport protocol.
Valid value:
  • udp
  • tcp
  • tls
  • dnsnaptr
hostname Yes String The domain or IP address of the ITSP.
port Yes Integer The registration port of the SIP trunk.
domain Yes String The domain or IP address of the ITSP.
username Yes String The username of the SIP account that is provided by the ITSP.
password Yes String The password of the SIP account.
Note:
  • Must contain numbers, uppercase, and lowercase letters.
  • The minimum character length is 10.
auth_name Yes String The authentication name that is provided by the ITSP.
enb_outbound_proxy No Integer Whether to enable an outbound proxy.

Valid value:

  • 0: Disable

  • 1: Enable

outbound_proxy_server No String The domain name or IP address of the outbound proxy server.
outbound_proxy_port No Integer The port of the outbound proxy server.
codec_sel Yes String Codec settings of the trunk.
Valid value:
  • ulaw
  • alaw
  • g729
  • gsm
  • h264
  • h263
  • h263p
  • ilbc
  • g722
  • g726
  • speex
  • adpcm
  • mpeg4
  • vp8
  • opus
def_outbound_cid No String Default outbound caller ID.
def_outbound_cid_name No String Default outbound caller ID name.
outbound_cid_list No Array <OutCaller_Info>

The information of customized outbound caller ID for specific extensions.

did_list No Array <DID_List> DID information associated with the trunk.
OutCaller_Info
Table 2.
Parameter Required Type Description
outbound_cid_option Yes String The type of outbound caller ID.
Valid value:
  • range
  • shared
outbound_cid Yes String The outbound caller ID.
outbound_cid_name No String The outbound caller ID name.
outbound_cid_to_ext_range No String The extension range corresponding to the outbound caller ID range.
Note: This parameter is required when outbound_cid_option is set to range.
ext_list No Array <Extension_Info> The information of the associated extensions.
Note: This parameter is required when outbound_cid_option is set to shared.
Extension_Info
Table 3.
Parameter Required Type Description
type No String Whether this is an extension or an extension group.

Valid value:

  • extension
  • ext_group
ext_number No String The number of an extension or the name of an extension group.
ext_name No String The name of an extension or an extension group.
id Yes Integer The unique ID of an extension or an extension group.
DID_List
Table 4.
Parameter Required Type Description
did Yes String The DID number associated with the trunk.
did_name No String The DID name associated with the trunk.
Add a Peer trunk
Table 5.
Parameter Required Type Description
name Yes String Trunk name.
enable No Integer Whether to enable the trunk.

Valid value:

  • 0: Disable

  • 1: Enable

country Yes String The country of the ITSP.
Note: You can query the desired ITSP using Query ITSP of SIP Trunks.
itsp No String The name of the ITSP.
Note: You can query the desired ITSP using Query ITSP of SIP Trunks.
type Yes String Trunk type.
Valid value:
  • peer_did
  • peer_port
  • peer_private
transport Yes String Transport protocol.
Valid value:
  • udp
  • tcp
  • tls
    Note: Peer Trunk (DID Based) does not support this protocol.
hostname Yes String The domain or IP address of the ITSP.
port Yes Integer The registration port of the SIP trunk.
domain Yes String The domain or IP address of the ITSP.
codec_sel Yes String Codec settings of the trunk.
Valid value:
  • ulaw
  • alaw
  • g729
  • gsm
  • h264
  • h263
  • h263p
  • ilbc
  • g722
  • g726
  • speex
  • adpcm
  • vp8
def_outbound_cid No String Default outbound caller ID.
def_outbound_cid_name No String Default outbound caller ID name.
outbound_cid_list No Array <OutCaller_Info>

The information of customized outbound caller ID for specific extensions.

did_list No Array <DID_List> DID information associated with the trunk.
OutCaller_Info
Table 6.
Parameter Required Type Description
outbound_cid_option Yes String The type of outbound Caller ID.
Valid value:
  • range
  • shared
outbound_cid Yes String The outbound Caller ID.
outbound_cid_name No String The outbound Caller ID name.
outbound_cid_to_ext_range No String The extension range corresponding to the outbound Caller ID range.
Note: This parameter is required when outbound_cid_option is set to range.
ext_list No Array <Extension_Info> The information of the associated extensions.
Note: This parameter is required when outbound_cid_option is set to shared.
Extension_Info
Table 7.
Parameter Required Type Description
type No String Whether this is an extension or an extension group.

Valid value:

  • extension
  • ext_group
ext_number No String The number of an extension or the name of an extension group.
ext_name No String The name of an extension or an extension group.
id Yes Integer The unique ID of an extension or an extension group.
DID_List
Table 8.
Parameter Required Type Description
did Yes String The DID number associated with the trunk.
did_name No String The DID name associated with the trunk.
Add an Account trunk
Table 9.
Parameter Required Type Description
name Yes String Trunk name.
enable No Integer Whether to enable the trunk.

Valid value:

  • 0: Disable

  • 1: Enable

country Yes String The country of the ITSP.
Note: You can query the desired ITSP using Query ITSP of SIP Trunks.
itsp No String The name of the ITSP.
Note: You can query the desired ITSP using Query ITSP of SIP Trunks.
type Yes String Trunk type.

Valid value: account

transport Yes String Transport protocol.
Valid value:
  • udp
  • tcp
  • tls
username Yes String The user name of the SIP account trunk.
password Yes String The password associated with the user name.
auth_name Yes String The authentication name for a third-party device to register with.
codec_sel Yes String Codec settings of the trunk.
Valid value:
  • ulaw
  • alaw
  • g729
  • gsm
  • h264
  • h263
  • h263p
  • ilbc
  • g722
  • g726
  • speex
  • adpcm
  • mpeg4
  • vp8
  • opus
def_outbound_cid No String Default outbound caller ID.
def_outbound_cid_name No String Default outbound caller ID name.
outbound_cid_list No Array <OutCaller_Info>

The information of customized outbound caller ID for specific extensions.

OutCaller_Info
Table 10.
Parameter Required Type Description
outbound_cid_option Yes String The type of outbound caller ID.
Valid value:
  • range
  • shared
outbound_cid Yes String The outbound caller ID.
outbound_cid_name No String The outbound caller ID name.
outbound_cid_to_ext_range No String The extension range corresponding to the outbound caller ID range.
Note: This parameter is required when outbound_cid_option is set to range.
ext_list No Array <Extension_Info> The information of the associated extensions.
Note: This parameter is required when outbound_cid_option is set to shared.
Extension_Info
Table 11.
Parameter Required Type Description
type No String Whether this is an extension or an extension group.

Valid value:

  • extension
  • ext_group
ext_number No String The number of an extension or the name of an extension group.
ext_name No String The name of an extension or an extension group.
id Yes Integer The unique ID of an extension or an extension group.

Response parameters

Table 12.
Parameter Type Description
errcode Integer Returned error code.
  • 0: Succeed.
  • Non-zero value: Failed.
Note: You can check the error code and error message in Error Code and Error Message.
errmsg String Returned message.
  • SUCCESS: Succeed.
  • FAILURE: Failed.
id Integer The unique ID of the trunk.

Examples

Request example

Add a register trunk.

POST /openapi/v1.0/trunk/create?access_token=LLTQiARUCJPsBrhTR22RBVCvBJ5xAiFI HTTP/1.1 

Host: yeastardocs.example.yeastarcloud.com
Content-Type: application/json
{
        "name": "test_Calls",
        "country": "general",
        "type": "register",
        "transport": "dnsnaptr",
        "hostname": "abc.provider.com",
        "port": 5060,
        "domain": "abc.provider.com",
        "username": "6701",
        "password": "aAc1653249",
        "auth_name": "mubJwYEWs9",
        "codec_sel": "ulaw,alaw,g729",
        "def_outbound_cid": "5503300",
        "def_outbound_cid_name": "Yeastar",
        "outbound_cid_list": [
            {
                "outbound_cid_option": "shared",
                "outbound_cid": "5503301",
                "outbound_cid_name": "Yeastar Sales",
                "ext_list": [
                    {
                        "ext_number": "Yeastar Sales",
                        "ext_name": "Yeastar Sales",
                        "type": "ext_group"
                    }
                ]
            }
        ],
        "did_list": [
            {
                "did": "5503308",
                "did_name": "Yeastar"
            }
        ]
    }
}

Response example

HTTP/1.1 200 OK
{
    "errcode": 0,
    "errmsg": "SUCCESS",
    "id": 19
}