Welcome
Get started sending SMS from your own system via CPSMS.dk API. This is the documentation listing all endpoints / methods.
Getting started
Info | Value |
---|---|
Host | api.cpsms.dk/v2 |
Port | 443 |
Protocol | HTTPS |
Authentication | Basic Authentication |
HTTP request methods | POST GET PUT DELETE |
User account
First step is to create a user account at cpsms.dk. You get the first 10 SMS points for free.
Generate a API key
You have to generate a API key at cpsms.dk.
This is the password to use the API.
Navigate to the INDSTILLINGER -> API
section and then generate an API key.
Generally
Data can be send as GET parameters or posted as a JSON object. Except for SMS and GroupSMS endpoints. - these requires data to be send as JSON objects
It is not possible to use a mix of GET parameters and a JSON object.
The HTTP requests show examples with parameters set as GET.
The code examples are shown as JSON objects.
Authentication
To authorize, use this code:
# With cURL, you can just pass the correct header with each request
curl "https://api.cpsms.dk/v2/endpoint"
-H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
<?php
$username = "Your CPSMS username";
$apiKey = "Your generated key";
CURLOPT_HTTPHEADER => array(
"Authorization: Basic " . base64_encode($username . ':' . $apiKey)
);
Make sure to replace $username and $apiKey with your own credentials.
CPSMS requires Basic Authorization to access the API. The token is your CPSMS username and your API key, concatenated with a colon, encoded as base64
Authorization: Basic <token>
SMS
Send
curl -X POST -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"to":"4522334488", "message": "This is the message text body", "from": "Compaya", "timestamp": 1474970400
}
' "https://api.cpsms.dk/v2/send"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/send",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"to":"4522334488", "message": "This is the message text body", "from": "Compaya", "timestamp": 1474970400}',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": [
{
"to": "4522334488",
"cost": 1
"smsAmount": 1
}
]
}
If an error is returned when trying to send to only one recipient, this is an example of error response:
{
"error":
{
"code": 400,
"message": "Phone number should be specified as a number"
}
}
If you set multiple recipients, the delivery report will contain statuses for every message, like so:
{
"success": [
{
"to": "4522334488",
"cost": 1
"smsAmount": 1
},
{
"to": "4533445599",
"cost": 1
"smsAmount": 1
}
],
"error": [
{
"code": 409,
"message": "Phone number length and country code do not match.",
"to": "45883311008"
}
]
}
This endpoint lets you send an SMS to one or multiple recipients.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
to required |
string or array | The recipient(s) of the message. The number starting with country code. |
message required |
string(1530) | The body text of the SMS message. Specifies the message to be sent. All characters allowed by the SMS protocol are accepted. If the message contains any illegal characters, they are automatically removed, and the message shortened. The maximum message length is 1530 characters, which is the length of 10 SMS'es joined together. |
from (required) |
string(11/15) | Set the number that the receiver will see as the sender of the SMS. It can be either numeric with a limit of 15 chars or alphanumeric with a limit of 11 chars. You can define a default from INDSTILLINGER -> GENERELT -> Standard afsendernavn. |
timestamp | int (unix timestamp) |
If specified, the message will be sent at this time. |
encoding | string | Default is UTF-8 . Alternative ISO-8859-1 . |
dlr_url | string | If specified, delivery reports will be send to this address via GET. If for example the dlr_url is http://google.com/ then CPSMS.dk will append ?status=x&receiver=xx Example: http://google.com/?status=x&receiver=xx If needed you can add your own parameters at the end of your dlr_url .See status parameters table. |
flash | int | Default is 0 . Specifies if the SMS should be sent as a flash SMS. |
reference | string(32) | An optional reference of your choice. |
format | string | Default is GSM - See table below for details |
Format parameter
Format type | Description |
---|---|
GSM | Send normal message (160 chars, but if more than 160 chars, 153 chars per part message) |
UNICODE | To send speciality chars like chinese letters. A normal message is 160 chars, but if you use unicode each message can only hold up to 70 chars (But if more than 70 chars, 67 chars per part message) |
Status parameters (dlr_url)
Status | Description |
---|---|
1 | Delivery successful |
2 | Delivery failed |
4 | Message buffered |
8 | Delivery abandoned |
Send to group
curl -X POST -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"to_group":12345, "message": "This is the message text body", "from": "Compaya", "timestamp": 1474970400
}
' "https://api.cpsms.dk/v2/sendgroup"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/sendgroup",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"to_group":12345, "message": "This is the message text body", "from": "Compaya", "timestamp": 1474970400}',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": [
{
"to": "4522334488",
"cost": 1
"smsAmount": 1
},
{
"to": "4522334499",
"cost": 1
"smsAmount": 1
},
{
"to": "46522334455",
"cost": 1.6
"smsAmount": 1
}
]
}
This endpoint lets you send a SMS to recipients you have created as contacts in a group.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
to_group required |
int | Specify the Group ID where you have your contacts. |
message required |
string(1530) | The body text of the SMS message. Specifies the message to be sent. All characters allowed by the SMS protocol are accepted. If the message contains any illegal characters, they are automatically removed, and the message shortened. The maximum message length is 1530 characters, which is the length of 10 SMS'es joined together. |
from (required) |
string(11/15) | Set the number that the receiver will see as the sender of the SMS. It can be either numeric with a limit of 15 chars or alphanumeric with a limit of 11 chars. You can define a default from INDSTILLINGER -> GENERELT -> Standard afsendernavn. |
timestamp | int (unix timestamp) |
If specified, the message will be sent at this time. |
encoding | string | Default is UTF-8 . Alternative ISO-8859-1 . |
dlr_url | string | If specified, delivery reports will be POSTed to this address. See details in Send example here. |
flash | int | Default is 0 . Specifies if the SMS should be sent as a flash SMS. |
reference | string(32) | An optional reference of your choice. |
Simple send (as GET)
This endpoint lets you send an SMS as GET. Makes it possible to send an SMS in the URL. The only limitation is that newline/line break is not accepted.
curl -X GET "https://cpsmsuser:18bf8100-d5e2-4660-a214-84ecdd5d1710@api.cpsms.dk/v2/simplesend/4522335544/message/CPSMS"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://cpsmsuser:18bf8100-d5e2-4660-a214-84ecdd5d1710@api.cpsms.dk/v2/simplesend/4522335544/message/CPSMS",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": [
{
"to": "4522335544",
"cost": 1
}
]
}
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
to required |
string | The recipient(s) of the message. The number starting with country code. |
message required |
string(1530) | The body text of the SMS message. Specifies the message to be sent. All characters allowed by the SMS protocol are accepted except newline/line break. If the message contains any illegal characters, they are automatically removed, and the message shortened. The maximum message length is 1530 characters, which is the length of 10 SMS'es joined together. |
from (required) |
string(11/15) | Set the number that the receiver will see as the sender of the SMS. It can be either numeric with a limit of 15 chars or alphanumeric with a limit of 11 chars. You can define a default from INDSTILLINGER -> GENERELT -> Standard afsendernavn. |
SMS credit
curl -X POST -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" "https://api.cpsms.dk/v2/creditvalue"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/creditvalue",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"credit": "9.843,40"
}
This endpoint lets you see how many credits you have left on your account.
HTTP Request
Delete SMS
curl -X DELETE -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" "https://api.cpsms.dk/v2/deletesms"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/deletesms",
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"reference":"<reference>"',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": "SMS(s) deleted"
}
With this endpoint you can delete an SMS that has been set with a <timestamp>
to send at some point in the future.
The <timestamp>
has to be greater than 10 minutes from delete time.
You must have set a <reference>
on the SMS to be able to delete it.
Every SMS with the specified <reference>
that meets the criteria will be deleted
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
reference required |
string(32) | The identifier set by you, when you posted the SMS. |
Group
Create group
curl -X POST -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"groupName": "This is a new group"
}
' "https://api.cpsms.dk/v2/addgroup"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/addgroup",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"groupName": "This is a new group"}',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": {
"groupId": "11986",
"groupName": "This is a new group"
}
}
This endpoint creates a group for contacts.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
groupName required |
string | Name of the group. |
List group(s)
curl -X GET -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
' "https://api.cpsms.dk/v2/listgroups"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/listgroups",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
[
{
"groupId": 11963,
"groupName": "Group 1"
},
{
"groupId": 11964,
"groupName": "Group 2"
},
{
"groupId": 11966,
"groupName": "Group 3"
}
]
The above command returns JSON structured like this:
With this endpoint you can view all your groups.
HTTP Request
Update group
curl -X PUT -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"groupId": <group ID>
"groupName": "<new name of group>"
}
' "https://api.cpsms.dk/v2/updategroup"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/updategroup",
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"groupId": <group ID>, "groupName": "<New name of group>" }',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": "groupId <groupId> Updated"
}
This endpoint updates a group.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
groupId required |
int | The ID of the group. You can find the ID with the listGroups API function or at CPSMS.dk. |
groupName required |
string | Name of the group. |
Delete group
curl -X DELETE -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"groupId": <group ID>
}
' "https://api.cpsms.dk/v2/deletegroup"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/deletegroup",
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => "{\n \"groupId\": <group ID>\n }",
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": "Group <groupId> deleted"
}
This endpoint deletes a group. A group can only be deleted if it does not contain Contacts.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
groupId required |
int | The ID of the group. You can find the ID with the listGroups API function or at CPSMS.dk. |
Contact
Create Contact
curl -X POST -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"groupId": 11969, "phoneNumber": "4596322222", "contactName": "Customer1"
}
' "https://api.cpsms.dk/v2/addcontact"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/addcontact",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"groupId": 11969,"phoneNumber": "4596322222","contactName": "Customer1"}',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": "Contact created/added in group"
}
This endpoint lets you create a new contact or add an existing contact to a group. If the contact exists in another group it will also be added to the new specified group.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
groupId required |
int | Id of the group the contact is to be placed in. |
phoneNumber required |
string | The phone number for the contact starting with country code. |
contactName | string | Name/ identifier of the contact. |
List contact(s)
curl -X GET -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
' "https://api.cpsms.dk/v2/listcontacts/<groupId>"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/listcontacts/<groupId>",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
[
{
"phoneNumber": "4595222222",
"contactName": "Contact1",
"timeAdded": 1481150286
},
{
"phoneNumber": "4596222222",
"contactName": "Contact2",
"timeAdded": 1481150286
},
{
"phoneNumber": "4588389000",
"contactName": "CPSMS help",
"timeAdded": 1481150286
}
]
This endpoint can list all contacts in a given group.
You need to specify a groupId
.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
groupId required |
int | Specifies a group. |
Update contact
curl -X PUT -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"phoneNumber": "4595222222" ,
"groupId": 11969,
"contactName":"New contact"
}
}
' "https://api.cpsms.dk/v2/updatecontact"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/updatecontact",
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"phoneNumber": "4595222222" ,"groupId": 11969,"contactName":"New contact"}',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": "Contact updated"
}
This endpoint updates a contact.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
groupId required |
int | The ID of the group. You can find the ID with the listGroups API function or at CPSMS.dk. |
phoneNumber required |
string | The phone number for the contact starting with country code. |
contactName | string | Name of the contact. |
Delete contact
curl -X DELETE -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -d '
{
"phoneNumber": "4595222222" ,
"groupId": 11969
}
' "https://api.cpsms.dk/v2/deletecontact"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/deletecontact",
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '{"phoneNumber": "4595222222" ,"groupId": 11969,',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": "Contact deleted/removed"
}
This endpoint removes a contact from a group. If the contact is removed from all groups, it will be completely deleted.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
groupId required |
int | The ID of the group. You can find the ID with the listGroups API function or at CPSMS.dk. |
phoneNumber required |
string | The contacts phone number. With country code. |
List group membership
curl --request GET \
--url https://api.cpsms.dk/v2/listgroupmembership/4598877665
--header 'Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=='
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/listgroupmembership/4598877665",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
{
"success": {
"groupId": "462644",
"groupName": "Group name"
}
}
If multiple results, JSON is structured like this:
{
"success": [
{
"groupId": "338025",
"groupName": "Group name 2"
},
{
"groupId": "462644",
"groupName": "Group name"
}
]
}
This endpoint lists all groups of a given contact.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
phoneNumber required |
string | The contacts phone number. With country code. |
Log
Getlog
curl -X GET -H "Authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg==" -H "https://api.cpsms.dk/v2/getlog"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.cpsms.dk/v2/getlog",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => '',
CURLOPT_HTTPHEADER => array(
"authorization: Basic bGFyc3ZpbmRlcjpHdWxlR3VtbWlzdMO4dmxlcg=="
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if($httpCode == 200) {
echo 'OK: ' . $response;
} else {
echo 'Read response message for details: ' . $response;
}
The above command returns JSON structured like this:
[
{
"to": "4522334455",
"from": "CPSMS",
"smsAmount": 1,
"pointPrice": 1,
"userReference": null,
"dlrStatus": 1,
"dlrStatusText": "Received",
"timeSent": 1466041455
},
{
"to": "4533224455",
"from": "CPSMS API",
"smsAmount": 1,
"pointPrice": 1,
"userReference": "someUserIdentifier",
"dlrStatus": 0,
"dlrStatusText": "",
"timeSent": 1467331800
},
{
"to": "4522334488",
"from": "Some sender",
"smsAmount": 1,
"pointPrice": 1,
"userReference": null,
"dlrStatus": 0,
"dlrStatusText": "",
"timeSent": 1470009600
}
]
This endpoint requests your SMS log.
You can look back a maximum of 3 months from current time, and the log will be shown that far back if you do not add start and end date.
It’s possible to request a specific <to>
with or without start/end dates.
HTTP Request
Parameters
Parameter | Type | Description |
---|---|---|
to | string | The recipient of the message you want to lookup. The number starting with country code. |
fromDate | int (unix timestamp) |
Timestamp from where the log result should start. |
toDate | int (unix timestamp) |
Timestamp from where the log result should end. |
Errors
The CPSMS.dk API uses the following error codes:
Error Code | Meaning |
---|---|
207 | Multi-Status – Your request is successful but you have some error(s) you should look at. (Status 207, is just to indicate partial success. it has nothing to do with WebDAV, nor does it comply with other RFC standards related to this type of response.) |
400 | Bad Request – There is something wrong with your request. |
401 | Unauthorized – Something wrong with the user credentials. |
402 | Payment Required – You do not have enough SMS credit/points. |
403 | Forbidden – IP validation gone wrong. |
404 | Not Found – The specified method could not be found. |
406 | Not Acceptable – You did something. |
409 | Conflict – Nothing to return based on posted data. |
500 | Internal Server Error – We had a problem with our server. Try again later. |