API documentation
Authentication
Company accounts can authenticate with an API key; any account can also authenticate with email and password, which give a JWT issued by AWS Cognito. In both cases you send the credential in the Authorization header, on every request tied to your account.
The integration account
There is no separate registration flow through the API. You use an ordinary Livrăria account, created once in the app. Our recommendation is an account dedicated to the integration, with an email address that you monitor — shipment notifications go to the account's address.
API keys (recommended for company accounts)
An active company account can create API keys. For a company integration this is the recommended option: you do not store the password, you do not authenticate every hour and you do not renew tokens. The key is sent exactly like a token, in the Authorization header.
- 1
Create the key
In the Livrăria account open Settings → Integrations → API keys, press Create key and name it after where you use it. Only company accounts see the page.
- 2
Copy it now
The key starts with
lvk_and is shown only once: you cannot read it again later. If you lose it, you revoke it and create another. An account can have at most 10 active keys; beyond that limit, creation answers with 422. - 3
Send it on requests
Example (example key) bashcurl -H "Authorization: Bearer lvk_example" \ https://www.api.livraria.ro/users/me - 4
Revoke it when it is no longer needed
From the same page, with Revoke. The effect is immediate: the next request with that key gets 401.
The routes that accept a key
A key is accepted only on the 53 routes below. On any other route that requires authentication it is refused with 401 and the error API keys are not accepted on this endpoint, even if the key is valid; there you need a token obtained through login (next section). Public routes require neither a key nor a token.
| Area | Routes |
|---|---|
| Account | GET /users/meGET /users/me/sender-profileGET /users/me/recipient-profile |
| Quotes and order preparation | POST /public/awb/quotesPOST /public/awb/locker-ratesGET /quote-request/{id}GET /quote-request/{id}/recommendationPUT /quote-request/{id}/selected-courier-quotePOST /quote-request/{id}/attach-billing-info-from-sender-profile |
| Shipments | POST /expeditionGET /expeditionGET /expedition/{id}GET /expedition/trackingGET /expedition/remeasurementsPATCH /expedition/{id}/client-referencePOST /me/own-expeditionsPOST /public/awb/return/{awbNumber} |
| Labels and cancellation | GET /public/awb/print/{awbNumber}POST /public/awb/print/jobsGET /public/awb/print/jobs/{id}GET /public/awb/print/jobs/{id}/filePATCH /public/awb/cancel/{awbNumber}DELETE /public/awb/{awbNumber} |
| Invoices and payouts | GET /invoicesGET /invoices/{id}GET /payoutsGET /payouts/{id} |
| Analytics | GET /me/analytics/dashboardGET /me/analytics/courier-performance-by-county |
| Courier selection | GET /me/courier-selection-policyPUT /me/courier-selection-policyGET /me/courier-selection-rulesPOST /me/courier-selection-rulesPUT /me/courier-selection-rules/reorderPOST /me/courier-selection-rules/simulatePATCH /me/courier-selection-rules/{id}DELETE /me/courier-selection-rules/{id} |
| Default parcel | GET /me/default-parcelPUT /me/default-parcelDELETE /me/default-parcel |
| Tracked AWBs | POST /me/tracked-awbsPOST /me/tracked-awbs/lookupDELETE /me/tracked-awbs/{id} |
| Pickup points | GET /public/pickup-points/me |
| Status webhooks | GET /me/webhooksPOST /me/webhooksGET /me/webhooks/{id}PATCH /me/webhooks/{id}DELETE /me/webhooks/{id}POST /me/webhooks/{id}/rotate-secretPOST /me/webhooks/{id}/testGET /me/webhooks/{id}/deliveriesPOST /me/webhooks/deliveries/{deliveryId}/retry |
A key can never manage API keys (it cannot create, list or revoke them: for that you need a signed-in session) and cannot reach Livrăria's administration routes, whatever the account. For these, as for any other route not on the list, send a token from /auth/login.
Authenticating with email and password (login)
For accounts that cannot have an API key (personal accounts) or when you prefer a classic session, you authenticate with the account email and password.
/auth/loginpublic10/minRequest body
| Field | Type | Required | Description |
|---|---|---|---|
email | string | required | The account email address. |
password | string | required | The account password. |
{
"email": "integrare@firma.ro",
"password": "parola-contului"
}curl -X POST https://www.api.livraria.ro/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"integrare@firma.ro","password":"parola-contului"}'{
"success": true,
"data": {
"accessToken": "eyJraWQiOiJ...",
"refreshToken": "eyJjdHkiOiJKV1Q...",
"expiresIn": 3600,
"tokenType": "Bearer",
"user": {
"id": "8f4c1e22-...",
"email": "integrare@firma.ro",
"name": "Firma Mea SRL",
"isBusiness": true
}
},
"message": "Login successful"
}A successful authentication answers with 201, not 200.
The fields in data
| Field | Type | Required | Description |
|---|---|---|---|
accessToken | string | always | The token you send in Authorization. |
refreshToken | string | always | Cognito refresh token. You send it to POST /auth/refresh — see “Renewing the token”. |
expiresIn | number | always | The lifetime of the token, in seconds (3600). |
tokenType | string | always | Always Bearer. |
user | object | always | id, email, name and isBusiness. The full profile is read with GET /users/me. |
Using the token
Put the token in the Authorization header, with the Bearer prefix:
Authorization: Bearer <accessToken>curl -H "Authorization: Bearer $TOKEN" \
https://www.api.livraria.ro/users/mePublic routes (quick quotes, reference data, public tracking) do not require the header and ignore it if you send it.
The token lifecycle
- The token is valid for 3600 seconds. Keep it in memory and reuse it for its whole lifetime.
- Do not authenticate on every request. The limit on
/auth/loginis 10 requests per minute, and one authentication per hour is enough for a server integration. - When the token expires — the first sign is a 401 — renew it with
POST /auth/refresh(see below) or, if that fails, call/auth/loginagain. There is nologoutroute: to log out, simply discard the token.
Renewing the token
Without sending the password again, you can exchange the refreshToken received at login for a new access token.
/auth/refreshpublic10/minRequest body
| Field | Type | Required | Description |
|---|---|---|---|
refreshToken | string | required | The refreshToken returned by POST /auth/login (data.refreshToken), at most 4096 characters. |
{
"refreshToken": "eyJjdHkiOiJKV1Q..."
}{
"success": true,
"data": {
"accessToken": "eyJraWQiOiJ...",
"expiresIn": 3600,
"tokenType": "Bearer"
},
"message": "Session refreshed"
}The fields in data
| Field | Type | Required | Description |
|---|---|---|---|
accessToken | string | always | The new access token. |
expiresIn | number | always | The lifetime of the token, in seconds (3600). |
tokenType | string | always | Always Bearer. |
refreshToken | string | optional | Present only when Cognito issued a new refresh token. Otherwise, keep using the one you have. |
Errors
| Code | What it means | What you do |
|---|---|---|
| 400 | refreshToken is missing, empty, not a string or longer than 4096 characters. | Send the refreshToken returned by login. |
| 401 | The refresh token has expired, was revoked or is not valid for this client. The body carries message.reason with the value REFRESH_EXPIRED. | Log in again with /auth/login. |
| 429 | Too many refresh attempts. | Wait and try again. |
| 500 | Refreshing the session failed. | Try again later. |
Errors
| Code | What it means | What you do |
|---|---|---|
| 401 | Invalid credentials. | Check the email and the password. Do not retry automatically. |
| 400 | The account is not confirmed, or too many authentication attempts. | Confirm the address from the email received at registration, or wait for the window to pass, respectively. |
| 429 | You exceeded the limit of 10 requests per minute. | Wait the interval from Retry-After. If you get here, most likely you are not caching the token. |
The error message comes in message, and the full shape of the error responses is described in the overview.
Need help?
If authentication fails with details you know are correct, write to us with the account address and the time of the attempt — we can check in our logs.
Contact us