Messages
Send one SMS, estimate one, and follow what happened to every message, from the API or the app.
The message object
| Field | Type | Description |
|---|---|---|
id | string | The message's id. |
object | string | Always message. |
livemode | boolean | false for a sandbox message, which reached no phone. |
to | string | The number in E.164. |
from | string | The sender ID it came from. |
text | string | The text as sent, the opt-out line of a promotion included. |
type | string | One of service, promotional. |
status | string | scheduled, then queued, then sent (handed to the network), then delivered, failed or expired (no report in 72 hours). held: waiting for a check by SemaLink. rejected: never sent (opted out since; not charged). cancelled: stopped before it went. |
network | string or null | The network it went to, or its number belongs to. |
parts | integer | The SMS it took; each is charged. |
encoding | string | One of gsm7, ucs2. |
cost | Money | What it costs: charged once it is sent, refunded when it never reached the network. |
reference | string or null | |
batch | string or null | The batch it was sent in (bat_...), or null for a single message. |
send_at | string or null | When it was scheduled for, or null when sent at once. |
created_at | string | |
sent_at | string or null | |
delivered_at | string or null | |
failure | object or null | Why it wasn't delivered; null while it may still be, and once delivered. |
failure. | string | One of absent_subscriber, unknown_subscriber, inactive_subscriber, promotions_blocked, rejected_by_network, not_delivered, provider_error, no_delivery_report, opted_out, contact_removed, cancelled. |
failure. | string | |
failure. | boolean | Its cost was returned: it never reached the network. |
refunded | boolean | Its cost was returned. |
Example
{
"id": "msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c",
"object": "message",
"livemode": true,
"to": "+254712345678",
"from": "GREENHILL",
"text": "Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.",
"type": "service",
"status": "delivered",
"network": "safaricom",
"parts": 1,
"encoding": "gsm7",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"reference": "invoice-1042",
"batch": null,
"send_at": null,
"created_at": "2026-12-01T07:30:00.000Z",
"sent_at": "2026-12-01T07:30:02.000Z",
"delivered_at": "2026-12-01T07:30:06.000Z",
"failure": null,
"refunded": false
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Estimate a message
/v1/messages/estimateScope: messages:sendHow long a message is, whether it can be sent as it is, and what it costs for each number. Sends nothing; a sandbox key gets the same answer as a live one. One SMS (160 standard characters) per message for now: a message that does not fit has fits false, says why in message.problems, and is not priced (every cost null). Each 100 numbers count as one more request against the rate limit. An Idempotency-Key is accepted and not kept: an estimate changes nothing, so a retry simply estimates again.
Headers
| Name | Type | Required | Description |
|---|---|---|---|
Idempotency-Key | string | Optional | Accepted (1 to 255 characters) and ignored: an estimate changes nothing. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
text | string | Required | The message. |
to | string or array of strings | Optional | Who it would go to: one number or up to 1,000, in E.164 (+254712345678) or a local form (0712345678). |
type | string | Optional | promotional adds the opt-out line in Kenya (STOP*456*9*5#), which counts in the length. One of service, promotional. Default service. |
Returns
200 OK The estimate. An estimate object.
Errors
| Status | Code | For example |
|---|---|---|
| 400 | parameter_missing | Missing required parameter: text. |
| 400 | parameter_invalid | Invalid to: give a phone number, or a list of 1 to 1,000 of them. |
| 400 | parameter_unknown | Unknown parameter: message. |
Like any POST, it can also answer invalid_json idempotency_key_invalid invalid_api_key key_revoked key_expired scope_missing ip_not_allowed browser_requests_not_allowed api_blocked account_suspended request_too_large unsupported_media_type rate_limited internal_error request_timeout.
Request
curl https://api.semalink.africa/v1/messages/estimate \
-H "Authorization: Bearer $SEMALINK_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"text": "Dear parent, the school closes for the holiday on Friday 5 December at 12:00. Greenhill Academy",
"to": [
"+254712345678",
"0722000111"
],
"type": "service"
}'2
3
4
5
6
7
8
9
10
11
12
const response = await fetch('https://api.semalink.africa/v1/messages/estimate', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SEMALINK_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(), // keep it if you retry
},
body: JSON.stringify({
text: 'Dear parent, the school closes for the holiday on Friday 5 December at 12:00. Greenhill Academy',
to: ['+254712345678', '0722000111'],
type: 'service',
}),
});
const estimate = await response.json();
console.log(response.status, estimate);2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
import uuid
import requests
response = requests.post(
"https://api.semalink.africa/v1/messages/estimate",
headers={
"Authorization": f"Bearer {os.environ['SEMALINK_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()), # keep it if you retry
},
json={
"text": "Dear parent, the school closes for the holiday on Friday 5 December at 12:00. Greenhill Academy",
"to": ["+254712345678", "0722000111"],
"type": "service",
},
timeout=30,
)
estimate = response.json()
print(response.status_code, estimate)2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$ch = curl_init('https://api.semalink.africa/v1/messages/estimate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SEMALINK_API_KEY'),
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)), // keep it if you retry
],
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Dear parent, the school closes for the holiday on Friday 5 December at 12:00. Greenhill Academy',
'to' => ['+254712345678', '0722000111'],
'type' => 'service',
]),
]);
$estimate = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print_r($estimate);2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Response
{
"object": "estimate",
"livemode": true,
"type": "service",
"country": "KE",
"message": {
"encoding": "gsm7",
"characters": 95,
"characters_left": 65,
"parts": 1,
"max_parts": 1,
"fits": true,
"problems": [],
"unsupported_characters": [],
"footer": null
},
"cost_per_message": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"recipients": [
{
"input": "+254712345678",
"to": "+254712345678",
"valid": true,
"country": "KE",
"network": "safaricom",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"rejection": null
},
{
"input": "0722000111",
"to": "+254722000111",
"valid": true,
"country": "KE",
"network": "safaricom",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"rejection": null
}
],
"totals": {
"recipients": 2,
"valid": 2,
"rejected": 0,
"sms": 2,
"cost": {
"amount": 160,
"currency": "KES",
"display": "KES 1.60"
}
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
"error": {
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "Missing required parameter: text.",
"param": "text",
"doc_url": "https://docs.semalink.africa/errors#parameter_missing",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9
10
{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "This API key isn't one we know. Check it was copied whole, or make a new one in Developer > API keys.",
"doc_url": "https://docs.semalink.africa/errors#invalid_api_key",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9
The estimate object
| Field | Type | Description |
|---|---|---|
object | string | Always estimate. |
livemode | boolean | |
type | string | One of service, promotional. |
country | string or null | The organisation's country: where the message's rules (the opt-out line) and cost_per_message come from. |
message | object | |
message. | string | gsm7, the standard SMS alphabet. Special characters (ucs2) are not available yet. |
message. | integer | Its length as SMS count it (some symbols count 2), the opt-out line included. |
message. | integer | How many more fit in max_parts; 0 when it is too long. |
message. | integer | The SMS it takes. Each part is charged. |
message. | integer | The most parts a message may have: 1 for now. |
message. | boolean | It can be sent as it is: within max_parts and only standard characters. When false, nothing is priced. |
message. | array of objects | Why it can't be sent as it is; empty when it fits. |
message. | string | One of message_too_long, unsupported_characters. |
message. | string | |
message. | array of objects | Characters outside the SMS alphabet, which stop it from being sent. |
message. | string | |
message. | string | |
message. | string | |
message. | string or null | What to write instead ('' removes it); null when there is no safe one. |
message. | string or null | The opt-out line added at the end, if any. |
cost_per_message | Money or null | What one copy costs in the organisation's country; null when it isn't priced, or the message doesn't fit. |
recipients | array of objects | One per number in to, in order; empty without to. |
recipients | string | The number as you sent it. |
recipients | string or null | The number in E.164, or null when it is not a number. |
recipients | boolean | It would be sent to. |
recipients | string or null | |
recipients | string or null | The network its prefix belongs to, when known. |
recipients | Money or null | null when the number would not be sent, or the message doesn't fit. |
recipients | object or null | Why it would not be sent; null when valid. |
recipients | string | One of invalid_number, unsupported_country, duplicate_in_request, no_price. |
recipients | string | |
totals | object | |
totals. | integer | |
totals. | integer | |
totals. | integer | |
totals. | integer | Parts times valid recipients: what is charged. |
totals. | Money or null | The valid recipients' cost; null when the message doesn't fit. |
Example
{
"object": "estimate",
"livemode": true,
"type": "service",
"country": "KE",
"message": {
"encoding": "gsm7",
"characters": 95,
"characters_left": 65,
"parts": 1,
"max_parts": 1,
"fits": true,
"problems": [],
"unsupported_characters": [],
"footer": null
},
"cost_per_message": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"recipients": [
{
"input": "+254712345678",
"to": "+254712345678",
"valid": true,
"country": "KE",
"network": "safaricom",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"rejection": null
},
{
"input": "0722000111",
"to": "+254722000111",
"valid": true,
"country": "KE",
"network": "safaricom",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"rejection": null
}
],
"totals": {
"recipients": 2,
"valid": 2,
"rejected": 0,
"sms": 2,
"cost": {
"amount": 160,
"currency": "KES",
"display": "KES 1.60"
}
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Send a message
/v1/messagesScope: messages:sendSends one message to one number, now or at send_at. A sandbox key plays the message out with no phone reached and nothing charged (the magic numbers in the sandbox guide set its outcome). Live: the same rules as the app (one SMS of standard characters, an approved sender ID, opt-outs, sending hours, review holds, the daily limit), charged when the network takes it and refunded when it refuses it. Retry safely with an Idempotency-Key.
Headers
| Name | Type | Required | Description |
|---|---|---|---|
Idempotency-Key | string | Optional | Any unique string (a UUID): a retry with the same key and body within 24 hours gets the first answer, with Idempotent-Replayed: true. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
to | string | Required | The number: E.164 (+254712345678) or a Kenyan local form (0712345678). |
text | string | Required | The message: one SMS (160 standard characters) for now. |
from | string | Required | The sender ID the message comes from: its name (GREENHILL) or its id (snd_...). Live: an approved one. Sandbox: any of yours, whatever its status, or SANDBOX. |
type | string | Optional | service (the default) for transactional messages; promotional for marketing, which adds the opt-out line in Kenya (STOP*456*9*5#) and may only go 07:00-19:00 East Africa Time. |
reference | string | Optional | Your own reference (an invoice or order number), returned on the message and in its events. Not checked for uniqueness. |
send_at | string (time) | Optional | Send later: 5 minutes to 90 days from now (ISO 8601). Leave it out to send now. |
Returns
202 Accepted Accepted: the message, queued (or scheduled, or held for a check). A message object.
Errors
| Status | Code | For example |
|---|---|---|
| 400 | parameter_missing | Missing required parameter: from. |
| 400 | parameter_invalid | Invalid send_at: choose a time at least 5 minutes from now, or leave it out to send now. |
| 400 | parameter_unknown | Unknown parameter: sender. |
| 402 | insufficient_balance | The balance is KES 40.00 short of this send's KES 800.00. Top up, then send again. |
| 403 | sending_paused | SemaLink has paused sending on this account. Reply to our email or contact support to sort it out. |
| 403 | account_not_active | This account isn't active yet, so it can't send messages |
| 409 | sending_disabled | Sending is switched off for now, so nothing was sent |
| 422 | message_too_long | The text is 172 characters: one SMS holds 160. Shorten it by 12. |
| 422 | unsupported_characters | The text has characters outside the SMS alphabet: ā (U+0101). Replace or remove them. |
| 422 | sender_id_not_approved | GREENHILL isn't approved to send yet. Send from an approved sender ID. |
| 422 | outside_sending_hours | Promotions to Kenya go between 07:00 and 19:00 East Africa Time. The next opening is 2026-12-02T04:00:00.000Z: send then, or pass it as send_at. |
| 422 | promotional_not_available | Promotions to Tanzania aren't available yet. Send it as a service message if it is one. |
| 422 | daily_limit_reached | Your account can send 1,000 messages a day. You've sent 990 today, so this send of 20 is over by 10. Send it tomorrow, or to fewer people. |
| 422 | content_blocked | SemaLink can't send this message as it is: its content is of a kind we don't carry. Contact support if you think this is wrong. |
| 422 | invalid_number | This number is too short. |
| 422 | opted_out | This number opted out of your messages. |
| 422 | unsupported_country | GREENHILL sends to Kenya only. |
Like any POST, it can also answer invalid_json idempotency_key_invalid invalid_api_key key_revoked key_expired scope_missing ip_not_allowed browser_requests_not_allowed api_blocked account_suspended idempotency_key_reused idempotency_key_in_use idempotency_answer_unavailable request_too_large unsupported_media_type rate_limited internal_error request_timeout.
Request
curl https://api.semalink.africa/v1/messages \
-H "Authorization: Bearer $SEMALINK_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"to": "+254712345678",
"text": "Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.",
"from": "GREENHILL",
"type": "service",
"reference": "invoice-1042"
}'2
3
4
5
6
7
8
9
10
11
const response = await fetch('https://api.semalink.africa/v1/messages', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SEMALINK_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(), // keep it if you retry
},
body: JSON.stringify({
to: '+254712345678',
text: 'Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.',
from: 'GREENHILL',
type: 'service',
reference: 'invoice-1042',
}),
});
const message = await response.json();
console.log(response.status, message);2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import uuid
import requests
response = requests.post(
"https://api.semalink.africa/v1/messages",
headers={
"Authorization": f"Bearer {os.environ['SEMALINK_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()), # keep it if you retry
},
json={
"to": "+254712345678",
"text": "Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.",
"from": "GREENHILL",
"type": "service",
"reference": "invoice-1042",
},
timeout=30,
)
message = response.json()
print(response.status_code, message)2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$ch = curl_init('https://api.semalink.africa/v1/messages');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SEMALINK_API_KEY'),
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)), // keep it if you retry
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '+254712345678',
'text' => 'Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.',
'from' => 'GREENHILL',
'type' => 'service',
'reference' => 'invoice-1042',
]),
]);
$message = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print_r($message);2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Response
{
"id": "msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c",
"object": "message",
"livemode": true,
"to": "+254712345678",
"from": "GREENHILL",
"text": "Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.",
"type": "service",
"status": "queued",
"network": "safaricom",
"parts": 1,
"encoding": "gsm7",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"reference": "invoice-1042",
"batch": null,
"send_at": null,
"created_at": "2026-12-01T07:30:00.000Z",
"sent_at": null,
"delivered_at": null,
"failure": null,
"refunded": false
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
"error": {
"type": "invalid_request_error",
"code": "message_too_long",
"message": "The text is 172 characters: one SMS holds 160. Shorten it by 12.",
"param": "text",
"characters": 172,
"max_characters": 160,
"doc_url": "https://docs.semalink.africa/errors#message_too_long",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9
10
11
12
{
"error": {
"type": "insufficient_balance",
"code": "insufficient_balance",
"message": "The balance is KES 40.00 short of this send's KES 800.00. Top up, then send again.",
"shortfall": {
"amount": 4000,
"currency": "KES",
"display": "KES 40.00"
},
"doc_url": "https://docs.semalink.africa/errors#insufficient_balance",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
List messages
/v1/messagesScope: messages:readThe organisation's messages, the newest first (sent from the app or the API; a sandbox key's are the sandbox's), filtered by status, number, batch, reference, sender ID and when they were made. Page with starting_after.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | Optional | 1 to 100; 20 when left out. Default 20. |
starting_after | string | Optional | A page's next_cursor: the messages after it. |
status | string | Optional | One of scheduled, queued, held, sent, delivered, failed, expired, rejected, cancelled. |
to | string | Optional | Messages to this number. |
batch | string | Optional | Messages of this batch (bat_...). |
reference | string | Optional | |
sender_id | string | Optional | Messages from this sender ID (its name). |
created[gte] | string (time) | Optional | Made at or after this time. |
created[lte] | string (time) | Optional | Made at or before this time. |
Returns
200 OK A page of messages. A list of message objects.
Errors
| Status | Code | For example |
|---|---|---|
| 400 | parameter_missing | Missing required parameter: from. |
| 400 | parameter_invalid | Invalid send_at: choose a time at least 5 minutes from now, or leave it out to send now. |
| 400 | parameter_unknown | Unknown parameter: sender. |
| 400 | invalid_json | The body isn't valid JSON. |
Like any request, it can also answer invalid_api_key key_revoked key_expired scope_missing ip_not_allowed browser_requests_not_allowed api_blocked account_suspended rate_limited internal_error request_timeout.
Request
curl "https://api.semalink.africa/v1/messages?limit=20&to=%2B254712345678" \
-H "Authorization: Bearer $SEMALINK_API_KEY"2
const response = await fetch('https://api.semalink.africa/v1/messages?limit=20&to=%2B254712345678', {
headers: {
Authorization: `Bearer ${process.env.SEMALINK_API_KEY}`,
},
});
const page = await response.json();
console.log(response.status, page);2
3
4
5
6
7
8
import os
import requests
response = requests.get(
"https://api.semalink.africa/v1/messages",
headers={
"Authorization": f"Bearer {os.environ['SEMALINK_API_KEY']}",
},
params={
"limit": 20,
"to": "+254712345678",
},
timeout=30,
)
page = response.json()
print(response.status_code, page)2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$ch = curl_init('https://api.semalink.africa/v1/messages?' . http_build_query(['limit' => 20, 'to' => '+254712345678']));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SEMALINK_API_KEY'),
],
]);
$page = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print_r($page);2
3
4
5
6
7
8
9
10
11
12
13
14
Response
{
"object": "list",
"data": [
{
"id": "msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c",
"object": "message",
"livemode": true,
"to": "+254712345678",
"from": "GREENHILL",
"text": "Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.",
"type": "service",
"status": "delivered",
"network": "safaricom",
"parts": 1,
"encoding": "gsm7",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"reference": "invoice-1042",
"batch": null,
"send_at": null,
"created_at": "2026-12-01T07:30:00.000Z",
"sent_at": "2026-12-01T07:30:02.000Z",
"delivered_at": "2026-12-01T07:30:06.000Z",
"failure": null,
"refunded": false
}
],
"has_more": true,
"next_cursor": "msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c"
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"error": {
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "Missing required parameter: from.",
"param": "from",
"doc_url": "https://docs.semalink.africa/errors#parameter_missing",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9
10
{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "This API key isn't one we know. Check it was copied whole, or make a new one in Developer > API keys.",
"doc_url": "https://docs.semalink.africa/errors#invalid_api_key",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9
Get a message
/v1/messages/{id}Scope: messages:readOne message, with each status it has had.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | The msg_... id. |
Returns
200 OK The message. A message object with status_history.
| Field | Type | Description |
|---|---|---|
status_history | array of objects | Each status it has had, the oldest first. |
status_history | string | One of scheduled, queued, held, sent, delivered, failed, expired, rejected, cancelled. |
status_history | string |
Errors
| Status | Code | For example |
|---|---|---|
| 404 | resource_not_found | There's no message msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c for this key. |
Like any request, it can also answer invalid_api_key key_revoked key_expired scope_missing ip_not_allowed browser_requests_not_allowed api_blocked account_suspended rate_limited internal_error request_timeout.
Request
curl https://api.semalink.africa/v1/messages/msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c \
-H "Authorization: Bearer $SEMALINK_API_KEY"2
const response = await fetch('https://api.semalink.africa/v1/messages/msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c', {
headers: {
Authorization: `Bearer ${process.env.SEMALINK_API_KEY}`,
},
});
const message = await response.json();
console.log(response.status, message);2
3
4
5
6
7
8
import os
import requests
response = requests.get(
"https://api.semalink.africa/v1/messages/msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c",
headers={
"Authorization": f"Bearer {os.environ['SEMALINK_API_KEY']}",
},
timeout=30,
)
message = response.json()
print(response.status_code, message)2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$ch = curl_init('https://api.semalink.africa/v1/messages/msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SEMALINK_API_KEY'),
],
]);
$message = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print_r($message);2
3
4
5
6
7
8
9
10
11
12
13
14
Response
{
"id": "msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c",
"object": "message",
"livemode": true,
"to": "+254712345678",
"from": "GREENHILL",
"text": "Your order 1042 is ready for collection at Greenhill Shop, Moi Avenue. Call 0712 345 678.",
"type": "service",
"status": "delivered",
"network": "safaricom",
"parts": 1,
"encoding": "gsm7",
"cost": {
"amount": 80,
"currency": "KES",
"display": "KES 0.80"
},
"reference": "invoice-1042",
"batch": null,
"send_at": null,
"created_at": "2026-12-01T07:30:00.000Z",
"sent_at": "2026-12-01T07:30:02.000Z",
"delivered_at": "2026-12-01T07:30:06.000Z",
"failure": null,
"refunded": false,
"status_history": [
{
"status": "queued",
"at": "2026-12-01T07:30:00.000Z"
},
{
"status": "sent",
"at": "2026-12-01T07:30:02.000Z"
},
{
"status": "delivered",
"at": "2026-12-01T07:30:06.000Z"
}
]
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
"error": {
"type": "invalid_request_error",
"code": "resource_not_found",
"message": "There's no message msg_3b9f6c2a1d4e4f5a8b7c6d5e4f3a2b1c for this key.",
"param": "id",
"doc_url": "https://docs.semalink.africa/errors#resource_not_found",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9
10
{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "This API key isn't one we know. Check it was copied whole, or make a new one in Developer > API keys.",
"doc_url": "https://docs.semalink.africa/errors#invalid_api_key",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}2
3
4
5
6
7
8
9