Authentication
The OAuth 2.0 client-credentials token endpoint of the TOVR REST API, its parameters, responses and rate limits, the bearer token it issues, the 401 error codes, and the scope catalog.
The TOVR REST API accepts one kind of credential: a bearer token from the OAuth 2.0 client-credentials grant. Each token belongs to one client application, and each client application belongs to one organization. The organization comes from the token. No request carries an organization id.
fOS API keys (tovr_…) do not work on /api/v1. They are for the fOS MCP server.
Client applications
An organization owner or admin creates client applications in
Settings → Developer. Creating one shows the
client_id and the client_secret. The secret is shown once.
| Property | Value |
|---|---|
| Belongs to | Exactly one organization |
| Scopes | Chosen when the application is created. They cannot be edited afterwards. To change them, create a new application. |
| Checked on every request | An application that is deactivated or past its expiry date is refused, even with an unexpired token. |
| Limits | Rate limits and the monthly quota count per client application, using the organization's plan. See Rate limiting and quota. |
Token endpoint
POST /api/v1/oauth2/token
No bearer token is needed. Send the parameters form-encoded
(application/x-www-form-urlencoded) or as JSON (application/json).
| Parameter | Required | Value |
|---|---|---|
grant_type | yes | client_credentials. No other grant is supported. |
client_id | yes | The client application's id. |
client_secret | yes | The client application's secret. |
Send each form parameter once. A parameter that appears twice is treated as missing. HTTP Basic
client authentication (client_secret_basic) is not supported.
curl -X POST https://tovr.eu/api/v1/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=$TOVR_CLIENT_ID" \
-d "client_secret=$TOVR_CLIENT_SECRET"{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.…",
"token_type": "Bearer",
"expires_in": 3600
}Responses
The token endpoint answers OAuth-style errors: error is a string, not the
error envelope the other endpoints use.
| Status | Body | When |
|---|---|---|
200 | access_token, token_type, expires_in | The credentials are valid. |
400 | {"error":"Content-Type must be application/x-www-form-urlencoded or application/json"} | Another media type. |
400 | {"error":"Unsupported grant_type. Use 'client_credentials'"} | grant_type is missing or not client_credentials. |
400 | {"error":"client_id and client_secret are required"} | One of the two is missing. |
401 | {"error":"Invalid client credentials"} | Unknown client_id, wrong secret, or a client application that is deactivated or expired. |
429 | {"error":"rate_limited","error_description":"…"} and Retry-After | See Rate limits. |
500 | {"error":"Failed to generate access token"} | A fault on TOVR's side, or an application/json body that does not parse as JSON or is null. |
Every response carries X-Request-Id.
Rate limits
The token endpoint has its own limits. They are checked before the secret is verified, and every attempt counts, including failed ones.
| Limit | Counted per | Checked |
|---|---|---|
| 30 requests per minute | Source IP address | First, before the body is read |
| 10 requests per minute | client_id | After the body is read |
Past either limit the endpoint answers 429 with Retry-After in seconds. A client that reuses
its token for its full hour sends one token request per hour.
The access token
| Property | Value |
|---|---|
| Format | JWT signed with HS256. Treat it as opaque. |
| Lifetime | 3,600 s (1 hour), from expires_in |
| Refresh | None. Request a new token before the old one expires. |
| Scopes | The client application's scopes at the moment the token was issued. The response does not list them. |
| Revocation | A revoked token, or a token of a deactivated or expired client application, is refused at once. Regenerating the client secret in Settings → Developer does not revoke tokens already issued: they work until they expire. Deleting the client application ends them at once. |
Send the token on every request:
curl https://tovr.eu/api/v1/shipments?limit=10 \
-H "Authorization: Bearer $TOVR_TOKEN"The scheme is case-sensitive: the header must start with Bearer (capital B, one space).
Authentication errors
A request without a usable token is refused with 401, the
error envelope with type: "authentication_error", and the header
WWW-Authenticate: Bearer error="invalid_token". These responses carry no rate-limit headers and
do not count against the limits.
code | Cause | What to do |
|---|---|---|
missing_credentials | No Authorization header, a scheme other than Bearer , or an empty token | Send the token. |
expired_token | The token is genuine and its hour has passed | Get a new token and retry. |
invalid_token | Bad signature, unknown or revoked token, or a client application that is missing, deactivated or expired | Get a new token. If the client application was deactivated or expired, a new token is also refused. |
{
"error": {
"type": "authentication_error",
"code": "expired_token",
"message": "The access token has expired.",
"request_id": "req_3f9c0b6a1d2e4f5a8b7c6d5e4f3a2b1c",
"doc_url": "https://tovr.eu/docs/tovr/reference/errors#expired_token"
}
}A token without the scope an endpoint needs is a 403
insufficient_scope, not a 401.
Scopes
A scope grants one family of endpoints. Holding shipments:write does not grant
shipments:read. Grant each scope the integration uses.
| Scope | Grants |
|---|---|
shipments:read | GET /shipments, GET /shipments/{id}; shipment.* events and webhooks |
shipments:write | POST /shipments, PATCH /shipments/{id} |
invoices:read | GET /invoices, GET /invoices/{id}; invoice.recorded events and webhooks |
chains:read | GET /chains, GET /chains/{id}; chain.* events and webhooks |
vehicles:read | GET /vehicles, GET /vehicles/{id}, GET /vehicles/{id}/availabilities; vehicle.* events and webhooks |
matches:read | GET /matches, GET /matches/{id}; match.* events and webhooks |
quotes:read | GET /quotes, GET /quotes/{id}; quote.* events and webhooks |
outreach:read | GET /outreach, GET /outreach/{id}; outreach.* events and webhooks |
events:read | GET /events |
events:stream | GET /events/stream |
webhooks:read | GET /webhook_endpoints, GET /webhook_endpoints/{id} |
webhooks:write | POST /webhook_endpoints, PATCH and DELETE /webhook_endpoints/{id}, POST /webhook_endpoints/{id}/rotate_secret |
estimate | POST /estimate, POST /estimate/batch |
market | GET /market/overview |
events:read, events:stream and the webhook scopes open a delivery channel. They do not widen
what is delivered: each event also needs the read scope of the object it is about. See
Change feed and Webhooks.
Related
REST API overview
Every endpoint of the TOVR REST API under /api/v1 with its scope, the order in which a request is checked, the list envelope and pagination, ids, and the parameters of the read-only resources, pricing and market endpoints.
Errors
The TOVR REST API error catalog. The error envelope, the six error types, every error code with its HTTP status and type, what to do about each, and retry rules. Every error's doc_url links to an entry on this page.