TOVRReference

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.

PropertyValue
Belongs toExactly one organization
ScopesChosen when the application is created. They cannot be edited afterwards. To change them, create a new application.
Checked on every requestAn application that is deactivated or past its expiry date is refused, even with an unexpired token.
LimitsRate 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).

ParameterRequiredValue
grant_typeyesclient_credentials. No other grant is supported.
client_idyesThe client application's id.
client_secretyesThe 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.

StatusBodyWhen
200access_token, token_type, expires_inThe 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-AfterSee 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.

LimitCounted perChecked
30 requests per minuteSource IP addressFirst, before the body is read
10 requests per minuteclient_idAfter 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

PropertyValue
FormatJWT signed with HS256. Treat it as opaque.
Lifetime3,600 s (1 hour), from expires_in
RefreshNone. Request a new token before the old one expires.
ScopesThe client application's scopes at the moment the token was issued. The response does not list them.
RevocationA 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.

codeCauseWhat to do
missing_credentialsNo Authorization header, a scheme other than Bearer , or an empty tokenSend the token.
expired_tokenThe token is genuine and its hour has passedGet a new token and retry.
invalid_tokenBad signature, unknown or revoked token, or a client application that is missing, deactivated or expiredGet 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.

ScopeGrants
shipments:readGET /shipments, GET /shipments/{id}; shipment.* events and webhooks
shipments:writePOST /shipments, PATCH /shipments/{id}
invoices:readGET /invoices, GET /invoices/{id}; invoice.recorded events and webhooks
chains:readGET /chains, GET /chains/{id}; chain.* events and webhooks
vehicles:readGET /vehicles, GET /vehicles/{id}, GET /vehicles/{id}/availabilities; vehicle.* events and webhooks
matches:readGET /matches, GET /matches/{id}; match.* events and webhooks
quotes:readGET /quotes, GET /quotes/{id}; quote.* events and webhooks
outreach:readGET /outreach, GET /outreach/{id}; outreach.* events and webhooks
events:readGET /events
events:streamGET /events/stream
webhooks:readGET /webhook_endpoints, GET /webhook_endpoints/{id}
webhooks:writePOST /webhook_endpoints, PATCH and DELETE /webhook_endpoints/{id}, POST /webhook_endpoints/{id}/rotate_secret
estimatePOST /estimate, POST /estimate/batch
marketGET /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.

On this page