Resources

URI

  • v1/accounts/{account_id}/resources
PropertyDescriptionValidationModifiable
name A friendly label for identification of the resource   yes
enabled When set to false the resource will be ignored by the call routing engine boolean yes
weight_cost If resource routing rules overlap, the highest weight will take precedence   yes
rules A list of rules used by the routing engine to determine when to use the resource array yes
flags A list of supported functionality by this route, such as fax, e911, or g729 array yes
caller_id_options Caller ID Option Parameters object yes
gateways A list of Gateway Parameters for reaching the resource array yes
   
  • You need to escape backslashes in literal strings with an additional backslash in the regular expressions.
VerbAcceptedReturnedDescription
GET   id and name Fetches a summary of resources
PUT ANY ALL Create a new resource
  • Normal Response Code(s): 200
  • Error Response Code(s): 400, 401, 415, 500, 503, 504

 

URI

  • v1/accounts/{account_id}/resources/{resource_id}
PropertyDescriptionValidationModifiable
name A friendly label for identification of the resource   yes
enabled When set to false the resource will be ignored by the call routing engine boolean yes
weight_cost If resource routing rules overlap, the highest weight will take precedence   yes
rules A list of rules used by the routing engine to determine when to use the resource array yes
flags A list of supported functionality by this route, such as fax, e911, or g729 array yes
caller_id_options Caller ID Option Parameters object yes
gateways A list of Gateway Parameters for reaching the resource array yes
VerbAcceptedReturnedDescription
GET   ALL Fetch the details of a resource
POST ANY ALL Update the parameters of a resource
DELETE     Delete a resource
  • Normal Response Code(s): 200, 201
  • Error Response Code(s): 400, 401, 404, 415, 500, 503, 504
PropertyDescriptionValidationModifiable
type An arbitrary caller-id type to search for when this route is used, otherwise uses 'external'   yes
  • You can create resources for your emergency numbers and set the 'caller_id.type' to 'emergency'. This will allow you to define the CID used for emergency calls at any level (ie: device, user, or account).
PropertyDescriptionValidationModifiable
server The destination server domain or IP   yes
realm The authentication realm used if challenged by the server   yes
username The authentication username used if challenged by the server   yes
password The authentication password used if challenged by the server   yes
invite_format The format of the request URI used in the SIP invite ["npan"|"1npan"|"e164"|"route"|"username"] yes
prefix Additional characters to prepend to the front of the dialed number (or first match group if present in the rule)   yes
progress_timeout In secs, the maximum time to wait for media from a resource gateway   yes
suffix Additional characters to append to the front of the dialed number (or first match group if present in the rule)   yes
codecs A list of codecs supported by this gateway array yes

PropertyDescriptionValidationModifiable
ringback The media to play to the caller until early media is provided by a resource (unless early media is ignored) required yes
timeout Maximum time to attempt to ring the device, defaults to 20 seconds   yes
ignore_early_media When set to true early media from the resources will not be passed to the caller boolean yes
  • The children of the resource module can be used to handle failure causes. The branch names can be failure messages, such as UNALLOCATED_NUMBER, or protocol specific codes, such as "sip:404". The wild card child will be used if present and no other branch matches. The failure codes are available at http://wiki.freeswitch.org/wiki/Hangup_Causes
  • Failure messages take precedence over codes.

{

   "module":"resources",

   "data": {

      "ringback": "/system_media/please_wait_while_we_connect_your_call",

      "timeout": 30,

      "ignore_early_media": false

   },

   "children": {

        "PROGRESS_TIMEOUT": {

            "module": "device",

            "data": {

                "id": "xyz987"

            },

            "children": {

            }

        },

        "sip:500": {

            "module": "response",

            "data": {

                "code": "486",

                "message": "Unable to process your call right now"

            },

            "children": {

            }

        },

        "_": {

            "module": "response",

            "data": {

                "code": "404",

                "message": "Not found",

                "media": "system_media/unable-to-process-call

            },

            "children": {

            }

        }

   }

}

Method GET
URI v1/accounts/{account_id}/resources
Request Headers X-Auth-Token: abc123
Accept: application/json
Request Body  
Response Body
{
   "auth_token":"abc123",
   "status":"success",
   "data":[
      {
         "id":"xyz987"
      }
   ]
}
Response Headers 200 OK 
Content-Type: application/json

Method PUT
Request URI v1/accounts/{account_id}/resources
Request Headers X-Auth-Token: abc123 
Accept: application/json
Content-Type: application/json
Request Body  
{
   "data":{
      "name":"Conversant",
      "enabled":true,
      "weight_cost":100,
      "rules":[
         ".*"
      ],
      "flags":[
         "CallerId"
      ],
      "caller_id_options":{
         "type": "local"
      },
      "gateways":[
         {
            "server":"sip.conversant.co.nz",
            "realm":"conversant.co.nz",
            "username":"user1234",
            "password":"p0sswUDD",
            "invite_format":"e164",
            "prefix":"",
            "suffix":"",
            "codecs":[
            ]
         }
      ]
   }
}
Response Body
Response Headers 201 OK 
Location: v1/accounts/{account_id}/resources/{resource_id}

Method GET
URI v1/accounts/{account_id}/resources/{resource_id}
Request Headers X-Auth-Token: abc123 
Accept: application/json
Request Body  
Response Body
{
   "auth_token":"abc123",
   "status":"success",
   "data":{
      "name":"Carrier 1",
      "enabled":true,
      "weight_cost":100,
      "rules":[
         ".*"
      ],
      "flags":[
         "CallerId"
      ],
      "caller_id_options":{
         "type": "local"
      },
      "gateways":[
         {
            "server":"sip.conversant.co.nz",
            "realm":"conversant.co.nz",
            "username":"user1234",
            "password":"p0sswUDD",
            "invite_format":"e164",
            "prefix":"",
            "suffix":"",
            "codecs":[
            ]
         }
      ]
   }
}
Response Headers 200 OK
Method POST
URI v1/accounts/{account_id}/resources/{resource_id}
Request Headers X-Auth-Token: abc123 
Accept: application/json
Content-Type: application/json
Request Body  
{
   "data":{
      "name":"Carrier",
      "enabled":false,
      "weight_cost":100,
      "rules":[
         ".*"
      ],
      "flags":[
         "CallerId"
      ],
      "caller_id_options":{
         "type": "local"
      },
      "gateways":[
         {
 
            "server":"sip.conversant.co.nz",
            "realm":"conversant.co.nz",
            "username":"user1234",
            "password":"p0sswUDD",
            "invite_format":"e164",
            "prefix":"",
            "suffix":"",
            "codecs":[
            ]
         }
      ]
   }
}
Response Body
{
   "auth_token":"abc123",
   "status":"success",
   "data":{
      "name":"Carrier",
      "enabled":false,
      "weight_cost":100,
      "rules":[
         ".*"
      ],
      "flags":[
         "CallerId"
      ],
      "caller_id_options":{
         "type": "local"
      },
      "gateways":[
         {
 
            "server":"sip.conversant.co.nz",
            "realm":"conversant.co.nz",
            "username":"user1234",
            "password":"p0sswUDD",
            "invite_format":"e164",
            "prefix":"",
            "suffix":"",
            "codecs":[
            ]
         }
      ]
   }
}
Response Headers  
Method DELETE
URI v1/accounts/{account_id}/resources/{resource_id}
Request Headers X-Auth-Token: abc123 
Accept: application/json
Request Body  
Response Body
{
   "auth_token":"abc123",
   "status":"success",
   "data":[]
}
Response Headers  

Resources represent external assets such as SIP trunks that provide for the remote termination/origination of call services.