Application Programming Interface

This RESTful API provides the building blocks that developers need to programmatically integrate CC with other network elements and systems. The API works over HTTP or HTTPS.

Individual objects that can be manipulated through the API include CC administrators, service providers, and more. This chapter is a developer reference for connecting a currently used system to CC.

The API is available at https://<NIU or HA address>/cc/api.

Note

For more information about JSON, see http://json.org/ .


URI Scheme

The following shows the base URI and the format used by the API:

Base URI: <niu-ha>/cc/api

Where niu-ha is the host address of the primary NIU.

Following the base URI, the scope and scope ID are added to show which role the actions are to be completed as.

URI Format: /<object>

Many objects will use the following URI: /<object>/<service_provider>/<subscriber>


Methods

The API uses the following methods:

  • GET: Access a resource

  • PUT: Create or modify a resource

  • POST: Create a resource

Note

The POST method can be used to import and export data. For more information, see Provisioning.

  • DELETE: Delete a resource

Note

The DELETE method can be used to archive, restore, and purge data. For more information, see Archiving, Restoring, and Purging Data.


Logging In to the API

POST to <base_uri>/authenticate with the username and password parameters.

For example:

curl -X POST \
         -H "Content-Type:application/json" \
         <niu-ha>/cc/api/authenticate \
         -d '{"username":"<username>","password":"<password>"}'

The response will contain the following:

"data": [
        {"token": "<secure-access-token>"}
        ],
"jsonapi": {"version": "1.7-6",
"name": "Calling Card",
"short_name": "cc",
"author": "IMSWorkX, Inc."}}

The secure access token must be passed back as the value of the Authorization header. For example:

Authorization: Basic <secure-access-token>

Note

Tokens expire after 24 hours.


Accessing an Object

URI Format: <niu-ha>/cc/api/<object>/<object-id>

curl -X GET \
         -H  "Content-Type:application/json" \
         -H "Authorization:Basic <secure-access-token>" \
         "http://localhost/cc/api/service_provider/IMSWorkX"

This GET command will provide a 200 message if the specified object exists:

{
        "meta": {
                "scope": "success",
                "code": "200",
                "records_page_size": "request.parameters.limit",
                "archive": "request.parameters.archive",
                "records_page_offset": "request.parameters.offset"
        },
        "data": [
                {
                        "scope": "number",
                        "meta": {
                                "modified_by": "<string>",
                                "modified": "<datetime>",
                                "created_by": "<string>",
                                "created": "<datetime>"
                        },
                        "attributes": {
                                "rules": "<array>",
                                "timezone": "<string>",
                                "number": "<string>",
                                "subscriber_name": "<string>"
                        }
                }
        ]
}

Table Queries

Tables are lists of objects that can be accessed and modified to affect multiple objects at once.

URI Format: <niu-ha>/cc/api/<object>?<optionalparameters>

Table queries may contain the following parameters, all of which are optional:

{
        "sort": {},
        "search": {},
        "like": {},
        "sort_function": {},
        "icontains": {},
        "limit": {},
        "offset": {}
}
sort

A string that defines how a column is ordered. Accepted values are ‘<column_name> ASC’ to be sorted by ascending value or ‘<column_name> DES’ to be sorted by descending value.

search

A string that is a comma-separated sequence of parameters to search by. There are two formats: ‘:string’ and ‘::’ where the first represents a string search (for example, ‘first_name:Bill’ would find any person with a first name of Bill) and the second represents a between search (for example, ‘customer_number:1000:2000’ would find all records with customer numbers between, but not including, 1000 and 2000). Note that this can also be a datetime object in ISO format.

like

A string that denotes a value to perform a ‘like’ search. This will perform a substring search on any string fields in the object and return if any of these fields are a partial match.

sort_function

A string that overrides ‘sort’. Pass in ::{:}*.

icontains

A string that is a case insensitive ‘contains’ search. Similar to the ‘search’ parameter, you should pass in a comma-separated list of ‘:string’. Exact search takes precedence. The field being searched must be a string-type variable.

limit

An integer that is the number of records to retrieve at a time. The default value is 10.

offset

An integer that is the number of records to skip from the beginning. The default value is 0.

An example CDR query:

curl -X GET \
         -H  "Content-Type:application/json" \
         -H "Authorization:Basic <secure-access-token>" \
         "http://localhost/cc/api/cdr"?offset=0&limit=25&sort=column:asc

Call Detail Records

The following information is returned after a request to retrieve Call Detail Records (CDRs).

{
        "access_number": "<string>",
        "calling_number": "<string>",
        "start_time": "<datetime>",
        "end_time": "<datetime>",
        "account_number": "<string>",
        "charge_number": "<string>",
        "serial_number": "<string>",
        "product_offering_type": "<string>",
        "product_offering_name": "<string>",
        "service_provider_name": "<string>",
        "rates": "<json>",
        "event": "<json>"
}

Endpoints

/cc/api/cc_cdr

GET - Retrieve all CDRs.

/cc/api/cc_cdr/{service_provider_name}

GET - Retrieve the CDR associated with the specified Service Provider.


Creating an Object

Use the POST command without specifying an object ID to create an object. At this time, the object will be given an object ID that can be modified later.

For example:

curl -X POST \
         -H "Content-Type:application/json" \
         -H "Authorization:Basic <secure-access-token>" \
         <ha_address>/cc/api/service_provider -d \
         '{"name": "IMSWorkX", "first_name": "Jane", "last_name": "Doe"...}'

This example POST command will add a new Service Provider named IMSWorkX.


Modifying an Object

When the PUT command is used and the object ID is included in the command, the object is modified.

For example:

curl -X PUT \
         -H "Content-Type:application/json" \
         -H "Authorization:Basic <secure-access-token>" \
         <ha_address>/cc/api/service_provider/IMSWorkX -d \
         '{"first_name": "John", "last_name": "Smith"}'

This example PUT command will change the name of the Service Provider from Jane Doe to John Smith.


Object Definitions

access_number

The following information is used in the body of a request to create and edit different access numbers.

{
        "number": "5555555555",
        "language": "eng",
        "first_greeting": "hello.wav",
        "play_language_selection": true,
        "csr_uri": "CSR@CustomerService.com",
        "service_provider_name": "exampleserviceprovider",
        "access_number_screening_entries": "[]"
}
number

A string that is the access number used to call into the system.

language (optional)

A string that determines the language of the initial greeting for the access number. The default value is “eng”, and the other accepted value is “thai”.

first_greeting (optional)

A string that is the audio file that first plays after this access number is dialed.

play_language_selection (optional)

A boolean value that determines if the language selection prompt is played. The default value is “true”.

csr_uri

A string that is the location to redirect calls to customer service for this access number.

service_provider_name

A unique string that is the name of the Service Provider using this access number. Must match an existing Service Provider.

access_number_screening_entries

An array of objects containing the numbers to screen and the type of screening to apply to each number.

Endpoints

/cc/api/access_number

GET - Retrieve all access numbers.

/cc/api/access_number/{service_provider_name}

GET - Retrieve all access numbers for the specified Service Provider.

POST - Create an access number for the specified Service Provider.

/cc/api/access_number/{service_provider_name}/{number}

GET - Retrieve the specified access number.

PUT - Modify the specified access number if it exists, otherwise create the number.

DELETE - Archive the specified access number.

account

The following information is used in the body of a request to create and edit different accounts.

{
        "number": "123456789",
        "pin": "1234",
        "current_pin": "1234",
        "require_pin_one_step": false,
        "initial_balance": "{"value": 5.00, "unit": "usd"}",
        "current_balance": "{"value": 3.00, "unit": "usd"}",
        "status": "GENERATED",
        "activation_date": "01012020",
        "default_expiration_type": "PRODUCT_OFFERING_EXPIRATION",
        "expiration_date": "01012030",
        "first_use_expiration_duration": "{"value": 0, "unit": "days"}",
        "first_use_activation_type": "FIRST_USE_IVR",
        "one_step_numbers": "[]",
        "use_phone_me": false,
        "phone_me_numbers": "[]",
        "speed_dial_numbers": "[]",
        "first_name": "john",
        "last_name": "doe",
        "email": "email@example.com",
        "constraint_overrides": [],
        "product_offering_name": "productoffering",
        "product_offering_service_provider_name": "serviceprovider",
        "service_provider_name": "serviceprovider",
        "charge_number": "123456789",
        "serial_number": "123456789",
        "identity": "",
        "params": "",
}
number

A unique string that is the card number of the account.

pin

A string that is the PIN of this account.

current_pin (optional)

A string that is the PIN of this account. If an account owner is changing a PIN, this is a required field.

require_pin_one_step (optional)

A boolean value that determines whether the PIN is required when using one-step numbers. If this is null, this defaults to the setting for the associated product offering.

initial_balance (optional)

A JSON object that is the initial balance of the account containing the value and the unit being used.

current_balance (optional)

A JSON object that is the current balance of the account containing the value and the unit being used.

status (optional)

A string that is the status of the account. This field accepts the following values: “ACTIVATED”, “BLOCKED”, “EMPTY”, “EXPIRED”, “GENERATED”, or “UPLOADED”. The default value is “GENERATED”.

activation_date (optional)

A datetime that is the activation date of the account.

default_expiration_type (optional)

A string that is the expiration type for this account. This field accepts the following values: “PRODUCT_OFFERING_EXPIRATION”, “NO_EXPIRATION”, “FIXED_EXPIRATION”, or “DAYS_FROM_FIRST_USE”. The default value is “PRODUCT_OFFERING_EXPIRATION”.

expiration_date (optional)

A datetime that is the expiration date of the account.

first_use_expiration_duration (optional)

A JSON object that is the number of units after the first time the account is used that it will expire containing the integer value and the unit being used. The default unit is “days”.

first_use_activation_type (optional)

A string that determines the activation type when the default_expiration_type is “DAYS_FROM_FIRST_USE”. This field accepts either “FIRST_USE_IVR” or “FIRST_BILLED_CALL”.

one_step_numbers (optional)

An array of one step numbers that are associated with the account.

use_phone_me (optional)

A boolean value where a value of “true” will set calls to default deny, unless a number is on the phone me list. The default value is “false”.

phone_me_numbers (optional)

An array of phone me numbers that are associated with the account.

speed_dial_numbers (optional)

An array of speed dial numbers that are associated with the account.

first_name (optional)

A string that is the first name of a contact for this account.

last_name (optional)

A string that is the last name of a contact for this account.

email (optional)

A string that is the email address of this account.

contraint_overrides (optional)

An array of calling destination constraint overrides used within this account.

product_offering_name

A unique string that is the product offering that is used by this account. Must match an existing product offering.

product_offering_service_provider_name

A unique string that is the Service Provider who provisioned the product offering that this account uses. Must match an existing Service Provider.

service_provider_name

A unique string that is the Service Provider who provisioned this account. Must match an existing Service Provider.

charge_number (optional)

A string that is the number used for billing that will appear in CDRs.

serial_number (optional)

A string that is the serial number used for identifying this account.

identity (optional)

A string that, if set, will set the P-Asserted-Identity header in outbound calls.

parameters (optional)

A JSON object that is a set of parameters to apply to every call.

Endpoints

/cc/api/account

GET - Retrieve all accounts.

/cc/api/account/{service_provider_name}

GET - Retrieve all accounts for the specified Service Provider.

POST - Create a new account.

/cc/api/account/{service_provider_name}/{number}

GET - Retrieve the specified account.

PUT - Modify the account if it exists, otherwise create the account.

DELETE - Archive the specified account.

/cc/api/account/{service_provider_name}/{number}/history

GET - Retrieve a call’s history.

/cc/api/account/{service_provider_name}/{number}/reset

POST - Reset an account’s PIN.

/cc/api/account/{service_provider_name}/{number}/activate

POST - Activate or deactivate an account.

administrator

The following information is used in the body of a request to create and edit different administrator level users.

{
        "username": "John_Doe_admin"
        "role_id": "service_provider:exampleserviceprovider"
        "first_name": "John"
        "last_name": "Doe"
        "email": "jdoe@example.com"
        "permissions": "default:service_provider"
}
username

A unique string that is the user name for this user. Limit of 64 characters.

role_id

A string that defines the type of administrator that is being created. Accepted values are:

  • platform_owner

  • service_provider:<service_provider_name>

first_name (optional)

A string that is the first name of this user. Limit of 250 characters.

last_name (optional)

A string that is the last name of this user. Limit of 250 characters.

email (optional)

A string that is the email address for this user. Limit of 250 characters.

permissions (optional)

An array of permission groups that this user is a member of. Permissions are dependent on the specified role_id of the created administrator.

Endpoints

/cc/api/administrator/{role_id}

GET - Retrieve all users with the specified role.

POST - Create a user with the specified role.

/cc/api/administrator/{role_id}/{username}

GET - Retrieve the user with the specified role and user name.

PUT - Modify the user if it exists, otherwise create the user.

DELETE - Archive the specified user.

/cc/api/administrator/{role_id}/{username}/reset

POST - Reset the password for the specified user, returning a reset token.

audio

The following information is used in the body of a request to create and edit audio files.

{
        "file": "example.wav",
        "location": "/tmp/audio",
        "server": "lab-niu01.lab.redcom.com",
        "label": "example",
        "service_provider_name": "exampleserviceprovider"
}
file

A string that is the name of the audio file. This must be a .wav file. While searching for all files, can use a regex match “^.*?.wav$”.

label (optional)

A string that is a nickname or label to help identify this audio file.

location

A string that is the exact location of the audio file.

server

A string that is the server (NIU or secondary) where the audio file is stored.

service_provider_name

A unique string that is the Service Provider who uses this audio file. Must match an existing Service Provider.

Endpoints

/cc/api/audio/{service_provider_name}

GET - Retrieve all audio files for the specified Service Provider.

POST - Create a new audio file for the specified Service Provider.

/cc/api/audio/{service_provider_name}/{file}

GET - Retrieve the specified audio file.

PUT - Modify the file if it exists, otherwise create the file.

DELETE - Archive the specified audio file.

calling_service

The following information is used in the body of a request to create and edit different calling services.

{
        "name": "callingservice",
        "display_name": "callingservice",
        "description": "An example calling service.",
        "rate_plans": [],
        "minimum_billing": {"value: 0, "unit": "sec"},
        "default_rounding_interval":  {"value": 1, "unit": "sec"},
        "rounding_threshold": {"value": 1, "unit": "sec"},
        "call_markup": {"value": 0.0, "unit": "percent"},
        "service_provider_name": "exampleserviceprovider",
        "promotion_active": true,
        "promotion_duration": "INDEFINITE",
        "promotion_start": "01012020",
        "promotion_end": "01012030",
        "promotion_discount": {"value": 0.0, "unit": "percent"}
}
name

A unique string that is the name of this calling service.

display_name (optional)

An unconstrained string used as a display name for this calling service.

description (optional)

A string that is a description of the calling service.

rate_plans

An array of the rate plans used for this calling service.

minimum_billing (optional)

A JSON object that defines the length of time that a call must be for billing to apply containing the integer value and the unit being used. The default value is “0” and the default unit is “sec”.

default_rounding_interval (optional)

A JSON object that is the amount of time used for rounding total call time containing the integer value and the unit being used. The default value is “1” and the default unit is “sec”.

rounding_threshold (optional)

A JSON object that defines the length of time after which rounding applies containing the integer value and the unit being used. The default value is “1” and the default unit is “sec”.

call_markup (optional)

A JSON object that is the surcharge to be applied after a call is completed containing the value and the unit being used. The default value is “0.00” and the default unit is “percent”.

service_provider_name

A unique string that is the Service Provider who uses this calling service. Must match an existing Service Provider.

promotion_active (optional)

A boolean value where a value of “true” means the promotion periods are in use. The default value is “false”.

promotion_duration (optional)

A string that is the duration of the promotion. This field accepts either “INDEFINITE” or “DATE_PERIOD”. The default value is “INDEFINITE”.

promotion_start (optional)

A timestamp of when the promotion starts.

promotion_end (optional)

A timestamp of when the promotion ends.

promotion_discount (optional)

A JSON object that is the promotion value for the calling service containing the value and the unit being used. The default value is “0.00” and the default unit is “percent”.

Endpoints

/cc/api/calling_service/{service_provider_name}

GET - Retrieve all calling services for the specified Service Provider.

POST - Create a new calling service for the specified Service Provider.

/cc/api/calling_service/{service_provider_name}/{name}

GET - Retrieve the specified calling service.

PUT - Modify the calling service if it exists, otherwise create the calling service.

DELETE - Archive the specified calling service.

constraint

The following information is used in the body of a request to create and edit different calling destination constraints that can be applied to product offerings.

{
        "label": "constraint",
        "description": "Requires 585 area code",
        "type": "REQUIRE",
        "value": "585xxxxxxx",
        "service_provider_name": "exampleserviceprovider"
}
label

A unique string that is the name of this constraint.

description (optional)

A string that is a description of the constraint.

type (optional)

A string that determines whether to require or block the call destination constraint. This field accepts either “REQUIRE” or “BLOCK”.

value

A string that is the call destination constraint value in regex format.

service_provider_name

A unique string that is the Service Provider who uses this constraint. Must match an existing Service Provider.

Endpoints

/cc/api/constraint/{service_provider_name}

GET - Retrieve all constraints for the specified Service Provider.

POST - Create a new constraint for the specified Service Provider.

/cc/api/constraint/{service_provider_name}/{label}

GET - Retrieve the specified constraint.

PUT - Modify the constraint if it exists, otherwise create the constraint.

DELETE - Archive the specified constraint.

product_offering

The following information is used in the body of a request to create and edit different product offerings.

{
        "name": "productoffering",
        "display_name": "productoffering"
        "description": "An example Product Offering",
        "type": "PREPAID_CALLING_CARD",
        "default_expiration_type": "NO_EXPIRATION",
        "default_expiration_date": "01012030"
        "first_use_expiration_duration": {"value": 0, "unit": "days"},
        "first_use_activation_type": "FIRST_USE_IVR",
        "require_pin": true,
        "require_pin_one_step": false,
        "access_numbers": [],
        "maximum_call_duration": {"value": 60, "unit": "minutes"},
        "limit_simultaneous_calls": false,
        "maximum_simultaneous_calls": 1,
        "allow_one_step_list": false,
        "maximum_one_step_numbers": 0,
        "allow_speed_dial_list": false,
        "allow_phone_me_list": false,
        "maximum_phone_me_numbers": 0,
        "routing_prefix": "0110",
        "minimum_balance": {"value": 0.0, "unit": "usd"},
        "maximum_balance": {"value": 50.0, "unit": "usd"},
        "allow_inbound_balance_transfer": false,
        "allow_outbound_balance_transfer": false,
        "disable_account_after_transfer": false,
        "sweep_balance": false,
        "sweep_balance_threshold": {"unit": "usd", "value": 0.00}
        "sweep_balance_activity_threshold": {"value": 0, "unit": "day"},
        "allow_identity": false,
        "allow_charge_number": false,
        "constraints": [],
        "calling_services": [],
        "service_provider_name": "exampleserviceprovider",
        "extend_expiration_after_transfer", false,
        "expiration_extension_type": "EXPIRATION_INTERVAL",
        "expiration_extension": {"value": 0, "unit": "day"}
        "balance_type": "PERSISTENT",
        "periodic_recharge_amount": {"unit": "usd", "value": 10.0}
        "periodic_recharge_type": "MONTHLY",
        "periodic_recharge_timing": 1,
        "last_periodic_recharge": "01012030"
        "second_greeting": "hello.wav",
        "extend_session_balance": false,
        "extended_balance": {"value": 0.00, "unit": "usd"},
        "params": {}
}
name

A string that is the name of this product offering.

display_name (optional)

An unconstrained string used as a display name for this product offering.

description (optional)

A string that is a description of the product offering. Limit 248 characters.

type (optional)

A string that is the product offering type. This field accepts the following values: “PREPAID_CALLING_CARD”, “PREPAID_RESIDENTIAL”, “POSTPAID_CALLING_CARD”, or “POSTPAID_RESIDENTIAL”. The default value is “PREPAID_CALLING_CARD”.

default_expiration_type (optional)

A string that is the product offering expiration type. This field accepts the following values: “NO_EXPIRATION”, “FIXED_EXPIRATION”, and “DAYS_FROM_FIRST_USE”. The default value is “NO_EXPIRATION”.

default_expiration_date (optional)

A datetime that is the expiration date of the product offering.

first_use_expiration_duration (optional)

A JSON object that is the number of units after the product offering is first used that the account cards will expire containing the integer value and the unit being used. The default value is “0” and the default unit is “days”.

first_use_activation_type (optional)

A string that is the activation type for first use expiration. This field accepts either “FIRST_USE_IVR” or “FIRST_BILLED_CALL”. The default value is “FIRST_USE_IVR”.

require_pin (optional)

A boolean value where a value of “false” does not require the associated account to use a PIN to log in. The default value is “true”.

require_pin_one_step (optional)

A boolean value that determines whether the PIN is required when using one-step numbers. The default value is “false”.

access_numbers (optional)

An array of access numbers associated with this product offering.

maximum_call_duration (optional)

A JSON object that is the maximum call duration for any call using this product offering containing the integer value and the unit being used. The default value is “0” and the default unit is “minutes”.

limit_simultaneous_calls (optional)

A boolean value where a value of “true” limits the number of simultaneous calls an account can make. The default value is “false”.

maximum_simultaneous_calls (optional)

An integer that is the maximum number of simultaneous call that can be made from an account. The default value is “1”.

allow_one_step_list (optional)

A boolean value where a value of “true” allows an account to maintain a one-step list. The default value is “false”.

maximum_one_step_numbers (optional)

An integer that is the maximum number of allowed entries in the one-step list. The default value of “0” means there is no limit.

allow_speed_dial_list (optional)

A boolean value where a value of “true” allows an account to maintain a speed dial list. The default value is “false”.

allow_phone_me_list (optional)

A boolean value where a value of “true” allows an account to maintain a phone me list. The default value is “false”.

maximum_phone_me_numbers (optional)

An integer that is the maximum number of allowed entries in the phone me list. The default value of “0” means there is no limit.

routing_prefix (optional)

A string that will be prepended to all outbound calls after leading zeros are stripped.

minimum_balance (optional)

A JSON object that is the minimum balance that an account is allowed to have containing the value and the unit being used. The default value is “0.00” and the default unit is “usd”.

maximum_balance (optional)

A JSON object that is the maximum balance that an account is allowed to have containing the value and the unit being used. The default value is “0.00” and the default unit is “usd”.

allow_inbound_balance_transfer (optional)

A boolean value where a value of “true” allows a balance to be transferred to these accounts. The default value is “false”.

allow_outbound_balance_transfer (optional)

A boolean value where a value of “true” allows a balance to be transferred from these accounts. The default value is “false”.

disable_account_after_transfer (optional)

A boolean value where a value of “true” will disable an account after a balance transfer if the minimum balance is not maintained. The default value is “false”.

sweep_balance (optional)

A boolean value where a value of “true” will cause an account to expire when the balance falls bellow a minimum. The default value is “false”.

sweep_balance_threshold (optional)

A JSON object that is the minimum balance an account must have to be exempt from a balance sweep expiration containing the value and the unit being used. The default value is “0.00” and the default unit is “usd”.

sweep_balance_activity_threshold (optional)

A JSON object that defines how long to wait for an account to have no activity before expiring it due to the sweep_balance setting containing the integer value and the unit being used. The default value is “0” and the default unit is “day”. The “unit” of this JSON accepts the following values: “hour”, “day”, or “year”.

allow_identity (optional)

A boolean value where a value of “true” allows an account owner to set their own identity. The default value is “false”.

allow_charge_number (optional)

A boolean value where a value of “true” allows an account owner to set the charge number on their account. The default value is “false”.

constraints (optional)

An array of calling destination constraints within this product offering.

calling_services

An array of calling services for this product offering.

service_provider_name

A unique string that is the Service Provider who uses this product offering. Must match an existing Service Provider.

extend_expiration_after_transfer (optional)

A boolean value where a value of “true” will extend the expiration date of accounts after a balance transfer. The default value is “false”.

expiration_extension_type (optional)

A string that is the type expiration extension that occurs. This field accepts either “TRANSFER_INTERVAL” or “EXPIRATION_INTERVAL”. The default value is “TRANSFER_INTERVAL”.

expiration_extension (optional)

A JSON object that is how long the expiration date is extended containing the integer value and the unit being used. The default value is “0” and the default unit is “day”. The “unit” of this JSON accepts the following values: “hour”, “day”, or “year”.

balance_type

A string that is the balance type. This field accepts either “PERSISTENT” or “PERIODIC”. A balance type of persistent has no periods associated with it. A balance type of periodic sets up a maximum/minimum amount per period.

periodic_recharge_amount (optional)

A JSON object that is the amount a user will be permitted to debit/credit during a given period containing the value and the unit being used. The default value is “0.00” and the default unit is “usd”.

periodic_recharge_type (optional)

A string that is when a periodic recharge should occur, in conjunction with the periodic_recharge_value setting. This field accepts the following values: “DAILY”, “WEEKLY”, or “MONTHLY”.

periodic_recharge_timing (optional)

An integer that is the timing description for the periodic recharge type. If the periodic recharge type is DAILY, this is the hour (0-23) that the recharge occurs. If the periodic recharge type is WEEKLY, this is the day of the week (0-6, Monday-Sunday) that the recharge occurs. If the periodic recharge type is MONTHLY, this is the day of the month (1-31) that the recharge occurs.

last_periodic_recharge (optional)

A datetime that is the last time a periodic recharge will occur.

second_greeting (optional)

A string that is an audio file to play after authentication.

extend_session_balance (optional)

A boolean value where a value of “true” will extend the balance when within a session. The default value is “false”.

extended_balance

A JSON object that is the separate balance used for establishing sessions and cutting off sessions, when the extend_session_balance setting is set to “true”, containing the value and the unit being used. The default value is “0.00” and the default unit is “usd”.

params (optional)

A JSON object that is a set of parameters to apply to all calls.

Endpoint

/cc/api/product_offering

GET - Retrieve all product offerings.

/cc/api/product_offering/{service_provider_name}

GET - Retrieve all product offerings for the specified Service Provider.

POST - Create a new product offering for the specified Service Provider.

/cc/api/product_offering/{service_provider_name}/{name}

GET - Retrieve the specified product offering.

PUT - Modify the product offering if it exist, otherwise create the product offering.

DELETE - Archive the specified product offering.

rate

The following information is used in the body of a request to create and edit different rates.

{
        "name": "thisrate",
        "display_name": "thisrate",
        "description": "The rate description.",
        "type": "ACCESS_NUMBER",
        "effective_date": "01012020",
        "end_date": "01012030",
        "charge_method": "PER_MINUTE",
        "amount": {"announced": true, "value": {"unit": "usd", "value": 0.10}},
        "surcharge": {"announced": true, "value": {"unit": "percent", "value": 0.50}},
        "if_no_sub_rates_exist": "USE_PARENT_AS_DEFAULT",
        "service_provider_name": "exampleserviceprovider",
        "children": []
}
name

A unique string that is the name of this rate. This name must be at least 6 characters long and no more than 64 characters long.

display_name (optional)

An unconstrained string used as a display name for this rate.

description (optional)

A string that is a description of the rate. Limit 248 characters.

type

A string that is the rate type. This field accepts the following values: “ACCESS_NUMBER”, “BUCKET_OF_MINUTES”, “DOMESTIC_DESTINATION”, “DOMESTIC_ORIGINATION”, “INTERNATIONAL_DESTINATION”, “INTERNATIONAL_ORIGINATION”, “MATRIX_DOMESTIC”, “MATRIX_GLOBAL”, or “PAYPHONE”. The default value is “ACCESS_NUMBER”.

effective_date (optional)

A datetime that is the start date of the rate.

end_date (optional)

A datetime that is the end date of the rate.

charge_method (optional)

A string that is the charge method used to determine the rate. This field accepts either “PER_MINUTE” or “EVENT”. The default value is “PER_MINUTE”.

amount (optional)

A JSON object that determines the charge for the rate containing the value, the unit being used, and whether the amount is announced. The default value is “0.00” and the default unit is “usd”.

surcharge (optional)

A JSON object that determines the rate surcharge containing the value, the unit being used, and whether the amount is announced. The default value is “0.00” and the default unit is “percent”.

if_no_sub_rates_exist (optional)

A string that is the rate behavior if no sub rates have been created. This field accepts the following values: “USE_PARENT_AS_DEFAULT”, “APPLY_NO_RATE”, or “BLOCK_EVENT”. The default value is “USE_PARENT_AS_DEFAULT”.

service_provider_name

A unique string that is the Service Provider who uses this rate. Must match an existing Service Provider.

children (optional)

An array of sub rate values.

Endpoints

/cc/api/rate/{service_provider_name}

GET - Retrieve all rates for the specified Service Provider.

POST - Create a new rate for the specified Service Provider.

/cc/api/rate/{service_provider_name}/{name}

GET - Retrieve the specified rate.

PUT - Modify the rate if it exists, otherwise create the rate.

DELETE - Archive the specified rate.

rate_plan

The following information is used in the body of a request to create and edit different rate plans.

{
        "name": "rateplan",
        "display_name": "rateplan",
        "description": "An example Rate Plan.",
        "modifier_schedule": [],
        "rates": [],
        "service_provider_name": "exampleserviceprovider"
}
name

A unique string that is the name of this rate plan.

display_name (optional)

An unconstrained string used as a display name for this rate plan.

description (optional)

A string that is a description of the rate plan. Limit of 248 characters.

modifier_schedule (optional)

An array that is when the rate plan will be active.

rates

An array of rates associated with this rate plan.

service_provider_name

A unique string that is the Service Provider who uses this rate plan. Must match an existing Service Provider.

Endpoints

/cc/api/rate_plan/{service_provider_name}

GET - Retrieve all rate plans for the specified Service Provider.

POST - Create a new rate plan for the specified Service Provider.

/cc/api/rate_plan/{service_provider_name}/{name}

GET - Retrieve the specified rate plan.

PUT - Modify the rate plan if it exists, otherwise create the rate plan.

DELETE - Archive the specified rate plan.

service_provider

The following information is used in the body of a request to create and edit different Service Providers.

Note

These are not administrator accounts.

{
        "name": "exampleserviceprovider",
        "display_name": "JSMITH",
        "first_name": "John",
        "last_name": "Smith",
        "email": "jsmith@example.com",
        "address": "123 Main St",
        "phone": "5851231234",
        "notes": "Any string here."
}
name

A unique string that is the name of this Service Provider. This name must be at least 8 characters long and no more than 128 characters long.

display_name

An unconstrained string used as a display name for this Service Provider.

first_name (optional)

A string that is the first name of a contact for this Service Provider.

last_name (optional)

A string that is the last name of a contact for this Service Provider.

email (optional)

A string that is the email address of this Service Provider, where notifications and password reset requests will be sent.

address (optional)

A string that is the physical address of this Service Provider.

phone (optional)

A string that is the primary phone number of this Service Provider.

notes (optional)

A string that is a free-form notes field. Limit of 2048 characters.

Endpoints

/cc/api/service_provider

GET - Retrieve all Service Providers.

POST - Create a new Service Provider.

/cc/api/service_provider/{name}

GET - Retrieve the Service Provider with the specified name.

PUT - Modify the Service Provider if it exists, otherwise create the Service Provider.

DELETE - Archive the specified Service Provider.

ucard_account

The following information is used in the body of a request to create and edit UCard integration settings.

{
        "account_number": "1234",
        "service_provider_name": "exampleserviceprovider",
        "access_number": "1234",
        "balance": "0.00"
}
account_number

A string that is the number of this UCard account.

service_provider_name

A unique string that is the Service Provider who uses this UCard account. Must match an existing Service Provider.

access_number

A string that is the number to access this UCard account.

balance

A value that is the current balance of this UCard account.

Endpoints

/cc/api/ucard_account/{service_provider_name}

POST - Create a new UCard account for the specified Service Provider.

/cc/api/service_provider/{account_number}

DELETE - Archive the specified UCard account.

Settings

The following information is used in the body of a request to edit settings. The following example uses the default values.

{
        "branding": {
                "imsworkx": {
                        "color_hue": "75",
                        "highlight_hue": "79",
                        "logo": "logo.png",
                        "label": "IMSWorkX, Inc. &reg;"
                }
        },
        "restworkx": {
                "archive_max_days": "7"
        },
        "web_settings": {
                "help_page": "http://www.imsworkx.com",
                "password_length": "8",
                "curency": "usd"
        },
        "security": {
                "client_cert": null,
                "client_key": null,
                "ca_bundle": null,
                "allow_insecure": false
        },
        "cc_settings": {
                "use_contact": true,
                "egress_route": "127.0.0.1",
                "radius_timeout":"5",
                "rating_interval":"5",
                "ring_type":"180",
                "skip_account_reentry":false
        },
        "email_settings": {
                "use_email": false,
                "host": "",
                "user": "",
                "port": "",
                "password": "",
                "use_tls": false,
                "messages": {
                        "recover": {
                                "subject": "Recover Your Account",
                                "headline": "Account Recovery",
                                "message": "Click the link below to recover your account."
                        },
                        "activate": {
                                "subject": "Activate Your Account",
                                "headline": "Account Activation",
                                "message": "Click the link below to activate your account."
                        }
                }
        }
}
branding

Contains settings related to the look and feel of the website using the following parameters:

imsworkx: The default appearance settings. Additional fields can be added at this level under different names, which can then be appended to the URL for custom branding.

color_hue: (Integer) This will change the primary color used on the site. This value is a number between 0 and 360, using the HSL model where 0 is red, 120 is green, and 240 is blue.

highlight_hue: (Integer) This will change the secondary color used on the site. This value is a number between 0 and 360, using the HSL model where 0 is red, 120 is green, and 240 is blue.

logo: (String) Filename for the logo that will appear in the upper, left corner of the website. The image must be a PNG file and placed in the /var/opt/xpressworkx/app-manager/cc/static/img/ directory.

label: (String) The message displayed in the upper, right corner of the website. This is generally a company name.

restworkx

Contains settings related to the platform and database.

archive_max_days: (Integer) Number of days to keep records in the archive table.

web_settings

Contains settings for elements on the website.

help_page: (String) URL for the web page that is linked in the “Help” button on the upper, right corner of the page.

password_length: (Integer) Minimum number of characters allowed in a password.

currency: (String) A value that determines the default currency of CC. Acceptable values are “usd” or “bot”.

security

Contains settings related to SSL configuration.

client_cert: (String) File location of the client’s certificate.

client_key: (String) File location of the key used for the client’s certificate.

ca_bundle: (String) File location of the root certificate. This is the only setting that matters when SSL is configured by the configure-ssl command and is automatically set by that script.

allow_insecure: (Boolean) If true, the web UI will not check the NIU’s certificate against the configured ca_bundle when making API calls.

cc_settings

Contains settings used during the call flow.

use_contact: (Boolean) If true, the host from the Contact header of the INVITE will be used as the egress_route.

egress_route: (String) The host to use when connecting a call to the called party.

radius_timeout: (Integer) Time in seconds to wait for a Radius response before discontinuing the call.

rating_interval: (Ineger) Time in seconds a call rate is calculated.

ring_type: (String)

skip_account_reentry: (Boolean)

email_settings

Contains settings for automated emails for password changes.

use_email: (Boolean) If true, activation and recovery emails will be sent.

host: (String) Host for email client to send messages through.

user: (String) Username for email service messages will be sent through.

port: (Integer) Port used for email host.

password: (String) Password for the email user.

use_tls: (Boolean) If true, TLS encryption will be used for the email.

messages: Contains settings for the contents of the email message.

recover: Contains settings for the contents of the email message sent when an account’s password is reset.

subject: (String) Subject line of the recovery email message.

headline: (String) Header of the recovery email message body.

message: (String) Message of the recovery email message.

activate: Contains settings for the contents of the email message sent when an account is created.

subject: (String) Subject line of the activation email message.

headline: (String) Header of the activation email message body.

message: (String) Message of the activation email message.

The following information is used in the body of a request to edit Service Provider settings. The following example uses the default values.

{
        "web_settings":{
                "pin_length":"04",
                "ivr_pin_retries":"05",
                "transfer_pin_retries":"15",
                "ivr_pin_reset_duration":{
                        "value":"5",
                        "unit":"hours"},
                "currency":"usd"},
        "cc_settings":{
                "block_with_media":false}
}
web_settings

Contains settings for elements on the website.

pin_length: (Integer) The minimum number of digits that a PIN must be.

ivr_pin_retries: (Integer) The number of times an incorrect PIN can be entered before the account is locked out. This value must be between 3 and 100.

transfer_pin_retries: (Integer) The number of times an incorrect PIN can be entered when transferring a balance before the account is locked out. This value must be between 3 and 100.

ivr_pin_reset_duration: (Array) The length of time an account is locked out after the exceeding the values set for ivr_pin_retries or transfer_pin_retries.

currency: (String) A value that determines the default currency of CC. Acceptable values are “usd” or “bot”.

cc_settings

block_with_media: (Boolean) If true, an audio message is played on a blocked call.

Endpoints

/cc/api/settings/

GET - Retrieve the settings for the current user.

PUT - Modify the settings.


Common Responses

The following common responses may be encountered while using the CC API. The format of these responses may look different from the documented examples based on the tool used to make API calls.

Note

Many HTTP responses are a 200 OK due to the call to the API being successful. It is important to read the body of the response as it could contain an error.

CC Not Installed

When making an API call to a server that does not have CC installed, the following message will be seen.

curl -X POST \
         -H "Content-Type:application/json" \
         <niu-ha>/cc/api/authenticate \
         -d '{"username":"<username>","password":"<password>"}'
         -v

< HTTP/1.1 404 Not Found
< Date: <datetime>
< Server: Apache/2.2.15 (CentOS)
< Content-Length: 412
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /cc/api/authenticate was not found on this server.</p>
</body></html>

Note

This response is not controlled by the CC API and is entirely an HTTP response.

Incorrect Log In

When logging in to the API with incorrect or missing information, the following message will be seen.

curl -X POST \
         -d '{"username":"cc_administrator"}' \
         localhost/cc/api/authenticate
         -v

< HTTP/1.1 200 OK
< Date: <datetime>
< Server: Apache/2.2.15 (CentOS)
< Expires: <datetime>
< Vary: Cookie
< Cache-Control: max-age=0
< Last-Modified: <datetime>
< Content-Type: application/json
< Set-Cookie: cc_sessionid=<cookie>; expires=<datetime>; httponly; Max-Age=1209600; Path=/cc
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0

{"meta": {
        "scope": "exception",
        "message": "The username and password provided were not correct.",
        "code": 401,
        "encoding": "ascii"
        },
"jsonapi": {
        "version": "1.6-7",
        "name": "Calling Card",
        "short_name": "cc",
        "author": "IMSWorkX, Inc."
        }
}

Unauthorized Action

When attempting to perform an action without the proper user permissions, such as a Service Provider creating another Service Provider, the following message will be seen.

{"meta": {
        "scope": "exception",
        "message": "You do not have permission to perform that operation.",
        "code": 403,
        "encoding": "ascii"},
"jsonapi": {"version": "1.6-7",
"name": "Calling Card",
"short_name": "cc",
"author": "IMSWorkX, Inc."}
}

Not Provisioned

When preforming a GET for data that has not been provisioned, the following message will be seen.

curl -X GET \
        -H "Authorization: Basic <secure-access-token>" \
        localhost/cc/api/service_provider/service_test45 \
        -v

< HTTP/1.1 200 OK
< Date: <datetime>
< Server: Apache/2.2.15 (CentOS)
< Expires: <datetime>
< Vary: Cookie
< Cache-Control: max-age=0
< Last-Modified: <datetime>
< Content-Type: application/json
< Set-Cookie: cc_sessionid=<cookie>; expires=<datetime>; httponly; Max-Age=1209600; Path=/cc
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0

{"meta": {
        "code": 200,
        "encoding": "ascii",
        "zoom": 0,
        "records_shown": 0,
        "records_total": 0,
        "scope": "success",
        "message": "",
        "archive": false,
        "authorization": "Basic <secure-access-token>"
        },
"data": [],
"jsonapi": {
        "version": "1.6-7",
        "name": "Calling Card",
        "short_name": "cc",
        "author": "IMSWorkX, Inc."
        }
}

Note

This is technically a successful call to the API, thus the 200 code return.

Object Does Not Exist

When creating an object that does not exist (for example, servi instead of service_provider), the following message will be seen.

curl -X GET \
         -H "Authorization: Basic <secure-access-token>" \
         localhost/cc/api/servi
         -v

< HTTP/1.1 200 OK
< Date: <datetime>
< Server: Apache/2.2.15 (CentOS)
< Expires: <datetime>
< Vary: Cookie
< Cache-Control: max-age=0
< Last-Modified: <datetime>
< Content-Type: application/json
< Set-Cookie: cc_sessionid=<cookie>; expires=<datetime>; httponly; Max-Age=1209600; Path=/cc
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0

{"meta": {
        "scope": "exception",
        "message": "No object 'servi' exists.",
        "code": "404"
        },
"jsonapi": {
        "version": "1.6-7",
        "name": "Calling Card",
        "short_name": "cc",
        "author": "IMSWorkX, Inc."
        }
}

Required Field Missing

If a required field is missing when creating an object, the following message will be seen.

curl -X POST \
         -H "Authorization: Basic <secure-access-token>" \
         localhost/cc/api/service_provider \
         -d '{"last_name":"api_test"}' \
         -v

< HTTP/1.1 200 OK
< Date: <datetime>
< Server: Apache/2.2.15 (CentOS)
< Expires: <datetime>
< Vary: Cookie
< Cache-Control: max-age=0
< Last-Modified: <datetime>
< Content-Type: application/json
< Set-Cookie: cc_sessionid=<cookie>; expires=<datetime>; httponly; Max-Age=1209600; Path=/cc
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0

{"meta": {
        "scope": "exception",
        "message": "ServiceProvider(): Field 'name' is required, but missing.",
        "code": 400,
        "encoding": "ascii"
        },
"jsonapi": {
        "version": "1.6-7",
        "name": "Calling Card",
        "short_name": "cc",
        "author": "IMSWorkX, Inc."
        }
}

No Method at Endpoint

When making a call with a Method that is not valid at the specific endpoint, the following message will be seen.

 curl -X GE \
 -H "Authorization: Basic <secure-access-token>" \
 localhost/cc/api/service_provider/service_test45 \
 -v

< HTTP/1.1 405 METHOD NOT ALLOWED
< Date: <datetime>
< Server: Apache/2.2.15 (CentOS)
< Expires: <datetime>
< Vary: Cookie
< Allow: GET, POST, PUT, DELETE
< Cache-Control: max-age=0
< Last-Modified: <datetime>
< Content-Length: 0
< Content-Type: text/html; charset=utf-8
< Set-Cookie: cc_sessionid=<cookie>; expires=<datetime>; httponly; Max-Age=1209600; Path=/cc
<
* Connection #0 to host localhost left intact
* Closing connection #0

Successful API Call

When making a successful API call, the following message will be seen.

curl -X GET \
        -H "Authorization: Basic <secure-access-token>" \
        localhost/cc/api/service_provider/ \
        -v

< HTTP/1.1 200 OK
< Date: <datetime>
< Server: Apache/2.2.15 (CentOS)
< Expires: <datetime>
< Vary: Cookie
< Cache-Control: max-age=0
< Last-Modified: <datetime>
< Content-Type: application/json
< Set-Cookie: cc_sessionid=<cookie>; expires=<datetime>; httponly; Max-Age=1209600; Path=/cc
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0

{"meta": {
        "code": 200,
        "encoding": "ascii",
        "zoom": 0,
        "records_page_offset": 0,
        "records_shown": 1,
        "records_total": 1,
        "scope": "success",
        "message": "",
        "archive": false,
        "authorization": "Basic <secure-access-token>",
        "records_page_size": 10
},
"data": [{
        <DATA FROM object>
}],
"jsonapi": {
        "version": "1.6-7",
        "name": "Calling Card",
        "short_name": "cc",
        "author": "IMSWorkX, Inc."
        }
}

The above responses can be seen as responses from a stable CC API. If you encounter other undocumented API errors, please contact support@imsworkx.com with the API call and output.


Audit Logging

Audit logs are generated every day by default and are stored as a CSV file. By default, these files are located in /var/opt/xpressworkx/app-manager/cc/logs/audit-logs and are named audit-<year>.<month>.<day>.log.