Authentication
Every API request authenticates with an API key sent as a Bearer token. Keys belong to your organization and can be limited to some endpoints, to your websites or to your servers' IPs. This page also covers what every endpoint shares: rate limits, quota, request IDs, caching, pagination and idempotency.
Bearer token
Send the key in the Authorization header, prefixed with Bearer. Keys start with psk_live_. The key is shown exactly once at creation — keep it in a secret manager, never in source or version control.
Authorization: Bearer psk_live_3f9a...Scopes
Each key carries scopes that limit which endpoints it can call. A new key gets all three by default; create least-privilege keys per integration. A call outside the key's scopes returns 403 insufficient_scope. It is rejected before the rate limit and the quota, so it costs you nothing.
| Scope | Covers |
|---|---|
verify | POST /v1/addresses/verify, POST /v1/addresses/batch, GET /v1/addresses/batch, GET /v1/addresses/batch/{id}, GET /v1/addresses/batch/{id}/results |
autocomplete | GET /v1/addresses/autocomplete |
postal_lookup | GET /v1/postal-codes/{code}, POST /v1/postal-codes/search, GET /v1/counties, GET /v1/localities/{siruta} |
IP and origin allowlists
A key can also be restricted to where it is used. With allowed IPs set (IPv4 or IPv6 addresses or CIDR ranges), calls from any other client IP return 403 ip_not_allowed. With allowed origins set, the request must carry a matching Origin header, otherwise you get 403 origin_not_allowed. That includes server-side calls, which send no Origin. Write origins as scheme://host[:port], lowercase, with no path, trailing slash or wildcard (https://shop.example.ro). For a key in browser code, create an autocomplete-only key with allowed origins. Origin is a header the client sets, so the list only stops a leaked key from being reused on other websites; it does not make the key a secret. Rate limits are what contain abuse.
Managing keys
Create, restrict, rotate and revoke keys under API keys in the dashboard (owners and admins). An organization can hold up to 25 active keys on the Free plan and 100 on any paid plan; revoked keys do not count. Rotating a key creates a replacement with the same name, scopes, environment and restrictions and revokes the old key immediately, with no overlap, so deploy the new secret right away. The API caches validated keys, so a revoked or rotated key can keep working for up to about 65 seconds; after that it gets 401 invalid_api_key.
Rate limits
Rate limits apply per key and per plan, in two windows: requests per second and requests per minute. Exceeding either returns 429 rate_limit_exceeded with a Retry-After header: wait that many seconds, then retry. On a successful call the X-RateLimit-* headers show your per-minute window; on a 429 they show the window you exceeded.
| Plan | Per second | Per minute |
|---|---|---|
| Free | 5 | 100 |
| Starter | 20 | 500 |
| Growth | 50 | 2,000 |
| Scale | 200 | 10,000 |
| Enterprise | Limits agreed with us | |
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum number of requests allowed in the current window. |
X-RateLimit-Remaining | How many requests you have left in the current window. |
X-RateLimit-Reset | Unix timestamp at which the window resets. |
Retry-After | Seconds to wait before retrying (present on 429 only). |
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1718700000
Retry-After: 12
Content-Type: application/json
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded, please slow down",
"request_id": "a1b2c3d4e5f6a7b8"
}
}Quota, overage and spend cap
Only billable calls count toward your monthly quota: verify, autocomplete, postal-code lookup and search, reference data (counties and localities, billed like lookups) and batch submit. A 304 Not Modified counts like a 200. Usage reads and batch list, status and results polling are never counted and never return 402. A used-up quota is not a 429. On a plan without overage you get 402 quota_exceeded (with X-Posty-Period-Resets-At), and retrying will not help. On a plan with overage, calls keep working and the extra requests are billed; an organization admin can set a monthly spend cap under Billing in the dashboard. Once the overage reaches the cap, calls return 402 spend_cap_reached (also with X-Posty-Period-Resets-At) until the next period or until the cap is raised. Usage is aggregated hourly, so the cap can be overshot by up to about an hour of traffic.
Request headers
| Header | Description |
|---|---|
Authorization | Bearer <your API key>. Required on every request. |
X-Request-Id | Optional: your own correlation ID, 8-64 characters [A-Za-z0-9._-]. When valid it is echoed as X-Posty-Request-Id and used in logs and error.request_id; invalid values are ignored and replaced by a generated ID. It is a correlation label only, not a trace ID. |
Idempotency-Key | POST /v1/addresses/batch only (see below). |
If-None-Match | ETag from an earlier 200; on a match you get 304 (see Caching and ETag). |
Accept-Language | ro or en: language of error.message (default ro). Success bodies are not localised. |
Other response headers
| Header | Description |
|---|---|
X-Posty-Request-Id | On every response, success or error; error bodies repeat it as error.request_id. Quote it when contacting support. |
X-Cache | HIT when served from cache, MISS when computed. Absent when the cache was bypassed. 200 responses only (postal-code lookup, autocomplete, reference data). |
X-Data-Attribution | Licence attribution for the data sources (OGL-ROU-1.0; ODbL-1.0 for OpenStreetMap when that source is enabled). If you display results, display this text too. |
Link | Always sent with X-Data-Attribution: <https://posty.ro/legal/data-sources>; rel="license". |
X-Posty-Period-Resets-At | On 402 quota_exceeded: RFC 3339 time at which the monthly quota resets. |
X-Posty-Grace-Period-Ends | On 402 payment_required: end of the past-due grace period. |
Caching and ETag
Postal-code lookup, autocomplete and reference data (counties, localities) responses carry an ETag and Cache-Control: private. Send the ETag back as If-None-Match: if nothing changed you get an empty 304 instead of the body. A 304 is a served request and is billed exactly like a 200, so it saves bandwidth, not quota. Autocomplete ETags only make sense for the same API key (Vary: Authorization).
Pagination
List endpoints (today GET /v1/addresses/batch) paginate with an opaque cursor. Send limit (1 to 200, default 50) and, for later pages, cursor. The response has a data array and a next_cursor field, and next_cursor is null on the last page. Pass it back unchanged as cursor. Results are newest first and limited to your organization. A malformed cursor or an out-of-range limit is 400 invalid_parameter.
curl "https://api.posty.ro/v1/addresses/batch?limit=50" \
-H "Authorization: Bearer psk_live_xxx"
# next page: pass next_cursor back unchanged
curl "https://api.posty.ro/v1/addresses/batch?limit=50&cursor=<next_cursor>" \
-H "Authorization: Bearer psk_live_xxx"Idempotency-Key
POST /v1/addresses/batch accepts an Idempotency-Key header (1 to 255 visible ASCII characters, for example a UUID) so a retry never creates a second job. Within 24 hours, the same key from the same organization with the same file_url and options.callback_url returns the original job with 202 and Idempotent-Replayed: true; no new job is created and nothing is billed again. The same key with a different body is 422 idempotency_key_reused, and a malformed key is 400 invalid_idempotency_key. Without the header, every call creates a new job. No other endpoint reads this header: verify, autocomplete and lookups are safe to retry as they are.
curl -X POST https://api.posty.ro/v1/addresses/batch \
-H "Authorization: Bearer psk_live_xxx" \
-H "Idempotency-Key: 7c1f6e2a-9b3d-4e6f-8a1c-2d4f6e8a0b2c" \
-H "Content-Type: application/json" \
-d '{ "file_url": "https://example.com/addresses.csv" }'