Skip to content

Reservations API

The reservations endpoints, each in TypeScript, Python, the CLI and curl.

Terminal window
npm install @limitry/sdk
export LIMITRY_API_KEY="lim_test_…"

To pass the key yourself, use createClient({ apiKey: key }) in TypeScript or Limitry(api_key=key) in Python.

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);

Returns:

{
"id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a",
"status": "committed",
"reserved": 5,
"cost": 3,
"expiresAt": "2026-11-06T12:05:00.000Z"
}
Field Description
reservationId string, path, required 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.

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);

Returns:

{
"id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a",
"status": "committed",
"reserved": 5,
"cost": 3,
"expiresAt": "2026-11-06T12:05:00.000Z"
}
Field Description
reservationId string, path, required The reservation's ID.
ttlSeconds number 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.

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);

Returns:

{
"id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a",
"status": "committed",
"reserved": 5,
"cost": 3,
"expiresAt": "2026-11-06T12:05:00.000Z"
}
Field Description
reservationId string, path, required The reservation's ID.
cost number, required 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.

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);

Returns:

{
"id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a",
"status": "committed",
"reserved": 5,
"cost": 3,
"expiresAt": "2026-11-06T12:05:00.000Z"
}
Field Description
reservationId string, path, required 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.