CallFire Solutions

05. Add Label to a Number

Follow

This endpoint allows for adding labels to an existing phone number on an account. If label name doesn’t currently exist on system it will be created and saved.

Endpoint

https://www.callfire.com/api/1.1/rest/label/number/{Number}

Request Type

POST

Request Headers

Content-Type application/xml
Accepts application/xml

Returns

On success this request does not return an XML payload, only an HTTP 204 No Content status code. However, if the request fails, an XML payload will be returned, along with either a HTTP 404 Not Found, or HTTP 500 Internal Server Error.

Request Arguments

ArgumentTypeDescription
Number long required - A E.164 compliant phone number, which follows the following format: [+][country code][subscriber number including area code]. A US example phone number is: 14055092773.
LabelName string The label to apply to the phone number.

Example Request

The below example shows how to make a request.

Curl

curl -i https://www.callfire.com/api/1.1/rest/label/number/2092084589 \
  -X POST \
  -H "Accept: application/xml" \
  --form "LabelName=Generic+Label" \
  --user <YOUR_LOGIN>:<YOUR_PASSWORD>

PHP SDK

$number = '2092084589';
$query = >new Request\LabelNumber();
$query->setLabelName('Generic Label')
      ->setNumber($number);
$response = $app->callfireNumberRestClient->LabelNumber('2092084589', $query);
$result = $callfireNumberRestClient::response($response);

This example shows how to make a request, which adds a label to a number, using the fluent interface of the PHP SDK.

Note: It’s worth noting that whilst there is a method on Request\LabelNumber() which allows for setting a number, the number is still required as the first parameter of the LabelNumber request.

Node.js

>var querystring = require('querystring');
>var https = require('https');

>var data  = querystring.stringify({
    LabelName: "Here is a Test Label"
});
>var options = {
    host: 'www.callfire.com',
    path: '/api/1.1/rest/label/number/2092084589/',
    auth: 'YOUR_LOGIN' + ':' + 'YOUR_PASSWORD',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': data.length
    }
};

>var req = https.request(options, >function(res) {
    res.setEncoding('utf8');
    res.on('data', >function(d) {
        process.stdout.write(d);
    });
}).on('error', >function(e) {
    console.error(e);
});

// post the data
req.write(data);

req.end();

Go

requestOptions := callfire.CallFireRequestOptions{
    Url:            "https://www.callfire.com/api/1.1/rest/label/number/2092084589/?",
    Login:          "YOUR_LOGIN",
    Secret:         "YOUR_PASSWORD",
    ReqType:        "POST",
    RequestOptions: "LabelName=Generic+Information",
}
client, req := callfire.InitHttpClient(requestOptions)
resp, err := client.Do(req)

Example Response

If the number supplied isn’t linked against the account, then the following XML payload will be returned:

HTTP/1.0 404 Not Found
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<r:ResourceException xmlns="http://api.callfire.com/data" xmlns:r="http://api.callfire.com/resource">
      <r:HttpStatus>404</r:HttpStatus>
      <r:Message>Not Found</r:Message>
</r:ResourceException>

If a label name isn’t specified in the request, then the following XML payload will be returned, with an HTTP 400 Bad Request status:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<r:ResourceException xmlns="http://api.callfire.com/data" xmlns:r="http://api.callfire.com/resource">
    <r:HttpStatus>400</r:HttpStatus>
    <r:Message>label name cannot be empty</r:Message>
</r:ResourceException>

If something goes wrong, then the following XML payload will be returned:

HTTP 500 Internal Server Error
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<r:ResourceException xmlns="http://api.callfire.com/data" xmlns:r="http://api.callfire.com/resource">
      <r:HttpStatus>500</r:HttpStatus>
      <r:Message>Internal resource exception. Ref: 50ea105f-ee83-459b-8313-f52f89b942ea</r:Message>
</r:ResourceException>

Have more questions? Submit a request

Comments