Public API
Authentication
The Authorization header, key check, and error codes
Every request to the public API is authenticated with a company key. The key goes in the Authorization header with the Bearer scheme:
Authorization: Bearer rv_live_<prefix>_<secret>
There are no cookies or user sessions here: company_id is derived from the key, so you never pick a company manually.
Checking a key
To confirm a key works and see its scopes, call /me:
curl https://api.rentevio.ru/api/public/v1/me \
-H "Authorization: Bearer rv_live_…"
{
"success": true,
"data": {
"company_id": "1e3e7bd5-…",
"scopes": ["equipment:read", "projects:read"],
"api_key_id": "01a14109-…"
}
}
/me needs no specific scope — any valid key can call it. Handy for a post-deploy smoke check.
Mutation headers
Authorization— always required.Idempotency-Key— forPOST,PATCH,DELETE. Repeating a request with the same value does not create a duplicate, so it is safe to retry after a network failure.
Error codes
Errors arrive in the {"success": false, "error": {…}} envelope, where error_code is a stable machine key:
error_code | HTTP | When |
|---|---|---|
UNAUTHORIZED | 401 | key missing, invalid, revoked or expired |
FORBIDDEN | 403 | the key lacks the required scope |
VALIDATION | 400 | malformed body or query parameters |
NOT_FOUND | 404 | resource not found or owned by another company |
CONFLICT | 409 | the operation conflicts with current state |
RATE_LIMITED | 429 | the key exceeded its rate limit |
UPSTREAM_ERROR | 502 | internal service error, retry later |
Example:
{
"success": false,
"error": {
"code": 403,
"error_code": "FORBIDDEN",
"message": "insufficient scope"
}
}
401 and 403 mean different things: 401 is "key rejected", 403 is "key accepted but not allowed". Handle them separately so you never show a client the wrong cause.
Next — versioning: how the API treats backward compatibility.