-
Notifications
You must be signed in to change notification settings - Fork 2
Middleware API
All entry points are relative to /api:
- /version
- /simulate
- /cdr
- /organization/invoices/generate
- /organization/accounts/recharge
- /subscriber/list
- /subscriber/:subscriber_id/accounts
- /subscriber/recharge
- /plan/list
- /plan
- /plan/:plan_id
- /stats/billing
- /stats/carrier_seconds
- /stats/carrier_minutes
- /stats/trunk_usage
- /stats/carrier_status
- /stats/driver_status_by_carrier
Very often (precisely when generic errors can be returned), the API will return a status code 400 (or other error code statuses) and the following json format:
{
"error": {
"payload": "account_id,amount,description",
"description": "missing_parameters"
}
}Be prepared for those messages!
Returns the version number of the middleware and the switch.
- GET
- 200
$ curl -k https://api.connexo.net/version
{
"middleware_version": "1",
"switch_version": "1",
"webapp_version": "1"
}In case of errors communicating with the switch, the switch_version field is "error"
Simulates a call, returning an array of json calls (1 per route found to terminate the call, see the Call Json Format).
- GET
- 200
- trunk: Trunk ID.
- from: E164 number. MUST be an existant DID in the system.
- to: Dialed number, as that particular subscriber would dial (i.e: probably not in E164).
- call_length: Duration in seconds for the simulated call.
$ curl -k "https://api.connexo.net/simulate? \
"trunk=1 \
"from=12035551234 \
"&to=00154115551122 \
"&call_length=15"
It will return approximately 200 cdr records each time for all the accounts of the customer.
For each record returns the following fields:
- ani_e164
- dnis_e164
- ani_src
- dnis_src
- ani_dst
- dnis_dst
- date_created
- id
- bill_time
- dial_status
- trunk_name_dst
- trunk_ip_dst
- GET
- 200
- from: Date. Format: YYYY-MM-DDTHH:MM:SS
- scroll_id: Optional.
$ curl -k "https://api.connexo.net/cdr?from=YYYY-MM-DDTHH:MM:SS"
{
"total": 1,
"total_rows": 1,
"rows": [{
"id":"a957ecd6-1f58-11e5-45g3-a1d7e9eae771",
"ani_dst":"17862799916",
"trunk_ip_dst":"1.2.3.4",
"ani_src":"17862799916",
"dial_status":"answer",
"ani_e164":"17862799916",
"bill_time":7,
"date_created":1435690136000,
"trunk_name_dst":"Carrier.1.2.3.4",
"dnis_e164":"14082571500",
"dnis_src":"14082571500",
"dnis_dst":"14082571500",
"type":"cdr",
"_id":"a957ecd6-1f58-11e5-45g3-a1d7e9eae771-5",
"date_created_as_string":"2015-06-30T15:48:56-03:00"
}],
"scroll_id": "c2NhbjswOzE7dG90YWxfaGl0czowOw=="
}Creates invoices for postpaid accounts
- POST
- application/json
- application/x-www-form-urlencoded
- 204
- 400 (if an error occurs while trying to save an invoice or trying to upload the invoice file to amazon s3)
- orgz_id: Organization ID.
$ curl -k -v -d "orgz_id=1" https://api.connexo.net/organization/invoices/generate
$ curl -k -v -d@req.json -H "content-type: application/json" https://api.connexo.net/organization/invoices/generate
Where req.json is something like this:
{
"orgz_id": "1"
}Recharges subscriber accounts via authorize net merchant if auto-recharge feature is enabled
- POST
- application/json
- application/x-www-form-urlencoded
- 204
- 400 (if an error occurs while trying to recharge account)
- orgz_id: Organization ID.
$ curl -k -v -d "orgz_id=1" https://api.connexo.net/organization/accounts/recharge
$ curl -k -v -d@req.json -H "content-type: application/json" https://api.connexo.net/organization/accounts/recharge
Where req.json is something like this:
{
"orgz_id": "1"
}Returns the complete list of all subscribers.
- GET
- include_accounts: No values. If present, will also return the info for the accounts for each subscriber.
- 200
$ curl -k "https://api.connexo.net/subscriber/list"
[
{
"id": 1,
"name": "Vip2Phone",
"contact_name": "",
"created": "2013-05-29T09:40:59-03:00"
}
]$ curl -k "https://api.connexo.net/subscriber/list?include_accounts"
[
{
"id": 1,
"name": "Vip2Phone",
"contact_name": "",
"created": "2013-05-29T09:40:59-03:00",
"accounts": [
{
"id": 6,
"funds": "100.0",
"credit": "0.0",
"subscriber_id": 1,
"plan_id": 5,
"postpaid": false,
"description": "",
"created": "2014-10-07T13:36:07Z",
"settings": {
},
"enabled": true
}
]
}
]Returns the complete list of all the accounts known for the given subscriber.
- GET
- 200
- 404 (on unknown or invalid subcriber_id)
- subscriber_id: Integer > 0
$ curl -k "https://api.connexo.net/subscriber/1/accounts"
[
{
"id": 1,
"funds": "100000.0",
"credit": "0.0",
"subscriber_id": 1,
"plan_id": 1,
"postpaid": true,
"description": "account description"
"created": "2013-05-29T09:40:59-03:00"
}
]Adds a sum of money to the given account.
- POST
- application/json
- application/x-www-form-urlencoded
- 204
- 400 (on invalid account_id or invalid arguments)
- account_id: Integer > 0.
- amount: String, represents a float, like "12.65".
- description: String. A message giving additional information about this event.
$ curl -k -v -d "account_id=1&amount=12.33&description=here is some money" https://api.connexo.net/subscriber/recharge
$ curl -k -v -d@req.json -H "content-type: application/json" https://api.connexo.net/subscriber/recharge
Where req.json is something like this:
{
"account_id": 1,
"amount": "12.33",
"description": "here is some money"
}Returns the complete list of all plans.
- GET
- 200
$ curl -k "https://api.connexo.net/plan/list"
[
{
"id": 1,
"name": "Regular",
"type": 0,
"dids": 1000,
"charge_incoming": 1,
"allow_incoming": 1,
"created": "2013-06-07T20:39:35-03:00"
}
]Creates a plan.
- PUT
- application/json
- application/x-www-form-urlencoded
- 201: Success operation.
- 409 (If the plan name already exists)
- Location: is returned with the url to access the resource.
- name: Integer > 0.
- type: String, "postpaid" or "prepaid".
- dids: Integer > 0.
$ curl -k -d -vX PUT "name=some_plan&type=postpaid&dids=1&allow_incoming=true&charge_incoming=true" -vX PUT https://api.connexo.net/plan"
$ curl -k -X PUT -v -d@req.json -H "content-type: application/json" https://api.connexo.net/plan
Result:
Location: https://api.connexo.net/plan/12
{"id":12}
Where req.json is something like this:
{
"name": "Regular",
"allow_incoming": true,
"charge_incoming": true,
"dids": 3,
"type": "postpaid"
}Returns the plan information, by id.
- GET
- 200
- 404 (if the plan id does not exist).
- plan_id: Integer > 0
$ curl -k "https://api.connexo.net/plan/11"
{
"id": 1,
"name": "Regular",
"type": 0,
"dids": 1000,
"allow_incoming": 1,
"charge_incoming": 1,
"created": "2013-06-07T20:39:35-03:00"
}Income vs cost report.
- GET
- 200
- 400 (on invalid or missing arguments)
- start: String, in the form "YYYY-MM-DD".
- end: String, in the form "YYYY-MM-DD".
- granularity: "daily" | "hourly"
- type: cost|income. If specified, the report will only contains the specified values.
- tag: String. If specified, the report will only contain this specific tag.
$ curl -k "https://api.connexo.net/stats/billing? \
start=2013-06-15 \
&end=2013-06-20 \
&granularity=daily"
[{
"name": "Daily income",
"pointStart": 1371254400,
"pointInterval": 86400,
"data": [0,0.01125,0,0,0,0.16875]
}, {
"name": "Daily cost",
"pointStart": 1371254400,
"pointInterval": 86400,
"data": [0,0.0110,0,0,0,0.2]
}]Total number of seconds of answered calls through all the known carriers.
- GET
- 200
- 400 (on invalid or missing arguments)
- start: String, in the form "YYYY-MM-DD".
- end: String, in the form "YYYY-MM-DD".
- granularity: "daily" | "hourly"
$ curl -k "https://api.connexo.net/stats/carrier_seconds? \
start=2013-06-15 \
&end=2013-06-20 \
&granularity=hourly"
[
{
"name": "Local",
"pointStart": 1356998400000,
"pointInterval": 3600000,
"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
},
{
"name": "Vitelity",
"pointStart": 1356998400000,
"pointInterval": 3600000,
"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
}
]Total number of minutes of answered calls through all the known carriers.
- GET
- 200
- 400 (on invalid or missing arguments)
- start: String, in the form "YYYY-MM-DD".
- end: String, in the form "YYYY-MM-DD".
- granularity: "daily" | "hourly"
$ curl -k "https://api.connexo.net/stats/carrier_minutes? \
start=2013-06-15 \
&end=2013-06-20 \
&granularity=hourly"
[
{
"name": "Local",
"pointStart": 1356998400000,
"pointInterval": 3600000,
"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
},
{
"name": "Vitelity",
"pointStart": 1356998400000,
"pointInterval": 3600000,
"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
}
]By trunk type, returns how many channels were used. Trunk type is one of:
- internal
- subscriber
- carrier
- GET
- 200
- 400 (on invalid or missing arguments)
- start: String, in the form "YYYY-MM-DD".
- end: String, in the form "YYYY-MM-DD".
- granularity: "daily" | "hourly"
$ curl -k "https://api.connexo.net/stats/trunk_usage? \
start=2013-06-15 \
&end=2013-06-20 \
&granularity=hourly"
[
{
"name": "internal",
"title": "internal trunk usage",
"pointStart": 1381363200000,
"pointInterval": 86400000,
"data": [0,0,0,7,0]
},
{
"name": "subscriber",
"title": "subscriber trunk usage",
"pointStart": 1381363200000,
"pointInterval": 86400000,
"data":[0,0,0,0,0]
},
{
"name": "carrier",
"title": "carrier trunk usage",
"pointStart": 1381363200000,
"pointInterval": 86400000,
"data": [0,0,0,2,0]
}
]Returns statistics about calls made using carriers, their status and driver_status.
- GET
- 200
- 400 (on invalid or missing arguments)
- start: String, in the form "YYYY-MM-DD".
- end: String, in the form "YYYY-MM-DD".
$ curl -k "https://api.connexo.net/stats/carrier_status? \
start=2013-06-15 \
&end=2013-06-20"
{
"status": [
["error",1],
["finish",1071]
],
"driver_status": [
["invalid_number_format",0],
["normal_temporary_failure",4],
["call_rejected",0],
["allotted_timeout",15],
["incompatible_destination",0],
["answer",704],
["normal_clearing",0],
["invalid_gateway",0],
["invalidargs",0],
["unallocated_number",0],
["cancel",81],
["error",0]
]
}Returns statistics about driver statuses per carrier.
- GET
- 200
- 400 (on invalid or missing arguments)
- start: String, in the form "YYYY-MM-DD".
- end: String, in the form "YYYY-MM-DD".
- carrier_id: Integer
$ curl -k "https://api.connexo.net/stats/driver_status_by_carrier? \
start=2013-06-15 \
&end=2013-06-20" \
&carrier_id=4
{
"carrier": "Conexiant",
"series": [
["invalid_number_format",0],
["normal_temporary_failure",4],
["call_rejected",0],
["allotted_timeout",23],
["incompatible_destination",0],
["answer",834],
["normal_clearing",0],
["invalid_gateway",0],
["simulated",0],
["dontcall",2],
["originator_cancel",230],
["success",0],
["early media",0],
["invalidargs",0],
["unallocated_number",0],
["cancel",85],
["error",0],
["missing",0],
["busy",35],
["user_busy",0],
["recovery_on_timer_expire",0],
["no_user_response",0],
["noanswer",48],
["user_not_registered",0],
]
}