Reservations API
The reservations endpoints, each in TypeScript, Python, the CLI and curl.
Set up
Section titled “Set up”npm install @limitry/sdkexport LIMITRY_API_KEY="lim_test_…"pip install limitryexport LIMITRY_API_KEY="lim_test_…"npm install -g @limitry/clilimitry loginexport LIMITRY_API_KEY="lim_test_…"To pass the key yourself, use createClient({ apiKey: key }) in TypeScript or Limitry(api_key=key) in Python.
Get a reservation
Section titled “Get a reservation”GET /v1/reservations/{reservationId} Try it in the API playground (opens in a new tab) Scope: checks:write.
Returns a reservation as it stands: held, committed, released or expired, with what it reserved and what it finally used.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();const reservation = await limitry.reservations.get("<reservation-id>");console.log(reservation);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()reservation = limitry.reservations.get("<reservation-id>")print(reservation)limitry reservations get '<reservation-id>'curl -X GET "https://api.limitry.com/v1/reservations/<reservation-id>" \ -H "Authorization: Bearer $LIMITRY_API_KEY"Returns:
{ "id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a", "status": "committed", "reserved": 5, "cost": 3, "expiresAt": "2026-11-06T12:05:00.000Z"}| Field | Description |
|---|---|
reservationId | The reservation's ID. |
More about this endpoint
A reservation past its expiry that nobody committed or released reads as expired. Reading it changes nothing.
Extend a reservation
Section titled “Extend a reservation”POST /v1/reservations/{reservationId}/extend Try it in the API playground (opens in a new tab) Scope: checks:write.
Keeps a reservation open for longer work, so it expires ttlSeconds from now.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();const result = await limitry.reservations.extend("<reservation-id>", { ttlSeconds: 600,});console.log(result);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()result = limitry.reservations.extend("<reservation-id>", ttl_seconds=600)print(result)limitry reservations extend '<reservation-id>' --ttl-seconds 600curl -X POST "https://api.limitry.com/v1/reservations/<reservation-id>/extend" \ -H "Authorization: Bearer $LIMITRY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"ttlSeconds":600}'Returns:
{ "id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a", "status": "committed", "reserved": 5, "cost": 3, "expiresAt": "2026-11-06T12:05:00.000Z"}| Field | Description |
|---|---|
reservationId | The reservation's ID. |
ttlSeconds | Seconds from now until the reservation expires. Default: 300. At most 3600. |
More about this endpoint
Call it again as a heartbeat while the work runs. You can only extend a reservation that’s still held. We cache its API key check briefly for speed. A revoked key can keep working here for up to 60 seconds.
Commit a reservation
Section titled “Commit a reservation”POST /v1/reservations/{reservationId}/commit Try it in the API playground (opens in a new tab) Scope: checks:write.
Commits a reservation with the amount actually used (cost).
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();const result = await limitry.reservations.commit("<reservation-id>", { cost: 3,});console.log(result);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()result = limitry.reservations.commit("<reservation-id>", cost=3)print(result)limitry reservations commit '<reservation-id>' --cost 3curl -X POST "https://api.limitry.com/v1/reservations/<reservation-id>/commit" \ -H "Authorization: Bearer $LIMITRY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"cost":3}'Returns:
{ "id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a", "status": "committed", "reserved": 5, "cost": 3, "expiresAt": "2026-11-06T12:05:00.000Z"}| Field | Description |
|---|---|
reservationId | The reservation's ID. |
cost | The amount actually used. |
More about this endpoint
If cost is less than the amount reserved, the rest goes back at once. If it’s more, Limitry charges the whole cost, since the work happened. A commit up to 24 hours after the reservation expired still charges cost. Repeating a commit with the same cost returns the same result, and a different cost gets a 400. Committing a released reservation gets a 409. We cache its API key check briefly for speed. A revoked key can keep working here for up to 60 seconds.
Release a reservation
Section titled “Release a reservation”POST /v1/reservations/{reservationId}/release Try it in the API playground (opens in a new tab) Scope: checks:write.
Gives the whole reservation back, because the work didn’t happen.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();const result = await limitry.reservations.release("<reservation-id>");console.log(result);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()result = limitry.reservations.release("<reservation-id>")print(result)limitry reservations release '<reservation-id>'curl -X POST "https://api.limitry.com/v1/reservations/<reservation-id>/release" \ -H "Authorization: Bearer $LIMITRY_API_KEY"Returns:
{ "id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a", "status": "committed", "reserved": 5, "cost": 3, "expiresAt": "2026-11-06T12:05:00.000Z"}| Field | Description |
|---|---|
reservationId | The reservation's ID. |
More about this endpoint
Repeating a release within 24 hours returns the same result. You can’t release a reservation you’ve already committed. We cache its API key check briefly for speed. A revoked key can keep working here for up to 60 seconds.