Skip to navigation

Requesting tokens

Exchange your application’s credentials for a short-lived access token, rotate those credentials safely, and revoke a token you no longer need.

Every call to the Partner API carries an access token. Your server gets one from the token endpoint with the OAuth 2.0 client_credentials grant, authenticating as the application with either a client secret or a private key (private_key_jwt).

POST https://api.evvahub.com/partner/v1/oauth/token

There is no refresh token. When a token is about to expire, request a new one with the same credentials. The official SDKs do this for you.

The request

Send the parameters in the request body, as application/x-www-form-urlencoded (the OAuth standard) or as application/json with the same names.

ParameterRequiredValue
grant_typeYesclient_credentials
scopeNoSpace-separated scopes, each one the application is allowed. Omit it to get every scope the application is allowed right now. See Narrowing a token.
client_idWith client_secret_postYour client ID (evpc_live_… or evpc_test_…). Optional with the other two methods; if you send it, it must name the same client.
client_secretWith client_secret_postYour client secret.
client_assertion_typeWith private_key_jwturn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertionWith private_key_jwtThe signed JWT described in Authenticating with a private key.

The endpoint is strict about the shape of the request, and refuses it with invalid_request when:

  • a recognised parameter appears more than once;
  • a recognised parameter is sent in the URL query string — credentials never travel in a URL;
  • the request uses more than one authentication method (for example an Authorization: Basic header and a client_secret in the body);
  • the content type is neither of the two above.

Parameters the endpoint does not recognise are ignored, and a parameter sent with an empty value counts as not sent. Keep the body under 16 KiB.

Authenticating with a client secret

You get the client secret once, when the application is created or its secret is rotated in the Partner Hub. EVVA keeps only a digest of it and can never show it again.

There are two ways to present it:

MethodHow
client_secret_basicAuthorization: Basic base64(client_id ":" client_secret), each half form-URL-encoded before the base64 step, as RFC 6749 (section 2.3.1) requires. EVVA client IDs and secrets contain only URL-safe characters, so the encoding changes nothing in practice. The SDKs’ default.
client_secret_postclient_id and client_secret as body parameters.
# client_secret_basic: curl -u builds the Basic header
curl -sS https://api.evvahub.com/partner/v1/oauth/token \
-u "$EVVA_CLIENT_ID:$EVVA_CLIENT_SECRET" \
-d grant_type=client_credentials
# client_secret_post: the same credentials in the body
curl -sS https://api.evvahub.com/partner/v1/oauth/token \
-d grant_type=client_credentials \
-d client_id="$EVVA_CLIENT_ID" \
-d client_secret="$EVVA_CLIENT_SECRET"

Authenticating with a private key

With private_key_jwt no shared secret ever leaves your infrastructure. You register the public half of a key pair on the application, keep the private key on your server, and sign a short-lived JWT (the client assertion) for every token request.

1. Create a key pair and register the public key

EVVA accepts two algorithms:

AlgorithmKey
RS256RSA, at least 2048 bits
ES256EC on the P-256 curve
# ES256 key pair: keep evva-app.pem secret, register the public key
openssl ecparam -name prime256v1 -genkey -noout | openssl pkcs8 -topk8 -nocrypt -out evva-app.pem
openssl pkey -in evva-app.pem -pubout -out evva-app.pub.pem

In the Partner Hub, open Integrations → Applications → your application → Credentials, and under Public keys (private_key_jwt) use Add a public key: choose the algorithm, give a key ID (kid), paste the public key as a JWK, and optionally set Valid until.

  • The key ID is 1–128 characters of A–Z a–z 0–9 . _ -. Leave it empty to use the JWK’s own kid.
  • A key ID is unique within the application, including keys you have revoked, so a revoked key’s ID cannot be reused.
  • Upload only the public key. A JWK that carries private key material is refused outright.
  • An application holds at most 5 active keys at a time, which leaves room for a rollover.

2. Build the assertion

The assertion is a compact JWS (three dot-separated parts) signed with your private key.

Header

MemberRule
algRS256 or ES256, and the same algorithm the key was registered with. Anything else — none, any HS*, PS*, EdDSA — is refused.
kidThe registered key ID. Recommended. Without it, the application must have exactly one usable key for that algorithm, otherwise the assertion is refused.
typOptional. If present: JWT, client-authentication+jwt or application/jwt.
jwk, jku, x5u, x5c, crit, b64, zip, encNot allowed. Only keys registered on the application can verify an assertion.

Claims

ClaimRequiredRule
issYesYour client ID.
subYesYour client ID.
audYesThe token endpoint URL, exactly: https://api.evvahub.com/partner/v1/oauth/token. A string, or an array that contains it. The match is exact — no trailing slash, no other spelling. GET /partner/v1/app/capabilities returns the value as authentication.tokenEndpoint.
expYesExpiry, in seconds since the epoch. At most 5 minutes ahead.
iatNoIssued-at. Not in the future; when present, exp − iat must not exceed 5 minutes.
nbfNoNot-before. Not in the future.
jtiYesA unique ID, 1–256 visible ASCII characters. Each jti is accepted once per client; a repeat is refused.

EVVA tolerates 60 seconds of clock difference on exp, iat and nbf. Keep your servers’ clocks synchronised.

Assertion header and claims, before signing
{ "alg": "ES256", "typ": "JWT", "kid": "key-2026-12" }
{
"iss": "evpc_live_YOUR_CLIENT_ID",
"sub": "evpc_live_YOUR_CLIENT_ID",
"aud": "https://api.evvahub.com/partner/v1/oauth/token",
"iat": 1795000000,
"exp": 1795000060,
"jti": "5f0c8a52-6b0e-4d55-9a8e-3f1d2c7b9e41"
}

3. Request the token

# $ASSERTION holds the signed JWT from step 2
curl -sS https://api.evvahub.com/partner/v1/oauth/token \
-d grant_type=client_credentials \
-d client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
-d client_assertion="$ASSERTION"

The response

A successful request returns 200 with the token. Every response from the token endpoint — success or error — carries Cache-Control: no-store and Pragma: no-cache.

200 OK
{
"access_token": "evpa_live_…",
"token_type": "Bearer",
"expires_in": 900,
"scope": "read:messages write:messages write:messages:automated"
}
FieldMeaning
access_tokenAn opaque token: evpa_live_ (live application) or evpa_test_ (sandbox application) followed by 43 characters. Do not parse it, and never log it.
token_typeAlways Bearer.
expires_inLifetime in seconds — 900 (15 minutes). Read the value rather than hard-coding it.
scopeThe scopes this token carries, space-separated.

Send the token on every API call:

Authorization: Bearer evpa_live_…

Narrowing a token

A token can only ever carry scopes the application is allowed. Use scope to ask for less than that — for example a worker that only reads conversations:

curl -sS https://api.evvahub.com/partner/v1/oauth/token \
-u "$EVVA_CLIENT_ID:$EVVA_CLIENT_SECRET" \
-d grant_type=client_credentials \
-d scope="read:messages read:subscribers"
  • Scopes are separated by spaces. Duplicates are merged.
  • If any requested scope is not one the application is allowed, the whole request is refused with invalid_scope. Nothing is silently dropped.
  • A token carries at most 64 scopes.
  • Without scope, the token carries every scope the application is allowed at that moment.

The SDKs take the same list as an option: scopes (TypeScript, Python, PHP) or Scopes (Go).

Holding a scope on the token is only one condition; what the application may actually do for each creator also depends on its grants and the creator’s consent. See Scopes and grants.

Errors

Errors follow RFC 6749 (section 5.2): a JSON body with error and error_description.

401 Unauthorized
{
"error": "invalid_client",
"error_description": "Client authentication failed."
}
errorStatusWhen
invalid_request400The request is malformed: wrong content type, unreadable body, a duplicated parameter, a parameter in the URL, more than one authentication method, client_secret without client_id, or only half of the assertion pair. error_description says which.
invalid_client401Client authentication failed, for any reason: unknown client, wrong or retired secret, unknown or revoked key, bad signature, wrong aud, expired assertion, reused jti. The body is the same in every case, on purpose. When you used HTTP Basic, the response also carries WWW-Authenticate: Basic realm="evva-partner", charset="UTF-8".
unauthorized_client400The credentials are valid, but the application may not get a token now: it is waiting for EVVA’s review, it is disabled, or your agency is suspended.
unsupported_grant_type400The client_credentials grant is not available.
invalid_scope400scope is malformed, names more than 64 scopes, or names a scope the application is not allowed.
temporarily_unavailable503EVVA could not verify the request right now. Nothing was issued. Retry after the Retry-After header (5 seconds).

invalid_client deliberately does not say what was wrong. Check, in order: the client ID was copied whole, the secret is the current one, the key ID matches a registered active key, aud is the exact token endpoint URL, exp is no more than 5 minutes ahead, jti is new, and your server clock is synchronised.

Token lifetime

An access token lives 15 minutes (expires_in: 900). There is no refresh token: request a new token before the current one expires. The SDKs renew a token 60 seconds before it expires and share one request between concurrent callers.

A token stops working before its expiry when it is revoked, when the application is disabled or revoked, or when your agency is suspended. A request with a token that is expired, revoked or unknown gets:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="evva-partner", error="invalid_token"
{ "code": "INVALID_TOKEN", "error": "The access token is not valid", "requestId": "…" }

Request a new token and retry. If the new token request is refused, its error tells you why.

Revoking a token

Revoke a token you no longer need — for example when a worker shuts down — at the revocation endpoint (RFC 7009):

POST https://api.evvahub.com/partner/v1/oauth/revoke
ParameterRequiredValue
tokenYesThe access token to revoke.
token_type_hintNoA hint only; it does not change the result.
Client authenticationYesExactly as at the token endpoint: client_secret_basic, client_secret_post or private_key_jwt.

The answer is 200 with an empty body whenever the request itself is valid — whether the token was revoked now, was already revoked or expired, is unknown, or belongs to another application (which is left untouched). An application can only revoke its own tokens, and can do so even while it is disabled. Errors are 400 invalid_request, 401 invalid_client and 503 temporarily_unavailable, as above.

Revocation takes effect from the next request. Realtime connections opened with the token are closed (SESSION_REVOKED, then close code 4401).

curl -sS https://api.evvahub.com/partner/v1/oauth/revoke \
-u "$EVVA_CLIENT_ID:$EVVA_CLIENT_SECRET" \
-d token="$TOKEN"

Rotating credentials

Credentials are managed in the Partner Hub under Integrations → Applications → your application → Credentials. Only the agency owner can change them; team leads can see them.

Client secret

Rotate secret creates a new secret, shows it once, and retires the current one after an overlap you choose under Keep the current secret working for: End it now, 1 hour, 24 hours (default), 3 days or 7 days (maximum).

1

Rotate

Rotate the secret in the Partner Hub and store the new value in your secret manager.

2

Roll it out

Deploy the new secret to every server within the overlap. During the overlap both secrets authenticate.

3

Let the old one lapse

When the overlap ends, only the new secret works.

At most two secrets work at once: rotating again during an overlap ends the older overlap immediately. After a secret is created, the Hub shows only its last four characters.

Public keys

Because an application can hold up to five active keys, you rotate a key with no downtime: add the new public key with a new key ID, switch your signer to the new private key and kid, then revoke the old key in the Hub. Assertions signed with a revoked key are refused from that moment. A key with Valid until set stops authenticating at that time.

Rotating a secret or revoking a key does not end access tokens already issued with it: they keep working until they expire, at most 15 minutes later. If a credential leaked, also revoke the tokens issued with it, or disable the application in the Hub, which revokes all of its tokens at once.

Yes. With private_key_jwt the client_id parameter is optional; if you send it, it must equal the assertion’s sub, otherwise authentication fails. With HTTP Basic, a client_id in the body must equal the one in the header.

Each jti is accepted once per client for as long as the assertion could be valid. Sign a new assertion, with a new random jti, for every token request — including retries.

No. A sandbox application’s client ID starts with evpc_test_ and its tokens with evpa_test_; it acts only in the sandbox. A live application uses evpc_live_ and evpa_live_.

No. Access tokens are never shown in the Hub. To end one, revoke it with the revocation endpoint, or disable the application.

Next steps