Authentication
Service accounts, access tokens and permissions.
Every API request is made by a service account: a sign-in for a system, not a person. You give it only the permissions it needs, and it proves who it is with an access token.
Create a service account
- Open Settings → Service accounts and select New service account. Only the organization's owner and admins can.
- Name it after the system that will use it, such as Shop.
- Turn on Test mode if it's for building and testing. Its messages reach no one and use no SMS. See Test mode.
- Choose its permissions. Start from a bundle (Read only, Customer sync, Messaging or Full access) and adjust.
A service account's permissions and test mode can't be changed later. To change them, create a new one and switch over.
You can have up to 50 service accounts, and disable, enable or delete any of them.
Permissions
| Permission | Lets it |
|---|---|
customers.read | List, search, open and export customers |
customers.write | Add, import and edit customers, and set their segments |
customers.delete | Delete customers |
activity.read, activity.write | Read and record what customers did |
segments.read, segments.write | List and manage segments and their members |
messages.read, messages.send | List and send messages |
broadcasts.read, broadcasts.send | List and send broadcasts |
analytics.read | Read analytics |
billing.read | Read your wallet, SMS balance and transactions |
webhooks.manage | Add and manage webhook endpoints, and see and resend deliveries |
Access tokens
Open the service account and select Create access token. Name it, and choose when it expires: in 30 days, 90 days, a year, or never. A service account can have up to 10.
The token starts with gzk_. Goomzo shows it only once, so copy it somewhere safe straight away.
Send it with every request as a Bearer token:
Authorization: Bearer gzk_...Or use Basic auth, with the service account's ID as the username and the token as the password:
curl -u "sva_...:gzk_..." https://api.goomzo.africa/v1/customersKeep tokens out of your code and out of anything a customer's browser can see. If one leaks, select Revoke on it in the service account; it stops working right away.
Key pairs
If you'd rather not keep a long-lived token, use a key pair instead. Your system signs a short JWT with its private key and exchanges it for a token that lasts an hour.
-
In the service account, under Advanced: key pairs, select Create key to download a key file, or Upload public key to use your own Ed25519 key. Goomzo keeps only the public half.
-
Sign a JWT with the private key:
Header: { "alg": "EdDSA", "kid": "<key_id>" } Claims: { "iss": "sva_...", "aud": "https://api.goomzo.africa/v1/oauth/token", "jti": "<unique id>", "iat": <now>, "exp": <now + up to 300> }Each
jtican be used only once. Add ascopeclaim, with permissions separated by spaces, to get a token with fewer permissions than the account.Use the
token_urifrom your key file asaud. Older key files namehttps://app.goomzo.africa/v1/oauth/token, which still works. -
Exchange it for a token:
curl https://api.goomzo.africa/v1/oauth/token \ -d grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \ -d assertion=$SIGNED_JWT{ "access_token": "gzt_...", "token_type": "Bearer", "expires_in": 3600, "scope": "customers.read" } -
Send
access_tokenas a Bearer token until it expires, then sign a new JWT.
A service account can have up to 10 active keys.