Help centre
العربية Back to sayvara.com

Authentication

Call the Sayvara API with an API key or with OAuth 2.0 client credentials, and choose the scopes each one may use.

Updated

Every call to the Sayvara API needs a bearer token in the Authorization header. You can use either:

  • an API key: one long-lived secret, simple to set up; or
  • an API client: OAuth 2.0 client credentials that you exchange for short-lived access tokens, with an optional list of allowed IP addresses.

Both work on every operation in the API reference. Both belong to your organisation, not to a person, and both need the API access feature in your plan.

API keys

Make a key

Only owners and admins can manage API keys.

  1. Open Developer.
  2. Select New API key.
  3. Enter a Name for the system that will use the key, for example "Data warehouse".
  4. Under What the key may do, choose the scopes (see Scopes).
  5. Under Key ends, choose Never or an end date (30, 90 or 180 days, or one year).
  6. Select Make key.
  7. Copy the key now. This is the only time you see it in full. Then select I have copied it.

Make one key per system. Then you can stop one system without touching the others.

Use a key

An API key looks like sv_ followed by 12 lower-case hex characters, an underscore and a 43-character secret. Send it as a bearer token:

curl "https://api.sayvara.com/v1/automation/me" \
  -H "Authorization: Bearer $SAYVARA_API_KEY"

SAYVARA_API_KEY stands for your own key. Keep keys on your servers, in a secrets store or environment variable. Never put a key in a web page or in an app that customers download.

Rotate or revoke a key

  • Rotate gives you a new key. Under The old key keeps working, choose No, it stops now, For one more hour or For 24 more hours, so you have time to put the new key into your system.
  • Revoke stops the key at once. Everything that uses it stops working, and REST hooks made with it are removed. This cannot be undone.

Test keys

Test mode is turned on organisation by organisation. Once it is on for yours, new keys look like svk_live_ or svk_test_, then the region, the 12-character key id and the secret. Keys that start with sv_ keep working.

A test key acts on your own organisation, but nothing it does reaches a customer or costs anything:

  • It can read (every GET operation) and call Send survey triggers. Any other operation answers 403 with the code API_KEY_TEST_MODE. The MCP server does not take test keys.
  • A trigger runs every check of a live call (body, survey, branch, signature) and answers 202 with "status": "test" and "test": true. No contact, invitation or message is stored, and nothing is billed or counted against your plan.
  • Where test sends are also on, the invitation is prepared with your own channel rules and sent to Sayvara's test provider only, never to a real phone number or e-mail address. The answer then also says "delivery": "fake", and a survey.sent event with "test": true goes to the webhook endpoints that opted in to test events (see Webhooks).

OAuth 2.0 client credentials

An API client has a client id and a client secret. Your system exchanges them for an access token that lasts from 5 minutes to 1 hour, then calls the API with that token.

Make an API client

Only owners and admins can manage API clients.

  1. Open Settings > API access.
  2. Under API clients, select New client.
  3. Enter a Client name, choose the Scopes, and choose the Token lifetime (5, 15 or 30 minutes, or 1 hour).
  4. Optional: under Allowed addresses (optional), enter one IPv4 or IPv6 address or CIDR block per line, for example 203.0.113.0/24. Tokens are then issued and accepted only for calls from those addresses. Leave it empty to allow any address. You can enter up to 50 lines; an IPv4 block can be at most /8 wide and an IPv6 block at most /16. Enter IPv4 addresses in their IPv4 form, not as IPv6-mapped addresses.
  5. Select Save.
  6. Copy the Client ID and the Client secret now. The secret is shown only once; Sayvara keeps only a fingerprint of it.

The client id starts with svc_ and the secret with svs_.

Get an access token

Send the client id and secret to the token URL, https://api.sayvara.com/v1/oauth/token, with HTTP Basic:

curl -X POST "https://api.sayvara.com/v1/oauth/token" \
  -u "$SAYVARA_CLIENT_ID:$SAYVARA_CLIENT_SECRET" \
  -d "grant_type=client_credentials"

You can also send client_id and client_secret in the body instead of HTTP Basic, but not both. The body can be form-encoded or JSON. To get a token with fewer scopes than the client has, add scope with the scopes separated by spaces.

The answer:

{
  "access_token": "eyJhbGciOi...",
  "token_type": "Bearer",
  "expires_in": 900,
  "scope": "responses.read events.write"
}

expires_in is in seconds. Full details and errors: Get an access token.

Use the token

Send the access token exactly like an API key:

curl "https://api.sayvara.com/v1/data/responses" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Reuse a token until it nearly expires, then get a new one. Each client can get at most 30 tokens a minute.

Change, rotate or revoke a client

  • Edit changes the name, scopes, allowed addresses or token lifetime. Narrower scopes apply to tokens already issued, at once.
  • New secret issues a new client secret. Under Keep the old secret working for, choose Stop it now, 1 hour or 24 hours. With Stop it now, every token issued before the change stops too.
  • Revoke stops the client and all its live tokens at once, and removes the REST hooks it made. This cannot be undone.

Scopes

Each key or client holds one or more scopes. An operation that needs a scope the key does not hold answers 403 with the code API_KEY_SCOPE.

Scope Shown in the app as Lets you
events.write Send events Send survey triggers.
responses.read Read answers (keys), Read responses (clients) Read responses, test the connection and manage REST hooks.
contacts.write Add and update contacts Add or update a contact.
surveys.read Read surveys Read your surveys: id, name, status and main metric, for example with the list_surveys tool of the MCP connector.
voice.calls Start phone surveys (calls) Start phone survey calls (IVR) to your contacts from your own system or call centre. It adds and updates the contacts it calls.

Give each key only the scopes its system needs.

When a call is refused

Status Code What it means
401 INVALID_API_KEY The key or token is missing, wrong, revoked or expired.
403 API_KEY_SCOPE The key or token lacks the scope of this operation.
403 IP_NOT_ALLOWED An access token was used from an address outside its client's allowed addresses.
403 ENTITLEMENT_REQUIRED Your plan does not include API access, or the trial has ended (then reads still work, but writes are refused until a plan is chosen).
429 RATE_LIMITED Too many calls, or too many failed key checks from your address. See Rate limits.

See Errors for the full list.