Skip to content

Reservations

Terminal window
npm install @limitry/sdk
import { createClient } from "@limitry/sdk";
const limitry = createClient(); // reads LIMITRY_API_KEY

POST /v1/reservations/{reservationId}/extend

Keeps a reservation for longer work: it now expires ttlSeconds from now (default 300, at most 3600) — call it again as a heartbeat.

await limitry.reservations.extend("<reservation-id>");
FieldDescription
reservationIdstring, path, required
ttlSecondsnumberSeconds from now. Default 300.
More about this endpoint

Only an open reservation can be extended. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.

POST /v1/reservations/{reservationId}/commit

Commits a reservation with the ACTUAL amount used (cost): less than reserved gives the rest back at once; more is charged in full — the work happened.

await limitry.reservations.commit("<reservation-id>", {
cost: 3,
});
FieldDescription
reservationIdstring, path, required
costnumber, requiredThe amount actually used.
More about this endpoint

A commit after the reservation expired still charges cost. Repeating a commit answers the same. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.

POST /v1/reservations/{reservationId}/release

Gives the whole reservation back — the work did not happen.

await limitry.reservations.release("<reservation-id>");
FieldDescription
reservationIdstring, path, required
More about this endpoint

Repeating a release answers the same; releasing a committed reservation is refused. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.