Account
Who the key belongs to, its mode and scopes, and whether live sending is ready.
The account object
| Field | Type | Description |
|---|---|---|
object | string | Always account. |
livemode | boolean | true for a live key, false for a sandbox (test) key. |
organisation | object | |
organisation. | string | The organisation's id. |
organisation. | string | |
organisation. | string | |
organisation. | string | pending until SemaLink has verified the organisation. One of active, pending, suspended. |
key | object | |
key. | string | The key's id. |
key. | string or null | |
key. | string | One of live, test. |
key. | array of strings | |
key. | string or null | The first 16 characters of the key. |
key. | array of strings | Addresses the key works from; empty: any. |
key. | string or null | When the key stops working; null: never. |
readiness | object | What live sending needs. All four true: the organisation's live keys can send. |
readiness. | boolean | SemaLink has verified the organisation. |
readiness. | boolean | At least one of its sender IDs is approved. |
readiness. | boolean | There is money to send with (for a sandbox key, the sandbox's virtual balance). |
readiness. | boolean | Sending is on at SemaLink and isn't paused for the organisation. |
Example
json
{
"object": "account",
"livemode": true,
"organisation": {
"id": "org_8c1f2a3b4d5e4f60a1b2c3d4e5f60718",
"name": "Greenhill Academy",
"country": "KE",
"status": "active"
},
"key": {
"id": "key_2b7e151628ae4d2a9f1c3b5d7e9f0a1c",
"label": "Billing server",
"mode": "live",
"scopes": [
"balance:read",
"sender_ids:read",
"pricing:read",
"messages:send",
"messages:read",
"webhooks:manage"
],
"prefix": "sk_live_3f9a2c1b",
"allowed_ips": [],
"expires_at": null
},
"readiness": {
"account_active": true,
"sender_id_approved": true,
"balance_ok": true,
"sending_enabled": true
}
}1
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
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
Get the account
GET
/v1/accountScope: Any keyThe organisation and the key making the request, and whether live sending is ready.
Any key can call it, whatever its scopes.
Returns
200 OK The account. An account object.
Errors
Like any request, it can answer invalid_api_key key_revoked key_expired ip_not_allowed browser_requests_not_allowed api_blocked account_suspended rate_limited internal_error request_timeout.
Request
bash
curl https://api.semalink.africa/v1/account \
-H "Authorization: Bearer $SEMALINK_API_KEY"1
2
2
js
const response = await fetch('https://api.semalink.africa/v1/account', {
headers: {
Authorization: `Bearer ${process.env.SEMALINK_API_KEY}`,
},
});
const account = await response.json();
console.log(response.status, account);1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
python
import os
import requests
response = requests.get(
"https://api.semalink.africa/v1/account",
headers={
"Authorization": f"Bearer {os.environ['SEMALINK_API_KEY']}",
},
timeout=30,
)
account = response.json()
print(response.status_code, account)1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
php
<?php
$ch = curl_init('https://api.semalink.africa/v1/account');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SEMALINK_API_KEY'),
],
]);
$account = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print_r($account);1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Response
json
{
"object": "account",
"livemode": true,
"organisation": {
"id": "org_8c1f2a3b4d5e4f60a1b2c3d4e5f60718",
"name": "Greenhill Academy",
"country": "KE",
"status": "active"
},
"key": {
"id": "key_2b7e151628ae4d2a9f1c3b5d7e9f0a1c",
"label": "Billing server",
"mode": "live",
"scopes": [
"balance:read",
"sender_ids:read",
"pricing:read",
"messages:send",
"messages:read",
"webhooks:manage"
],
"prefix": "sk_live_3f9a2c1b",
"allowed_ips": [],
"expires_at": null
},
"readiness": {
"account_active": true,
"sender_id_approved": true,
"balance_ok": true,
"sending_enabled": true
}
}1
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
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
json
{
"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"
}
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
json
{
"error": {
"type": "permission_error",
"code": "ip_not_allowed",
"message": "This API key can't be used from 196.201.214.10: it isn't on the key's list of allowed addresses.",
"doc_url": "https://docs.semalink.africa/errors#ip_not_allowed",
"request_id": "req_5f1d0c2e8a9b4c3d9e7f6a5b4c3d2e1f"
}
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9