@limitry/sdk 1.0.0-rc.7 → 1.0.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/v1.gen.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface paths {
10
10
  put?: never;
11
11
  /**
12
12
  * Check whether a subject may act
13
- * @description Asks whether `subject` may do `action` at `cost`, given every enabled limit that applies, and — in `consume` mode — uses it. Always 200 for a decision: read `allowed`; `remaining` shows what is left per limit and `retryAfterSeconds` when to try again. An `Idempotency-Key` header makes a retried check return the same decision without using twice. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.
13
+ * @description Asks whether `subject` may do `action` at `cost`, given every enabled limit that applies, and — in `consume` mode — uses it. Always 200 for a decision, allowed or refused: read `allowed`; `limits` shows what is left on each limit and `retryAfterSeconds` when to try again. An `Idempotency-Key` header makes a retried check return the same decision without using twice. Its API-key check is cached briefly for speed: a revoked key can keep working here for up to 60 seconds.
14
14
  */
15
15
  post: operations["checks.create"];
16
16
  delete?: never;
@@ -34,7 +34,7 @@ export interface paths {
34
34
  put?: never;
35
35
  /**
36
36
  * Create a limit
37
- * @description Limits how much of an action a subject may use per window — for example 200 cents of `ai-call` a month for every `user`. Checks enforce it from then on. Names are unique among the environment's active limits. Owners and admins only, for a person's token.
37
+ * @description Limits how much a subject may use per window — for example 200 cents a month for every `user`. Only `subject.kind`, `amount` and `window` are needed: `action` defaults to every action (`*`), `unit` to units, and `name` to the sentence the limit reads as. Checks enforce it from then on. What it counts (subject, action, unit, window, every, start, rolling) is fixed once created. Owners and admins only, for a person's token.
38
38
  */
39
39
  post: operations["limits.create"];
40
40
  delete?: never;
@@ -62,7 +62,7 @@ export interface paths {
62
62
  head?: never;
63
63
  /**
64
64
  * Change a limit
65
- * @description Changes any of a limit's fields; checks use the new rule within a minute. Owners and admins only, for a person's token.
65
+ * @description Changes a limit's name, amount, fail mode or whether it is enabled; checks use the new rule at once. What a limit counts (subject, action, unit, window, every, start, rolling) is fixed: a different value is refused (400) — create a new limit and archive this one. Owners and admins only, for a person's token.
66
66
  */
67
67
  patch: operations["limits.update"];
68
68
  trace?: never;
@@ -78,7 +78,7 @@ export interface paths {
78
78
  put?: never;
79
79
  /**
80
80
  * Archive a limit
81
- * @description Stops a limit: checks stop enforcing it within a minute, and it leaves the list. It is archived, not erased — its usage history and credit grants stay, and `POST /v1/limits/{limitId}/restore` brings it back. Owners and admins only, for a person's token.
81
+ * @description Stops a limit: checks stop enforcing it at once, and it leaves the list. It is archived, not erased — its usage history and credits stay, and `POST /v1/limits/{limitId}/restore` brings it back. Owners and admins only, for a person's token.
82
82
  */
83
83
  post: operations["limits.archive"];
84
84
  delete?: never;
@@ -87,7 +87,7 @@ export interface paths {
87
87
  patch?: never;
88
88
  trace?: never;
89
89
  };
90
- "/limits/{limitId}/grants": {
90
+ "/limits/{limitId}/credits": {
91
91
  parameters: {
92
92
  query?: never;
93
93
  header?: never;
@@ -95,16 +95,16 @@ export interface paths {
95
95
  cookie?: never;
96
96
  };
97
97
  /**
98
- * List a balance's grants
99
- * @description Credits added to subjects' balances for this limit, newest first.
98
+ * List a balance's credits
99
+ * @description Credits added to (or taken back from) subjects' balances for this limit, newest first.
100
100
  */
101
- get: operations["limits.grants.list"];
101
+ get: operations["limits.credits.list"];
102
102
  put?: never;
103
103
  /**
104
104
  * Add credits to a balance
105
- * @description Adds `amount` to one subject's balance — a limit whose window is `total`. A negative `amount` takes credits back (a refund, a chargeback) and needs a `note` saying why; the balance may go below zero, and checks are refused until it is topped up. Owners and admins, or a workspace API key; an agent asks a person (the `limit.grant` approval).
105
+ * @description Adds `amount` credits to one subject's balance — a limit whose window is `total`. A negative `amount` takes credits back (a refund, a chargeback) and needs a `note` saying why; the balance may go below zero, and checks are refused until more credits are added. Owners and admins, or a workspace API key; an agent asks a person (the `limit.credit` approval).
106
106
  */
107
- post: operations["limits.grants.create"];
107
+ post: operations["limits.credits.create"];
108
108
  delete?: never;
109
109
  options?: never;
110
110
  head?: never;
@@ -142,7 +142,7 @@ export interface paths {
142
142
  put?: never;
143
143
  /**
144
144
  * Sync limits from a list
145
- * @description Makes the environment's limits match `limits`, by name: creates the missing, changes those that differ (an omitted field means its default) and, with `archiveMissing`, archives active limits the list doesn't name. Running it twice changes nothing the second time. Limitry checks the whole list first, and a problem anywhere changes nothing (400, each problem in `details`); then it writes every change at once. `dryRun` answers the plan without writing. For keeping limits in a file in your repository (`limitry sync`). Owners and admins only, for a person's token.
145
+ * @description Makes the environment's limits match `limits`, by name: creates the missing, changes those that differ (an omitted field means its default) and, with `archiveMissing`, archives active limits the list doesn't name. Running it twice changes nothing the second time. Limitry checks the whole list first, and a problem anywhere changes nothing (400, each problem in `details`); then it writes every change at once. What a limit counts is fixed: a different subject, action, unit or window under an existing name is refused until the entry is renamed. `preview` answers what it would do without writing. For keeping limits in a file in your repository (`limitry sync`). Owners and admins only, for a person's token.
146
146
  */
147
147
  post: operations["limits.sync"];
148
148
  delete?: never;
@@ -162,7 +162,7 @@ export interface paths {
162
162
  put?: never;
163
163
  /**
164
164
  * Commit a reservation
165
- * @description Settles a hold with the ACTUAL amount used (`cost`): less than held gives the rest back at once; more is charged in full — the work happened. A commit after the hold 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.
165
+ * @description 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. 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.
166
166
  */
167
167
  post: operations["reservations.commit"];
168
168
  delete?: never;
@@ -182,7 +182,7 @@ export interface paths {
182
182
  put?: never;
183
183
  /**
184
184
  * Extend a reservation
185
- * @description Keeps a hold for longer work: it now expires `ttlSeconds` from now (default 300, at most 3600) — call it again as a heartbeat. Only a held 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.
185
+ * @description Keeps a reservation for longer work: it now expires `ttlSeconds` from now (default 300, at most 3600) — call it again as a heartbeat. 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.
186
186
  */
187
187
  post: operations["reservations.extend"];
188
188
  delete?: never;
@@ -202,7 +202,7 @@ export interface paths {
202
202
  put?: never;
203
203
  /**
204
204
  * Release a reservation
205
- * @description Gives the whole hold back — the work did not happen. 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.
205
+ * @description Gives the whole reservation back — the work did not happen. 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.
206
206
  */
207
207
  post: operations["reservations.release"];
208
208
  delete?: never;
@@ -220,7 +220,7 @@ export interface paths {
220
220
  };
221
221
  /**
222
222
  * Get a subject
223
- * @description A subject's anchor: when its `anchor` limits' periods start from. A subject is yours (a user, a team, an agent) and exists once a check names it.
223
+ * @description A subject's billing date: when its `billing_date` limits' periods start from. A subject is yours (a user, a team, an agent) and exists once a check names it.
224
224
  */
225
225
  get: operations["subjects.get"];
226
226
  put?: never;
@@ -229,8 +229,8 @@ export interface paths {
229
229
  options?: never;
230
230
  head?: never;
231
231
  /**
232
- * Set a subject's anchor
233
- * @description Sets when a subject's `anchor` limits' periods start from: typically its subscription's start date, from your billing system's webhook, so its allowance refills on its own billing day (monthly for an annual plan, too). Owners and admins only, for a person's token.
232
+ * Set a subject's billing date
233
+ * @description Sets when a subject's `billing_date` limits' periods start from: typically its subscription's start date, from your billing system's webhook, so its allowance resets on its own billing day (monthly for an annual plan, too). Owners and admins only, for a person's token.
234
234
  */
235
235
  patch: operations["subjects.update"];
236
236
  trace?: never;
@@ -246,7 +246,7 @@ export interface paths {
246
246
  put?: never;
247
247
  /**
248
248
  * Reset a subject's limits
249
- * @description Refills one limit on a subject (`limitId`), or every limit on it (`{}`), at once: for goodwill, a promotion or support. The schedule doesn't move: the next refill is still the usual one. A balance goes back to its amount; a concurrent limit is skipped. Send an Idempotency-Key and a repeat resets once. Owners and admins only, for a person's token.
249
+ * @description Resets one limit on a subject (`limitId`), or every limit on it (`{}`), at once: for goodwill, a promotion or support. The schedule doesn't move: the next reset is still the usual one. A balance goes back to its amount; a concurrent limit is skipped. Send an Idempotency-Key and a repeat resets once. Owners and admins only, for a person's token.
250
250
  */
251
251
  post: operations["subjects.reset"];
252
252
  delete?: never;
@@ -264,7 +264,7 @@ export interface paths {
264
264
  };
265
265
  /**
266
266
  * Get a limit's usage over time
267
- * @description Units used, checks allowed and denied for one limit — across all subjects, or one (`subjectKind` + `subjectId`) — per hour or per day (UTC), every bucket in the range included. Up to about a minute behind live checks. Default: the last 30 days, by day.
267
+ * @description Units used, checks allowed and refused for one limit — across all subjects, or one (`subject`, as `kind:id`) — per hour or per day (UTC), every bucket in the range included. Up to about a minute behind live checks. Default: the last 30 days, by day.
268
268
  */
269
269
  get: operations["usage.query"];
270
270
  put?: never;
@@ -284,7 +284,7 @@ export interface paths {
284
284
  };
285
285
  /**
286
286
  * Get where a subject stands
287
- * @description Every enabled limit on one subject — and on its shared subjects (`shared`, comma-separated `kind:id`, such as `team:team_42`) — with what is used, what is left and when it resets, exact as of now. For showing an end user where they stand: call it from your server with your key, never from a browser. Not a check: nothing is counted. A subject with no limit here answers an empty `limits` list.
287
+ * @description Every enabled limit on one subject (`subject`, as `kind:id`, such as `user:usr_123`) — and on its shared subjects (`shared`, comma-separated `kind:id`, such as `team:team_42`) — with what is used, what is left and when it resets, exact as of now. For showing an end user where they stand: call it from your server with your key, never from a browser. Not a check: nothing is counted. A subject with no limit here answers an empty `limits` list.
288
288
  */
289
289
  get: operations["usage.standing"];
290
290
  put?: never;
@@ -304,7 +304,7 @@ export interface paths {
304
304
  };
305
305
  /**
306
306
  * List who is using a limit now
307
- * @description A limit's subjects in its CURRENT window, most used first: units used, what is left, how many checks were denied — `over` when any were. Up to about a minute behind live checks.
307
+ * @description A limit's subjects in its CURRENT window, most used first: units used, what is left, and how many checks it refused. Up to about a minute behind live checks.
308
308
  */
309
309
  get: operations["usage.subjects"];
310
310
  put?: never;
@@ -772,21 +772,21 @@ export interface components {
772
772
  allowed: boolean;
773
773
  /** @example chk_9d2e… */
774
774
  id: string;
775
- /** @description Why not, when `allowed` is false: a limit is used up (`limit` names it), or the subject already holds the most open reservations (1,000). */
775
+ /** @description Every limit that applied, and what is left on each (`limits[0].remaining`). */
776
+ limits: components["schemas"]["CheckLimit"][];
777
+ /** @description Why it was refused, when `allowed` is false: `limit_reached` — a limit is used up (`limitId` names it) — or `too_many_reservations` — the subject already holds the most open reservations (1,000). */
776
778
  reason: {
777
779
  /** @enum {string} */
778
- code: "limit_exceeded" | "too_many_reservations";
779
- /** @example lim_3f0c… */
780
- limit: string | null;
780
+ code: "limit_reached" | "too_many_reservations";
781
+ /** @example lmt_3f0c… */
782
+ limitId: string | null;
781
783
  /**
782
784
  * @description The refusal in one sentence, for people and logs: show it, never parse it (its wording may change). Branch on `allowed` and `code`.
783
785
  * @example Refused by AI replies per day: 0 replies left, resets 2026-11-01T00:00:00.000Z. Try again in 3600 s.
784
786
  */
785
787
  message: string;
786
788
  } | null;
787
- /** @description Every limit that applied, and what is left in its window. */
788
- remaining: components["schemas"]["CheckRemaining"][];
789
- /** @description With `mode: reserve`, when allowed: the hold — commit or release it before `expiresAt`, or it releases itself. */
789
+ /** @description With `mode: reserve`, when allowed: the reservation — commit or release it before `expiresAt`, or it releases itself. */
790
790
  reservation?: {
791
791
  expiresAt: string;
792
792
  /** @example rsv_WyJ1c2VyIiwidV80MiJd_9f… */
@@ -795,14 +795,14 @@ export interface components {
795
795
  /** @description When `allowed` is false: seconds until it could be allowed. */
796
796
  retryAfterSeconds: number | null;
797
797
  };
798
- CheckRemaining: {
798
+ CheckLimit: {
799
799
  /**
800
800
  * @description What to do if Limitry cannot be reached next time: `open` allows, `closed` denies. SDKs remember it.
801
801
  * @enum {string}
802
802
  */
803
803
  failMode: "open" | "closed";
804
- /** @example lim_3f0c… */
805
- limit: string;
804
+ /** @example lmt_3f0c… */
805
+ limitId: string;
806
806
  /** @example AI budget */
807
807
  name: string;
808
808
  /** @example 195 */
@@ -831,7 +831,7 @@ export interface components {
831
831
  */
832
832
  cost?: number;
833
833
  /**
834
- * @description `consume` (default) decides and uses; `preview` decides without using; `reserve` decides and HOLDS `cost` (an estimate) until you commit the actual amount or release it — see `reservation` in the answer. Only a reservation takes a slot of a `concurrent` limit.
834
+ * @description `consume` (default) decides and uses; `preview` decides without using; `reserve` decides and reserves `cost` (what it will probably use) until you commit the actual amount or release it — see `reservation` in the answer. Only a reservation takes a slot of a `concurrent` limit.
835
835
  * @example consume
836
836
  * @enum {string}
837
837
  */
@@ -851,7 +851,7 @@ export interface components {
851
851
  }[];
852
852
  subject: components["schemas"]["CheckSubject"];
853
853
  /**
854
- * @description With `reserve`: how long the hold lasts before it releases itself. Default 300, at most 3600.
854
+ * @description With `reserve`: how long the reservation lasts before it releases itself. Default 300, at most 3600.
855
855
  * @example 300
856
856
  */
857
857
  ttlSeconds?: number;
@@ -869,6 +869,42 @@ export interface components {
869
869
  */
870
870
  kind: string;
871
871
  };
872
+ Credit: {
873
+ amount: number;
874
+ createdAt: string;
875
+ createdByUserId: string | null;
876
+ /** @example crd_… */
877
+ id: string;
878
+ limitId: string;
879
+ note: string;
880
+ subject: {
881
+ id: string;
882
+ kind: string;
883
+ };
884
+ };
885
+ CreditInput: {
886
+ /**
887
+ * @description Credits to add; negative to take them back. Not 0.
888
+ * @example 5000
889
+ */
890
+ amount: number;
891
+ /**
892
+ * @description Required when `amount` is negative.
893
+ * @example October credits
894
+ */
895
+ note?: string;
896
+ /**
897
+ * @description Who gets the credits, as `{"kind": "team", "id": "team_42"}`.
898
+ * @example {
899
+ * "kind": "team",
900
+ * "id": "team_42"
901
+ * }
902
+ */
903
+ subject: {
904
+ id: string;
905
+ kind: string;
906
+ };
907
+ };
872
908
  ErrorEnvelope: {
873
909
  error: {
874
910
  /** @example unauthorized */
@@ -915,7 +951,7 @@ export interface components {
915
951
  * @example 200
916
952
  */
917
953
  amount: number;
918
- /** @description When it was archived (deleting archives it); null while active. An archived limit isn't enforced; its usage history and credit grants stay. */
954
+ /** @description When it was archived; null while active. An archived limit isn't enforced; its usage history and credits stay. */
919
955
  archivedAt: string | null;
920
956
  /** @example 2026-10-04T12:00:00.000Z */
921
957
  createdAt: string;
@@ -931,18 +967,23 @@ export interface components {
931
967
  * @enum {string}
932
968
  */
933
969
  failMode: "open" | "closed";
934
- /** @example lim_3f0c… */
970
+ /** @example lmt_3f0c… */
935
971
  id: string;
936
- /** @example AI budget */
972
+ /**
973
+ * @description The hour a check last reached this limit, from usage history (up to about a minute behind); null if none has. A limit no check reaches isn't being enforced: check the subject kind and action your checks send.
974
+ * @example 2026-10-04T12:00:00.000Z
975
+ */
976
+ lastCheckedAt: string | null;
977
+ /** @example 200 cents per user per month */
937
978
  name: string;
938
979
  /** @description Counts the last minute, hour or day at the moment of the check instead of the calendar window. */
939
980
  rolling: boolean;
940
981
  /**
941
- * @description Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `anchor`: from the subject's anchor, its billing date, set with `subjects.update` (its first check until then), so an annual plan can refill monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar.
982
+ * @description Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `billing_date`: from the subject's billing date, set with `subjects.update` (its first check until then), so an annual plan can reset monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar.
942
983
  * @example calendar
943
984
  * @enum {string}
944
985
  */
945
- start: "calendar" | "anchor" | "first_use";
986
+ start: "calendar" | "billing_date" | "first_use";
946
987
  subject: components["schemas"]["LimitSubject"];
947
988
  /** @example cents */
948
989
  unit: string;
@@ -951,54 +992,18 @@ export interface components {
951
992
  /** @description Increases on every change. */
952
993
  version: number;
953
994
  /**
954
- * @description `minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, refilled where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, topped up by grants. `concurrent`: at most `amount` held reservations at once.
995
+ * @description `minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, reset where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, raised by credits. `concurrent`: at most `amount` open reservations at once.
955
996
  * @example month
956
997
  * @enum {string}
957
998
  */
958
999
  window: "minute" | "hour" | "day" | "week" | "month" | "year" | "total" | "concurrent";
959
1000
  };
960
- LimitGrant: {
961
- amount: number;
962
- createdAt: string;
963
- createdByUserId: string | null;
964
- /** @example grt_… */
965
- id: string;
966
- limitId: string;
967
- note: string;
968
- subject: {
969
- id: string;
970
- kind: string;
971
- };
972
- };
973
- LimitGrantInput: {
974
- /**
975
- * @description Credits to add; negative to take them back. Not 0.
976
- * @example 5000
977
- */
978
- amount: number;
979
- /**
980
- * @description Required when `amount` is negative.
981
- * @example October top-up
982
- */
983
- note?: string;
984
- /**
985
- * @description Who gets the credits, as `{"kind": "team", "id": "team_42"}`.
986
- * @example {
987
- * "kind": "team",
988
- * "id": "team_42"
989
- * }
990
- */
991
- subject: {
992
- id: string;
993
- kind: string;
994
- };
995
- };
996
1001
  LimitInput: {
997
1002
  /**
998
- * @description The action to limit; `*` for every action.
1003
+ * @description The action to limit. Default: `*`, every action.
999
1004
  * @example ai-call
1000
1005
  */
1001
- action: string;
1006
+ action?: string;
1002
1007
  /**
1003
1008
  * @description How many units each subject may use per window.
1004
1009
  * @example 200
@@ -1017,93 +1022,89 @@ export interface components {
1017
1022
  */
1018
1023
  failMode?: "open" | "closed";
1019
1024
  /**
1020
- * @description A name for the limit, unique among its environment's active limits.
1025
+ * @description A name, unique among the environment's active limits. Default: the sentence the limit reads as, such as "200 cents per user per month". If a limit already has that name, the answer is 409: give this one a name.
1021
1026
  * @example AI budget
1022
1027
  */
1023
- name: string;
1028
+ name?: string;
1024
1029
  /** @description Count the last window instead of the calendar one (minute, hour or day only). Default: false. */
1025
1030
  rolling?: boolean;
1026
1031
  /**
1027
- * @description Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `anchor`: from the subject's anchor, its billing date, set with `subjects.update` (its first check until then), so an annual plan can refill monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar.
1032
+ * @description Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `billing_date`: from the subject's billing date, set with `subjects.update` (its first check until then), so an annual plan can reset monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar.
1028
1033
  * @example calendar
1029
1034
  * @enum {string}
1030
1035
  */
1031
- start?: "calendar" | "anchor" | "first_use";
1032
- /** @description One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window. */
1033
- subjectId?: string | null;
1034
- /**
1035
- * @description Your own label for who is checked.
1036
- * @example user
1037
- */
1038
- subjectKind: string;
1036
+ start?: "calendar" | "billing_date" | "first_use";
1037
+ subject: components["schemas"]["LimitInputSubject"];
1039
1038
  /**
1040
- * @description What the amount counts (display only). Default: units.
1039
+ * @description What the amount counts, in words. Default: units.
1041
1040
  * @example cents
1042
1041
  */
1043
1042
  unit?: string;
1044
1043
  /**
1045
- * @description `minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, refilled where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, topped up by grants. `concurrent`: at most `amount` held reservations at once.
1044
+ * @description `minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, reset where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, raised by credits. `concurrent`: at most `amount` open reservations at once.
1046
1045
  * @example month
1047
1046
  * @enum {string}
1048
1047
  */
1049
1048
  window: "minute" | "hour" | "day" | "week" | "month" | "year" | "total" | "concurrent";
1050
1049
  };
1050
+ /** @description Who it applies to: `{"kind": "user"}` for every user, `{"kind": "user", "id": "usr_123"}` for one. */
1051
+ LimitInputSubject: {
1052
+ /** @description One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window. */
1053
+ id?: string | null;
1054
+ /**
1055
+ * @description Your own label for who is checked: user, team, apikey …
1056
+ * @example user
1057
+ */
1058
+ kind: string;
1059
+ };
1051
1060
  LimitPage: {
1052
1061
  items: components["schemas"]["Limit"][];
1053
1062
  /** @description Pass as ?cursor= to fetch the next page. */
1054
1063
  nextCursor: string | null;
1055
1064
  };
1056
1065
  LimitPatch: {
1057
- /**
1058
- * @description The action to limit; `*` for every action.
1059
- * @example ai-call
1060
- */
1066
+ /** @description The action. Fixed once the limit is created: to change it, create a new limit and archive this one. */
1061
1067
  action?: string;
1062
1068
  /**
1063
1069
  * @description How many units each subject may use per window.
1064
- * @example 200
1070
+ * @example 300
1065
1071
  */
1066
1072
  amount?: number;
1067
- /** @description Whether checks enforce it. Default: true. */
1073
+ /** @description Whether checks enforce it. */
1068
1074
  enabled?: boolean;
1069
- /**
1070
- * @description How many `window` units a period lasts: `window: "month", every: 3` is a quarter, `window: "hour", every: 5` five hours. Default: 1.
1071
- * @example 1
1072
- */
1075
+ /** @description How many windows a period lasts. Fixed once the limit is created: to change it, create a new limit and archive this one. */
1073
1076
  every?: number;
1074
1077
  /**
1075
- * @description What your code should do when Limitry can't be reached: `open` (allow) or `closed` (deny). Default: open.
1078
+ * @description What your code should do when Limitry can't be reached: `open` (allow) or `closed` (deny).
1076
1079
  * @enum {string}
1077
1080
  */
1078
1081
  failMode?: "open" | "closed";
1079
1082
  /**
1080
- * @description A name for the limit, unique among its environment's active limits.
1083
+ * @description A new name, unique among the environment's active limits.
1081
1084
  * @example AI budget
1082
1085
  */
1083
1086
  name?: string;
1084
- /** @description Count the last window instead of the calendar one (minute, hour or day only). Default: false. */
1087
+ /** @description Whether it counts the last window. Fixed once the limit is created: to change it, create a new limit and archive this one. */
1085
1088
  rolling?: boolean;
1086
1089
  /**
1087
- * @description Where a period begins. `calendar`: UTC boundaries (midnight, Monday, the 1st, 1 January). `anchor`: from the subject's anchor, its billing date, set with `subjects.update` (its first check until then), so an annual plan can refill monthly from its start day. `first_use`: at the first check after the previous period ended. Default: calendar.
1088
- * @example calendar
1090
+ * @description Where a period begins. Fixed once the limit is created: to change it, create a new limit and archive this one.
1089
1091
  * @enum {string}
1090
1092
  */
1091
- start?: "calendar" | "anchor" | "first_use";
1092
- /** @description One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window. */
1093
- subjectId?: string | null;
1094
- /**
1095
- * @description Your own label for who is checked.
1096
- * @example user
1097
- */
1098
- subjectKind?: string;
1099
- /**
1100
- * @description What the amount counts (display only). Default: units.
1101
- * @example cents
1102
- */
1093
+ start?: "calendar" | "billing_date" | "first_use";
1094
+ /** @description Who it applies to. Fixed once the limit is created: to change it, create a new limit and archive this one. */
1095
+ subject?: {
1096
+ /** @description One subject; omit or null for every subject of the kind. A subject's own limit replaces the kind's limits with the same action and window. */
1097
+ id?: string | null;
1098
+ /**
1099
+ * @description Your own label for who is checked: user, team, apikey …
1100
+ * @example user
1101
+ */
1102
+ kind?: string;
1103
+ };
1104
+ /** @description What the amount counts. Fixed once the limit is created: to change it, create a new limit and archive this one. */
1103
1105
  unit?: string;
1104
1106
  /**
1105
- * @description `minute`, `hour`, `day`, `week`, `month` or `year`: a period of `every` of them, refilled where `start` says (or rolling: see `rolling`). `total`: a balance that never resets, topped up by grants. `concurrent`: at most `amount` held reservations at once.
1106
- * @example month
1107
+ * @description The window. Fixed once the limit is created: to change it, create a new limit and archive this one.
1107
1108
  * @enum {string}
1108
1109
  */
1109
1110
  window?: "minute" | "hour" | "day" | "week" | "month" | "year" | "total" | "concurrent";
@@ -1120,17 +1121,24 @@ export interface components {
1120
1121
  */
1121
1122
  kind: string;
1122
1123
  };
1124
+ LimitSyncEntry: components["schemas"]["LimitInput"] & {
1125
+ /**
1126
+ * @description The limit's name: the key a sync matches on, unique in the list.
1127
+ * @example AI budget
1128
+ */
1129
+ name: string;
1130
+ };
1123
1131
  LimitSyncInput: {
1124
1132
  /** @description Archive the environment's active limits whose names aren't in `limits` (restorable). Default: false, which leaves them alone. */
1125
1133
  archiveMissing?: boolean;
1126
- /** @description Answer what the sync would do and change nothing. Default: false. */
1127
- dryRun?: boolean;
1128
1134
  /**
1129
- * @description Every limit you want, each described whole: an omitted field is its default, as on create. Names are the key and must be unique in the list. At most 200.
1135
+ * @description Every limit you want, each described whole: an omitted field is its default, as on create. Names are the key and must be unique in the list. What a limit counts (subject, action, unit, window, every, start, rolling) is fixed: to change it, rename the entry, which creates a new limit. At most 200.
1130
1136
  * @example [
1131
1137
  * {
1132
1138
  * "name": "AI budget",
1133
- * "subjectKind": "user",
1139
+ * "subject": {
1140
+ * "kind": "user"
1141
+ * },
1134
1142
  * "action": "ai-call",
1135
1143
  * "amount": 200,
1136
1144
  * "unit": "cents",
@@ -1138,7 +1146,9 @@ export interface components {
1138
1146
  * }
1139
1147
  * ]
1140
1148
  */
1141
- limits: components["schemas"]["LimitInput"][];
1149
+ limits: components["schemas"]["LimitSyncEntry"][];
1150
+ /** @description Answer what the sync would do and change nothing. Default: false. */
1151
+ preview?: boolean;
1142
1152
  };
1143
1153
  LimitSyncResult: {
1144
1154
  /** @description Names of the limits archived (with `archiveMissing`). */
@@ -1150,8 +1160,8 @@ export interface components {
1150
1160
  * ]
1151
1161
  */
1152
1162
  created: string[];
1153
- /** @description True when nothing was written: this is the plan. */
1154
- dryRun: boolean;
1163
+ /** @description True when nothing was written: this is what a sync would do. */
1164
+ preview: boolean;
1155
1165
  /** @description Names of the limits that already matched. */
1156
1166
  unchanged: string[];
1157
1167
  /** @description The limits changed, field by field. */
@@ -1198,10 +1208,10 @@ export interface components {
1198
1208
  cost: number;
1199
1209
  expiresAt: string;
1200
1210
  id: string;
1201
- /** @description The amount held. */
1211
+ /** @description The amount reserved. */
1202
1212
  reserved: number;
1203
1213
  /**
1204
- * @description `expired`: nobody settled it in time, so it gave its hold back.
1214
+ * @description `expired`: nobody committed or released it in time, so it released itself.
1205
1215
  * @enum {string}
1206
1216
  */
1207
1217
  status: "held" | "committed" | "released" | "expired";
@@ -1222,10 +1232,10 @@ export interface components {
1222
1232
  };
1223
1233
  Subject: {
1224
1234
  /**
1225
- * @description When its `anchor` limits' periods start from: its billing date, else its first counted check. Null until it has one.
1235
+ * @description When its `billing_date` limits' periods start from: the billing date you set, else its first counted check. Null until it has one.
1226
1236
  * @example 2026-03-17T14:30:00.000Z
1227
1237
  */
1228
- anchor: string | null;
1238
+ billingDate: string | null;
1229
1239
  subject: components["schemas"]["SubjectRef"];
1230
1240
  };
1231
1241
  SubjectRef: {
@@ -1235,12 +1245,12 @@ export interface components {
1235
1245
  SubjectReset: {
1236
1246
  /**
1237
1247
  * @description Just this limit. Default: every limit on the subject.
1238
- * @example lim_3f0c…
1248
+ * @example lmt_3f0c…
1239
1249
  */
1240
1250
  limitId?: string;
1241
1251
  };
1242
1252
  SubjectResetResult: {
1243
- /** @description The limits that were refilled. */
1253
+ /** @description The limits that were reset. */
1244
1254
  reset: string[];
1245
1255
  subject: components["schemas"]["SubjectRef"];
1246
1256
  };
@@ -1250,7 +1260,7 @@ export interface components {
1250
1260
  * @description The date and time its periods start from (ISO 8601), such as a subscription's start.
1251
1261
  * @example 2026-03-17T14:30:00Z
1252
1262
  */
1253
- anchor: string;
1263
+ billingDate: string;
1254
1264
  };
1255
1265
  Team: {
1256
1266
  /** @example 2026-08-19T12:00:00.000Z */
@@ -1269,8 +1279,8 @@ export interface components {
1269
1279
  };
1270
1280
  UsageBySubject: {
1271
1281
  items: {
1272
- denied: number;
1273
- over: boolean;
1282
+ /** @description Checks this limit refused in the window. */
1283
+ refused: number;
1274
1284
  remaining: number;
1275
1285
  subject: {
1276
1286
  id: string;
@@ -1287,7 +1297,7 @@ export interface components {
1287
1297
  limitId: string;
1288
1298
  points: {
1289
1299
  allowed: number;
1290
- denied: number;
1300
+ refused: number;
1291
1301
  start: string;
1292
1302
  used: number;
1293
1303
  }[];
@@ -1298,9 +1308,9 @@ export interface components {
1298
1308
  limits: {
1299
1309
  action: string;
1300
1310
  amount: number;
1301
- limit: string;
1311
+ limitId: string;
1302
1312
  name: string;
1303
- /** @description A balance's can exceed `amount` once credits are granted. */
1313
+ /** @description A balance's can exceed `amount` once credits are added. */
1304
1314
  remaining: number;
1305
1315
  resetsAt: string | null;
1306
1316
  rolling: boolean;
@@ -1624,7 +1634,7 @@ export interface operations {
1624
1634
  "application/json": components["schemas"]["Limit"];
1625
1635
  };
1626
1636
  };
1627
- /** @description Invalid request, such as a duplicate name (code: invalid_request). */
1637
+ /** @description Invalid request, such as a change to a field fixed once the limit is created (code: invalid_request). */
1628
1638
  400: {
1629
1639
  headers: {
1630
1640
  [name: string]: unknown;
@@ -1651,6 +1661,15 @@ export interface operations {
1651
1661
  "application/json": components["schemas"]["ErrorEnvelope"];
1652
1662
  };
1653
1663
  };
1664
+ /** @description An active limit already has this name — or, with no `name` sent, the one the limit would get (code: invalid_request): send a `name` of its own. */
1665
+ 409: {
1666
+ headers: {
1667
+ [name: string]: unknown;
1668
+ };
1669
+ content: {
1670
+ "application/json": components["schemas"]["ErrorEnvelope"];
1671
+ };
1672
+ };
1654
1673
  /** @description Per-key quota exhausted (code: rate_limited); retry after the Retry-After header. */
1655
1674
  429: {
1656
1675
  headers: {
@@ -1754,7 +1773,7 @@ export interface operations {
1754
1773
  "application/json": components["schemas"]["Limit"];
1755
1774
  };
1756
1775
  };
1757
- /** @description Invalid request, such as a duplicate name (code: invalid_request). */
1776
+ /** @description Invalid request, such as a change to a field fixed once the limit is created (code: invalid_request). */
1758
1777
  400: {
1759
1778
  headers: {
1760
1779
  [name: string]: unknown;
@@ -1790,6 +1809,15 @@ export interface operations {
1790
1809
  "application/json": components["schemas"]["ErrorEnvelope"];
1791
1810
  };
1792
1811
  };
1812
+ /** @description An active limit already has this name — or, with no `name` sent, the one the limit would get (code: invalid_request): send a `name` of its own. */
1813
+ 409: {
1814
+ headers: {
1815
+ [name: string]: unknown;
1816
+ };
1817
+ content: {
1818
+ "application/json": components["schemas"]["ErrorEnvelope"];
1819
+ };
1820
+ };
1793
1821
  /** @description Per-key quota exhausted (code: rate_limited); retry after the Retry-After header. */
1794
1822
  429: {
1795
1823
  headers: {
@@ -1862,7 +1890,7 @@ export interface operations {
1862
1890
  };
1863
1891
  };
1864
1892
  };
1865
- "limits.grants.list": {
1893
+ "limits.credits.list": {
1866
1894
  parameters: {
1867
1895
  query?: never;
1868
1896
  header?: {
@@ -1878,14 +1906,14 @@ export interface operations {
1878
1906
  };
1879
1907
  requestBody?: never;
1880
1908
  responses: {
1881
- /** @description The grants. */
1909
+ /** @description The credits. */
1882
1910
  200: {
1883
1911
  headers: {
1884
1912
  [name: string]: unknown;
1885
1913
  };
1886
1914
  content: {
1887
1915
  "application/json": {
1888
- items: components["schemas"]["LimitGrant"][];
1916
+ items: components["schemas"]["Credit"][];
1889
1917
  };
1890
1918
  };
1891
1919
  };
@@ -1927,7 +1955,7 @@ export interface operations {
1927
1955
  };
1928
1956
  };
1929
1957
  };
1930
- "limits.grants.create": {
1958
+ "limits.credits.create": {
1931
1959
  parameters: {
1932
1960
  query?: never;
1933
1961
  header?: {
@@ -1943,20 +1971,20 @@ export interface operations {
1943
1971
  };
1944
1972
  requestBody: {
1945
1973
  content: {
1946
- "application/json": components["schemas"]["LimitGrantInput"];
1974
+ "application/json": components["schemas"]["CreditInput"];
1947
1975
  };
1948
1976
  };
1949
1977
  responses: {
1950
- /** @description The grant — the balance is raised. */
1978
+ /** @description The credit — the balance is raised. */
1951
1979
  201: {
1952
1980
  headers: {
1953
1981
  [name: string]: unknown;
1954
1982
  };
1955
1983
  content: {
1956
- "application/json": components["schemas"]["LimitGrant"];
1984
+ "application/json": components["schemas"]["Credit"];
1957
1985
  };
1958
1986
  };
1959
- /** @description Invalid request, such as a duplicate name (code: invalid_request). */
1987
+ /** @description Invalid request, such as a change to a field fixed once the limit is created (code: invalid_request). */
1960
1988
  400: {
1961
1989
  headers: {
1962
1990
  [name: string]: unknown;
@@ -2037,7 +2065,7 @@ export interface operations {
2037
2065
  "application/json": components["schemas"]["Limit"];
2038
2066
  };
2039
2067
  };
2040
- /** @description Invalid request, such as a duplicate name (code: invalid_request). */
2068
+ /** @description Invalid request, such as a change to a field fixed once the limit is created (code: invalid_request). */
2041
2069
  400: {
2042
2070
  headers: {
2043
2071
  [name: string]: unknown;
@@ -2102,7 +2130,7 @@ export interface operations {
2102
2130
  };
2103
2131
  };
2104
2132
  responses: {
2105
- /** @description What changed, or with `dryRun`, what would. */
2133
+ /** @description What changed, or with `preview`, what would. */
2106
2134
  200: {
2107
2135
  headers: {
2108
2136
  [name: string]: unknown;
@@ -2111,7 +2139,7 @@ export interface operations {
2111
2139
  "application/json": components["schemas"]["LimitSyncResult"];
2112
2140
  };
2113
2141
  };
2114
- /** @description Something in the list is invalid, such as a name twice; nothing was changed (code: invalid_request, each problem in `details`). */
2142
+ /** @description Something in the list is invalid, such as a name twice or a change to what a limit counts; nothing was changed (code: invalid_request, each problem in `details`). */
2115
2143
  400: {
2116
2144
  headers: {
2117
2145
  [name: string]: unknown;
@@ -2169,7 +2197,7 @@ export interface operations {
2169
2197
  };
2170
2198
  };
2171
2199
  responses: {
2172
- /** @description The reservation, settled. */
2200
+ /** @description The reservation. */
2173
2201
  200: {
2174
2202
  headers: {
2175
2203
  [name: string]: unknown;
@@ -2178,7 +2206,7 @@ export interface operations {
2178
2206
  "application/json": components["schemas"]["Reservation"];
2179
2207
  };
2180
2208
  };
2181
- /** @description Already settled the other way, or an invalid cost (code: invalid_request). */
2209
+ /** @description Already committed or released the other way, or an invalid cost (code: invalid_request). */
2182
2210
  400: {
2183
2211
  headers: {
2184
2212
  [name: string]: unknown;
@@ -2254,7 +2282,7 @@ export interface operations {
2254
2282
  };
2255
2283
  };
2256
2284
  responses: {
2257
- /** @description The reservation, settled. */
2285
+ /** @description The reservation. */
2258
2286
  200: {
2259
2287
  headers: {
2260
2288
  [name: string]: unknown;
@@ -2263,7 +2291,7 @@ export interface operations {
2263
2291
  "application/json": components["schemas"]["Reservation"];
2264
2292
  };
2265
2293
  };
2266
- /** @description Already settled the other way, or an invalid cost (code: invalid_request). */
2294
+ /** @description Already committed or released the other way, or an invalid cost (code: invalid_request). */
2267
2295
  400: {
2268
2296
  headers: {
2269
2297
  [name: string]: unknown;
@@ -2335,7 +2363,7 @@ export interface operations {
2335
2363
  };
2336
2364
  requestBody?: never;
2337
2365
  responses: {
2338
- /** @description The reservation, settled. */
2366
+ /** @description The reservation. */
2339
2367
  200: {
2340
2368
  headers: {
2341
2369
  [name: string]: unknown;
@@ -2344,7 +2372,7 @@ export interface operations {
2344
2372
  "application/json": components["schemas"]["Reservation"];
2345
2373
  };
2346
2374
  };
2347
- /** @description Already settled the other way, or an invalid cost (code: invalid_request). */
2375
+ /** @description Already committed or released the other way, or an invalid cost (code: invalid_request). */
2348
2376
  400: {
2349
2377
  headers: {
2350
2378
  [name: string]: unknown;
@@ -2494,7 +2522,7 @@ export interface operations {
2494
2522
  };
2495
2523
  };
2496
2524
  responses: {
2497
- /** @description The subject, with its new anchor. */
2525
+ /** @description The subject, with its new billing date. */
2498
2526
  200: {
2499
2527
  headers: {
2500
2528
  [name: string]: unknown;
@@ -2503,7 +2531,7 @@ export interface operations {
2503
2531
  "application/json": components["schemas"]["Subject"];
2504
2532
  };
2505
2533
  };
2506
- /** @description Invalid anchor (code: invalid_request). */
2534
+ /** @description Invalid billing date (code: invalid_request). */
2507
2535
  400: {
2508
2536
  headers: {
2509
2537
  [name: string]: unknown;
@@ -2636,10 +2664,8 @@ export interface operations {
2636
2664
  granularity?: "hour" | "day";
2637
2665
  /** @description The limit. */
2638
2666
  limitId: string;
2639
- /** @description With `subjectKind`: one subject's usage. */
2640
- subjectId?: string;
2641
- /** @description With `subjectId`: one subject's usage, not every subject's. */
2642
- subjectKind?: string;
2667
+ /** @description One subject's usage, not every subject's, as `kind:id`. */
2668
+ subject?: string;
2643
2669
  /** @description End of the range (ISO 8601). Default: now. */
2644
2670
  to?: string;
2645
2671
  };
@@ -2713,12 +2739,10 @@ export interface operations {
2713
2739
  "usage.standing": {
2714
2740
  parameters: {
2715
2741
  query: {
2716
- /** @description The subject's id, as your checks send it. */
2717
- id: string;
2718
- /** @description The subject's kind, as your checks send it. */
2719
- kind: string;
2720
2742
  /** @description Shared subjects to include, comma-separated `kind:id` (up to 4). */
2721
2743
  shared?: string;
2744
+ /** @description The subject, as `kind:id`: its kind and id as your checks send them. */
2745
+ subject: string;
2722
2746
  };
2723
2747
  header?: {
2724
2748
  /** @description The environment the request acts in; without it, the product's default. An API key bound to an environment always acts in its own (403 naming another); an unknown environment is 400. */