|
API
Nuntium public Application Programming Interface
Featured Public API
Libraries
Authentication
CarriersList all carriersHTTP GET /api/carriers.{xml|json}?country_id=CC(C) Authentication: none List of carriers with their GUIDs for a given country. The country code can be the iso 2 or 3 letters. If no country code is given, all carriers are listed. Examples Request: HTTP GET /api/carriers.xml?country_code=ar Response: HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <carriers type="array"> <carrier name="Personal" country_iso2="ar" guid="c09dc81a-2f0d-4332-9459-ab49e6690908"/> </carriers> Request: HTTP GET /api/carriers.json?country_code=ar Response: HTTP/1.1 200 OK [{"name":"Personal","guid":"c09dc81a-2f0d-4332-9459-ab49e6690908","country_iso2":"ar"}]Show a carrierHTTP GET /api/carriers/<guid>.{xml|json} Authentication: none Show a carrier given its GUID. Responds with HTTP_NOT_FOUND if the carrier with the given GUID does not exist. Examples Request: HTTP GET /api/carriers/c09dc81a-2f0d-4332-9459-ab49e6690908.xml Response: HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <carrier name="Personal" country_iso2="ar" guid="c09dc81a-2f0d-4332-9459-ab49e6690908"/> Request: HTTP GET /api/carriers/c09dc81a-2f0d-4332-9459-ab49e6690908.json Response: HTTP/1.1 200 OK {"name":"Personal","guid":"c09dc81a-2f0d-4332-9459-ab49e6690908","country_iso2":"ar"}ChannelsChannel specificationEvery channel in nuntium must have the following properties:
Additionally each channel has configuration properties that are specific to each channel kind. clickatell
dtac
pop3
qst_client
qst_server
smpp
smtp
xmpp
List all channelsHTTP GET /api/channels.{xml|json} Authentication: account, application List both channels that belong to an application and that does not belong to any application. Examples Request: HTTP GET /api/channels.xml Response: HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel kind="clickatell" direction="outgoing" enabled="true" name="foo" protocol="sms" priority="100" address="sms://1234">
<configuration>
<property value="1" name="api_id"/>
<property value="c" name="from"/>
<property value="45" name="network"/>
<property value="a" name="user"/>
<property value="3" name="concat"/>
</configuration>
<restrictions>
<property value="bar" name="foo"/>
<property value="baz" name="foo"/>
<property value="prop" name="another"/>
</restrictions>
</channel>
</channels>Request: HTTP GET /api/channels.json Response: HTTP/1.1 200 OK [{
"kind": "clickatell",
"direction": "outgoing",
"enabled": "true",
"configuration":[
{"value": "1", "name": "api_id"},
{"value": "c", "name": "from"},
{"value": "45", "name": "network"},
{"value": "a", "name": "user"},
{"value": "3", "name": "concat"}
],
"restrictions":[
{"value": ["bar", "baz"], "name": "foo"},
{"value": "prop", "name": "another"}
]
"name":"foo",
"protocol":"sms",
"priority":100,
"address":"sms://1234"
}]Create a channelHTTP POST /api/channels.{xml|json} Authentication: account, application Creates a channel that will belong to an application. Responds with HTTP_BAD_REQUEST if the some of the channel's fields are not valid. Check the errors section for more info. Examples Request: HTTP POST /api/channels.xml <?xml version="1.0" encoding="UTF-8"?>
<channel kind="clickatell" direction="outgoing" enabled="true" name="foo" protocol="sms" priority="100" address="sms://1234">
<configuration>
<property value="1" name="api_id"/>
<property value="c" name="from"/>
<property value="45" name="network"/>
<property value="a" name="user"/>
<property value="3" name="concat"/>
</configuration>
<restrictions>
<property value="bar" name="foo"/>
<property value="baz" name="foo"/>
<property value="prop" name="another"/>
</restrictions>
</channel>Response: HTTP/1.1 200 OK Request: HTTP POST /api/channels.json {
"kind": "clickatell",
"direction": "outgoing",
"enabled": "true",
"configuration":[
{"value": "1", "name": "api_id"},
{"value": "c", "name": "from"},
{"value": "45", "name": "network"},
{"value": "a", "name": "user"},
{"value": "3", "name": "concat"}
],
"restrictions":[
{"value": ["bar", "baz"], "name": "foo"},
{"value": "prop", "name": "another"}
]
"name":"foo",
"protocol":"sms",
"priority":100,
"address":"sms://1234"
}Response: HTTP/1.1 200 OK Update a channelHTTP POST /api/channels.{xml|json} Authentication: account, application Updates a channel that belongs to an application. Only the attributes present in the given xml/json will be updated: the others will remain untouched. If a configuration element is present, all of the configuration values will be updated. The same is true for the restrictions element. Responds with HTTP_NOT_FOUND if the channel does not exist. Responds with HTTP_FORBIDDEN if the channel belongs to another application (when authenticated as an application). Responds with HTTP_BAD_REQUEST if some of the channel's fields are not valid. Check the errors section for more info. Examples Request: HTTP PUT /api/channels/foo.xml <?xml version="1.0" encoding="UTF-8"?>
<channel kind="clickatell" direction="outgoing" enabled="true" name="foo" protocol="sms" priority="100" address="sms://1234">
<configuration>
<property value="1" name="api_id"/>
<property value="c" name="from"/>
<property value="45" name="network"/>
<property value="a" name="user"/>
<property value="3" name="concat"/>
</configuration>
<restrictions>
<property value="bar" name="foo"/>
<property value="baz" name="foo"/>
<property value="prop" name="another"/>
</restrictions>
</channel>Response: HTTP/1.1 200 OK Request: HTTP PUT /api/channels/foo.json {
"kind": "clickatell",
"direction": "outgoing",
"enabled": "true",
"configuration":[
{"value": "1", "name": "api_id"},
{"value": "c", "name": "from"},
{"value": "45", "name": "network"},
{"value": "a", "name": "user"},
{"value": "3", "name": "concat"}
],
"restrictions":[
{"value": ["bar", "baz"], "name": "foo"},
{"value": "prop", "name": "another"}
]
"protocol":"sms",
"priority":100,
"address":"sms://1234"
}Response: HTTP/1.1 200 OK Show a channelHTTP GET /api/channels/<channel_name>.{xml|json} Authentication: account, application Show the channel that belong to an application or that does not belong to any application. Responds with HTTP_NOT_FOUND if the channel does not exist. Examples Request: HTTP GET /api/channels/foo.xml Response: HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?>
<channel kind="clickatell" direction="outgoing" enabled="true" name="foo" protocol="sms" priority="100" address="sms://1234">
<configuration>
<property value="1" name="api_id"/>
<property value="c" name="from"/>
<property value="45" name="network"/>
<property value="a" name="user"/>
<property value="3" name="concat"/>
</configuration>
<restrictions>
<property value="bar" name="foo"/>
<property value="baz" name="foo"/>
<property value="prop" name="another"/>
</restrictions>
</channel>Request: HTTP GET /api/channels/foo.json Response: HTTP/1.1 200 OK {
"kind": "clickatell",
"direction": "outgoing",
"enabled": "true",
"configuration":[
{"value": "1", "name": "api_id"},
{"value": "c", "name": "from"},
{"value": "45", "name": "network"},
{"value": "a", "name": "user"},
{"value": "3", "name": "concat"}
],
"restrictions":[
{"value": ["bar", "baz"], "name": "foo"},
{"value": "prop", "name": "another"}
]
"name":"foo",
"protocol":"sms",
"priority":100,
"address":"sms://1234"
}Delete a channelHTTP DELETE /api/channels/<channel_name> Authentication: account, application Deletes a channel that belong to an application. Responds with HTTP_NOT_FOUND if the channel does not exist. Responds with HTTP_FORBIDDEN if the channel belongs to another application (when authenticated as an application). Examples Request: HTTP DELETE /api/channels/foo Response: HTTP/1.1 200 OK Candidate channelsHTTP GET /api/candidate/channels.{xml|json}?from=...&to=...&subject=...&body=... Authentication: application List candidate channels that will be used when routing the given AO Message, that is, the result of the Channel Filter Phase. This does not perform the routing, it just simulates it and returns the candidate channels list. Examples Request: HTTP GET /api/candidate/channels.xml?from=sms://1&to=sms://2&subject=Hello&body=Hi Response: HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel kind="clickatell" direction="outgoing" enabled="true" name="foo" protocol="sms" priority="100" address="sms://1234">
<configuration>
<property value="1" name="api_id"/>
<property value="c" name="from"/>
<property value="45" name="network"/>
<property value="a" name="user"/>
<property value="3" name="concat"/>
</configuration>
<restrictions>
<property value="bar" name="foo"/>
<property value="baz" name="foo"/>
<property value="prop" name="another"/>
</restrictions>
</channel>
</channels>Request: HTTP GET /api/candidate/channels.json?from=sms://1&to=sms://2&subject=Hello&body=Hi Response: HTTP/1.1 200 OK [{
"kind": "clickatell",
"direction": "outgoing",
"enabled": "true",
"configuration":[
{"value": "1", "name": "api_id"},
{"value": "c", "name": "from"},
{"value": "45", "name": "network"},
{"value": "a", "name": "user"},
{"value": "3", "name": "concat"}
],
"restrictions":[
{"value": ["bar", "baz"], "name": "foo"},
{"value": "prop", "name": "another"}
]
"name":"foo",
"protocol":"sms",
"priority":100,
"address":"sms://1234"
}]Specific channel APIsSome channel kinds support additional API methods. Create friendshipHTTP GET /api/channels/<name>/twitter/friendships/create?user=<user>&follow=<follow> Authentication: account, application Creates a friendship between the channel's twitter account and the given user. Returns HTTP_OK if the friendship could be created or if the frienship already existed. Refer to Twitter's documentation: http://apiwiki.twitter.com/Twitter-REST-API-Method:-friendships%C2%A0create Responds with HTTP_NOT_FOUND if the channel does not exist. Responds with HTTP_FORBIDDEN if the channel belongs to another application (when authenticated as an application). Responds with HTTP_BAD_REQUEST if the channel is not a Twitter channel. Channel errorsWhen creating or updating a channel, if some of the fields are missing or are invalid, an HTTP_BAD_REQUEST response is returned. The body of the response contains the error messages. Examples Request: HTTP POST /api/channels.xml <?xml version="1.0" encoding="UTF-8"?>
<channel kind="clickatell" direction="outgoing" enabled="true" name="foo" priority="100">
<configuration>
<property value="1" name="api_id"/>
<property value="c" name="from"/>
<property value="45" name="network"/>
<property value="a" name="user"/>
<property value="3" name="concat"/>
</configuration>
<restrictions>
<property value="bar" name="foo"/>
<property value="baz" name="foo"/>
<property value="prop" name="another"/>
</restrictions>
</channel>Response: HTTP/1.1 400 BAD REQUEST <?xml version="1.0" encoding="UTF-8"?> <error summary="There were some problems"> <property name="protocol" value="can't be blank" /> </error> Request: HTTP POST /api/channels.json Response: HTTP/1.1 400 BAD REQUEST {
"summary": "There were some problems",
"properties" => {
"protocol" => "can't be blank"
}
}CountriesList all countriesHTTP GET /api/countries.{xml|json} Authentication: none List of countries with their phone prefixes known for Nuntium. Examples Request: HTTP GET /api/countries.xml Response: HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <countries> <country name="Argentina" iso2="ar" iso3="arg" phone_prefix="54" /> </countries> Request: HTTP GET /api/countries.json Response: HTTP/1.1 200 OK [{
"name": "Argentina",
"iso2": "ar",
"phone_prefix": "54",
"iso3": "arg"
}]Show a countryHTTP GET /api/countries/<iso2_or_iso3>.{xml|json} Authentication: none Shows a country given its iso2 or iso3 code. Responds with HTTP_BAD_REQUEST if no country exists with that iso code. Examples Request: HTTP GET /api/countries/ar.xml Response: HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <country name="Argentina" iso2="ar" iso3="arg" phone_prefix="54" /> Request: HTTP GET /api/countries/ar.json Response: HTTP/1.1 200 OK {
"name": "Argentina",
"iso2": "ar",
"phone_prefix": "54",
"iso3": "arg"
}MessagesSend an Application Originated messageHTTP GET /<account_name>/<application_name>/send_ao.{xml|json}
HTTP POST /<account_name>/<application_name>/send_ao.{xml|json}Authentication: application Sends one or more Application Originated messages. If no format is specified (the request is made as just send_ao) one message will be sent and the request should include form data. The form data can contain the following fields: from, to, subject, body, guid, timestamp, token. Additional form data will be set as custom attributes, with the exception of the following fields: controller, action, application_name, account_name. If the JSON format is specified (send_ao.json) the POST body must be an array of hashes. If the XML format is specified (send_ao.xml) the POST body must be as specified in the QST protocol. Responds with HTTP_OK. In any case, the following custom HTTP headers will be sent in the response:
Examples Request: HTTP GET /account_name/application_name/send_ao?from=sms://0&to=sms://1&subject=Hello Response: HTTP/1.1 200 OK X-Nuntium-Id: 1343 X-Nuntium-Guid: 2b483424-2c2a-4702-b391-651f2a21da9d X-Nuntium-Token: 8212275-c104-1bbd-4a22-a94943fa263d2 Get Application Originated messagesHTTP GET /<account_name>/<application_name>/get_ao.json?token={token}Authentication: application Gets Application Originated messages with the given token. Returns a JSON, an array of hashes with the properties of the message: from, to, subject, body, guid, state, channel (the channel's name), channel_kind and custom atrributes. Responds with `HTTP_OK. |