Getting started
Authentication and scopes
API keys, scopes, test mode, rate limits and errors.
Every request carries a credential as a bearer token:
curl https://api.spiiksi.fi/v1/account -H "Authorization: Bearer $SPIIKSI_KEY"An API key may also be sent as X-Api-Key: ….
API keys#
An organization admin creates keys under API & integrations → API keys. A key belongs to the organization, and everything done with it is billed to the organization.
- Live keys start with
spk_live_, test keys withspk_test_. - The key is shown once, when it is made. Spiiksi keeps only a hash of it.
- Keep keys on your server. A browser or a mobile app should call your server, which calls Spiiksi; or use OAuth for apps that many organizations install.
- Revoking a key stops it at once.
Scopes#
A key can be limited to what it needs. A request outside the key's scopes is refused with 403.
| Scope | Allows |
|---|---|
calls:read | Listing and reading calls |
calls:write | Starting, ending and dialling calls; new links; phone lines |
sessions:read | Reading support chats, their messages and live streams |
sessions:write | Starting support chats, posting messages and voice messages |
translate | Text translation |
events:read | The organization's live event stream |
account:read | The organization, its balance and prices |
A Zendesk app that starts calls and translates replies needs calls:write and translate; a reporting job needs only calls:read. GET /v1/account (with account:read) lists a key's scopes.
Test mode#
Test keys work like live ones, for free:
- text is "translated" by a stand-in that tags it with the target language,
[es] Hello; - calls connect, but each side hears the other's own voice, untranslated;
- voice messages in chats get a placeholder transcript;
- nothing is billed, even with an empty balance;
- a test key sees only what test keys made, and a live key only live objects.
Objects and events say which mode they belong to with "livemode": false. Phones can't be dialled in test mode.
Rate limits#
Each key, and each connected app, may make 600 requests a minute. Past that, requests are refused with 429 and a Retry-After header in seconds.
Errors#
Errors are JSON with a detail field, a message or, for an invalid request body, a list of what is wrong:
{"detail": "This key or app lacks the translate scope"}| Status | Means |
|---|---|
| 400 | The request can't be carried out as it is (for example, dialling in test mode) |
| 401 | The key or token is missing, unknown, revoked or expired |
| 402 | The organization's prepaid balance has run out |
| 403 | The key or app lacks the scope for this |
| 404 | No such object, or it belongs to another organization or the other mode |
| 409 | The object's state doesn't allow it (for example, a call that has ended) |
| 422 | The request body or parameters are invalid |
| 429 | Too many requests; wait Retry-After seconds |
| 502 | An upstream service (interpretation, telephony) failed; try again |