@limitry/sdk 1.0.0-rc.6 → 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,16 +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;
783
+ /**
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`.
785
+ * @example Refused by AI replies per day: 0 replies left, resets 2026-11-01T00:00:00.000Z. Try again in 3600 s.
786
+ */
787
+ message: string;
781
788
  } | null;
782
- /** @description Every limit that applied, and what is left in its window. */
783
- remaining: components["schemas"]["CheckRemaining"][];
784
- /** @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. */
785
790
  reservation?: {
786
791
  expiresAt: string;
787
792
  /** @example rsv_WyJ1c2VyIiwidV80MiJd_9f… */
@@ -790,14 +795,14 @@ export interface components {
790
795
  /** @description When `allowed` is false: seconds until it could be allowed. */
791
796
  retryAfterSeconds: number | null;
792
797
  };
793
- CheckRemaining: {
798
+ CheckLimit: {
794
799
  /**
795
800
  * @description What to do if Limitry cannot be reached next time: `open` allows, `closed` denies. SDKs remember it.
796
801
  * @enum {string}
797
802
  */
798
803
  failMode: "open" | "closed";
799
- /** @example lim_3f0c… */
800
- limit: string;
804
+ /** @example lmt_3f0c… */
805
+ limitId: string;
801
806
  /** @example AI budget */
802
807
  name: string;
803
808
  /** @example 195 */
@@ -826,7 +831,7 @@ export interface components {
826
831
  */
827
832
  cost?: number;
828
833
  /**
829
- * @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.
830
835
  * @example consume
831
836
  * @enum {string}
832
837
  */
@@ -846,7 +851,7 @@ export interface components {
846
851
  }[];
847
852
  subject: components["schemas"]["CheckSubject"];
848
853
  /**
849
- * @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.
850
855
  * @example 300
851
856
  */
852
857
  ttlSeconds?: number;
@@ -864,6 +869,42 @@ export interface components {
864
869
  */
865
870
  kind: string;
866
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
+ };
867
908
  ErrorEnvelope: {
868
909
  error: {
869
910
  /** @example unauthorized */
@@ -910,7 +951,7 @@ export interface components {
910
951
  * @example 200
911
952
  */
912
953
  amount: number;
913
- /** @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. */
914
955
  archivedAt: string | null;
915
956
  /** @example 2026-10-04T12:00:00.000Z */
916
957
  createdAt: string;
@@ -926,18 +967,23 @@ export interface components {
926
967
  * @enum {string}
927
968
  */
928
969
  failMode: "open" | "closed";
929
- /** @example lim_3f0c… */
970
+ /** @example lmt_3f0c… */
930
971
  id: string;
931
- /** @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 */
932
978
  name: string;
933
979
  /** @description Counts the last minute, hour or day at the moment of the check instead of the calendar window. */
934
980
  rolling: boolean;
935
981
  /**
936
- * @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.
937
983
  * @example calendar
938
984
  * @enum {string}
939
985
  */
940
- start: "calendar" | "anchor" | "first_use";
986
+ start: "calendar" | "billing_date" | "first_use";
941
987
  subject: components["schemas"]["LimitSubject"];
942
988
  /** @example cents */
943
989
  unit: string;
@@ -946,54 +992,18 @@ export interface components {
946
992
  /** @description Increases on every change. */
947
993
  version: number;
948
994
  /**
949
- * @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.
950
996
  * @example month
951
997
  * @enum {string}
952
998
  */
953
999
  window: "minute" | "hour" | "day" | "week" | "month" | "year" | "total" | "concurrent";
954
1000
  };
955
- LimitGrant: {
956
- amount: number;
957
- createdAt: string;
958
- createdByUserId: string | null;
959
- /** @example grt_… */
960
- id: string;
961
- limitId: string;
962
- note: string;
963
- subject: {
964
- id: string;
965
- kind: string;
966
- };
967
- };
968
- LimitGrantInput: {
969
- /**
970
- * @description Credits to add; negative to take them back. Not 0.
971
- * @example 5000
972
- */
973
- amount: number;
974
- /**
975
- * @description Required when `amount` is negative.
976
- * @example October top-up
977
- */
978
- note?: string;
979
- /**
980
- * @description Who gets the credits, as `{"kind": "team", "id": "team_42"}`.
981
- * @example {
982
- * "kind": "team",
983
- * "id": "team_42"
984
- * }
985
- */
986
- subject: {
987
- id: string;
988
- kind: string;
989
- };
990
- };
991
1001
  LimitInput: {
992
1002
  /**
993
- * @description The action to limit; `*` for every action.
1003
+ * @description The action to limit. Default: `*`, every action.
994
1004
  * @example ai-call
995
1005
  */
996
- action: string;
1006
+ action?: string;
997
1007
  /**
998
1008
  * @description How many units each subject may use per window.
999
1009
  * @example 200
@@ -1012,93 +1022,89 @@ export interface components {
1012
1022
  */
1013
1023
  failMode?: "open" | "closed";
1014
1024
  /**
1015
- * @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.
1016
1026
  * @example AI budget
1017
1027
  */
1018
- name: string;
1028
+ name?: string;
1019
1029
  /** @description Count the last window instead of the calendar one (minute, hour or day only). Default: false. */
1020
1030
  rolling?: boolean;
1021
1031
  /**
1022
- * @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.
1023
1033
  * @example calendar
1024
1034
  * @enum {string}
1025
1035
  */
1026
- start?: "calendar" | "anchor" | "first_use";
1027
- /** @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. */
1028
- subjectId?: string | null;
1036
+ start?: "calendar" | "billing_date" | "first_use";
1037
+ subject: components["schemas"]["LimitInputSubject"];
1029
1038
  /**
1030
- * @description Your own label for who is checked.
1031
- * @example user
1032
- */
1033
- subjectKind: string;
1034
- /**
1035
- * @description What the amount counts (display only). Default: units.
1039
+ * @description What the amount counts, in words. Default: units.
1036
1040
  * @example cents
1037
1041
  */
1038
1042
  unit?: string;
1039
1043
  /**
1040
- * @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.
1041
1045
  * @example month
1042
1046
  * @enum {string}
1043
1047
  */
1044
1048
  window: "minute" | "hour" | "day" | "week" | "month" | "year" | "total" | "concurrent";
1045
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
+ };
1046
1060
  LimitPage: {
1047
1061
  items: components["schemas"]["Limit"][];
1048
1062
  /** @description Pass as ?cursor= to fetch the next page. */
1049
1063
  nextCursor: string | null;
1050
1064
  };
1051
1065
  LimitPatch: {
1052
- /**
1053
- * @description The action to limit; `*` for every action.
1054
- * @example ai-call
1055
- */
1066
+ /** @description The action. Fixed once the limit is created: to change it, create a new limit and archive this one. */
1056
1067
  action?: string;
1057
1068
  /**
1058
1069
  * @description How many units each subject may use per window.
1059
- * @example 200
1070
+ * @example 300
1060
1071
  */
1061
1072
  amount?: number;
1062
- /** @description Whether checks enforce it. Default: true. */
1073
+ /** @description Whether checks enforce it. */
1063
1074
  enabled?: boolean;
1064
- /**
1065
- * @description How many `window` units a period lasts: `window: "month", every: 3` is a quarter, `window: "hour", every: 5` five hours. Default: 1.
1066
- * @example 1
1067
- */
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. */
1068
1076
  every?: number;
1069
1077
  /**
1070
- * @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).
1071
1079
  * @enum {string}
1072
1080
  */
1073
1081
  failMode?: "open" | "closed";
1074
1082
  /**
1075
- * @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.
1076
1084
  * @example AI budget
1077
1085
  */
1078
1086
  name?: string;
1079
- /** @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. */
1080
1088
  rolling?: boolean;
1081
1089
  /**
1082
- * @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.
1083
- * @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.
1084
1091
  * @enum {string}
1085
1092
  */
1086
- start?: "calendar" | "anchor" | "first_use";
1087
- /** @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. */
1088
- subjectId?: string | null;
1089
- /**
1090
- * @description Your own label for who is checked.
1091
- * @example user
1092
- */
1093
- subjectKind?: string;
1094
- /**
1095
- * @description What the amount counts (display only). Default: units.
1096
- * @example cents
1097
- */
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. */
1098
1105
  unit?: string;
1099
1106
  /**
1100
- * @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.
1101
- * @example month
1107
+ * @description The window. Fixed once the limit is created: to change it, create a new limit and archive this one.
1102
1108
  * @enum {string}
1103
1109
  */
1104
1110
  window?: "minute" | "hour" | "day" | "week" | "month" | "year" | "total" | "concurrent";
@@ -1115,17 +1121,24 @@ export interface components {
1115
1121
  */
1116
1122
  kind: string;
1117
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
+ };
1118
1131
  LimitSyncInput: {
1119
1132
  /** @description Archive the environment's active limits whose names aren't in `limits` (restorable). Default: false, which leaves them alone. */
1120
1133
  archiveMissing?: boolean;
1121
- /** @description Answer what the sync would do and change nothing. Default: false. */
1122
- dryRun?: boolean;
1123
1134
  /**
1124
- * @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.
1125
1136
  * @example [
1126
1137
  * {
1127
1138
  * "name": "AI budget",
1128
- * "subjectKind": "user",
1139
+ * "subject": {
1140
+ * "kind": "user"
1141
+ * },
1129
1142
  * "action": "ai-call",
1130
1143
  * "amount": 200,
1131
1144
  * "unit": "cents",
@@ -1133,7 +1146,9 @@ export interface components {
1133
1146
  * }
1134
1147
  * ]
1135
1148
  */
1136
- 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;
1137
1152
  };
1138
1153
  LimitSyncResult: {
1139
1154
  /** @description Names of the limits archived (with `archiveMissing`). */
@@ -1145,8 +1160,8 @@ export interface components {
1145
1160
  * ]
1146
1161
  */
1147
1162
  created: string[];
1148
- /** @description True when nothing was written: this is the plan. */
1149
- dryRun: boolean;
1163
+ /** @description True when nothing was written: this is what a sync would do. */
1164
+ preview: boolean;
1150
1165
  /** @description Names of the limits that already matched. */
1151
1166
  unchanged: string[];
1152
1167
  /** @description The limits changed, field by field. */
@@ -1193,10 +1208,10 @@ export interface components {
1193
1208
  cost: number;
1194
1209
  expiresAt: string;
1195
1210
  id: string;
1196
- /** @description The amount held. */
1211
+ /** @description The amount reserved. */
1197
1212
  reserved: number;
1198
1213
  /**
1199
- * @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.
1200
1215
  * @enum {string}
1201
1216
  */
1202
1217
  status: "held" | "committed" | "released" | "expired";
@@ -1217,10 +1232,10 @@ export interface components {
1217
1232
  };
1218
1233
  Subject: {
1219
1234
  /**
1220
- * @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.
1221
1236
  * @example 2026-03-17T14:30:00.000Z
1222
1237
  */
1223
- anchor: string | null;
1238
+ billingDate: string | null;
1224
1239
  subject: components["schemas"]["SubjectRef"];
1225
1240
  };
1226
1241
  SubjectRef: {
@@ -1230,12 +1245,12 @@ export interface components {
1230
1245
  SubjectReset: {
1231
1246
  /**
1232
1247
  * @description Just this limit. Default: every limit on the subject.
1233
- * @example lim_3f0c…
1248
+ * @example lmt_3f0c…
1234
1249
  */
1235
1250
  limitId?: string;
1236
1251
  };
1237
1252
  SubjectResetResult: {
1238
- /** @description The limits that were refilled. */
1253
+ /** @description The limits that were reset. */
1239
1254
  reset: string[];
1240
1255
  subject: components["schemas"]["SubjectRef"];
1241
1256
  };
@@ -1245,7 +1260,7 @@ export interface components {
1245
1260
  * @description The date and time its periods start from (ISO 8601), such as a subscription's start.
1246
1261
  * @example 2026-03-17T14:30:00Z
1247
1262
  */
1248
- anchor: string;
1263
+ billingDate: string;
1249
1264
  };
1250
1265
  Team: {
1251
1266
  /** @example 2026-08-19T12:00:00.000Z */
@@ -1264,8 +1279,8 @@ export interface components {
1264
1279
  };
1265
1280
  UsageBySubject: {
1266
1281
  items: {
1267
- denied: number;
1268
- over: boolean;
1282
+ /** @description Checks this limit refused in the window. */
1283
+ refused: number;
1269
1284
  remaining: number;
1270
1285
  subject: {
1271
1286
  id: string;
@@ -1282,7 +1297,7 @@ export interface components {
1282
1297
  limitId: string;
1283
1298
  points: {
1284
1299
  allowed: number;
1285
- denied: number;
1300
+ refused: number;
1286
1301
  start: string;
1287
1302
  used: number;
1288
1303
  }[];
@@ -1293,9 +1308,9 @@ export interface components {
1293
1308
  limits: {
1294
1309
  action: string;
1295
1310
  amount: number;
1296
- limit: string;
1311
+ limitId: string;
1297
1312
  name: string;
1298
- /** @description A balance's can exceed `amount` once credits are granted. */
1313
+ /** @description A balance's can exceed `amount` once credits are added. */
1299
1314
  remaining: number;
1300
1315
  resetsAt: string | null;
1301
1316
  rolling: boolean;
@@ -1619,7 +1634,7 @@ export interface operations {
1619
1634
  "application/json": components["schemas"]["Limit"];
1620
1635
  };
1621
1636
  };
1622
- /** @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). */
1623
1638
  400: {
1624
1639
  headers: {
1625
1640
  [name: string]: unknown;
@@ -1646,6 +1661,15 @@ export interface operations {
1646
1661
  "application/json": components["schemas"]["ErrorEnvelope"];
1647
1662
  };
1648
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
+ };
1649
1673
  /** @description Per-key quota exhausted (code: rate_limited); retry after the Retry-After header. */
1650
1674
  429: {
1651
1675
  headers: {
@@ -1749,7 +1773,7 @@ export interface operations {
1749
1773
  "application/json": components["schemas"]["Limit"];
1750
1774
  };
1751
1775
  };
1752
- /** @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). */
1753
1777
  400: {
1754
1778
  headers: {
1755
1779
  [name: string]: unknown;
@@ -1785,6 +1809,15 @@ export interface operations {
1785
1809
  "application/json": components["schemas"]["ErrorEnvelope"];
1786
1810
  };
1787
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
+ };
1788
1821
  /** @description Per-key quota exhausted (code: rate_limited); retry after the Retry-After header. */
1789
1822
  429: {
1790
1823
  headers: {
@@ -1857,7 +1890,7 @@ export interface operations {
1857
1890
  };
1858
1891
  };
1859
1892
  };
1860
- "limits.grants.list": {
1893
+ "limits.credits.list": {
1861
1894
  parameters: {
1862
1895
  query?: never;
1863
1896
  header?: {
@@ -1873,14 +1906,14 @@ export interface operations {
1873
1906
  };
1874
1907
  requestBody?: never;
1875
1908
  responses: {
1876
- /** @description The grants. */
1909
+ /** @description The credits. */
1877
1910
  200: {
1878
1911
  headers: {
1879
1912
  [name: string]: unknown;
1880
1913
  };
1881
1914
  content: {
1882
1915
  "application/json": {
1883
- items: components["schemas"]["LimitGrant"][];
1916
+ items: components["schemas"]["Credit"][];
1884
1917
  };
1885
1918
  };
1886
1919
  };
@@ -1922,7 +1955,7 @@ export interface operations {
1922
1955
  };
1923
1956
  };
1924
1957
  };
1925
- "limits.grants.create": {
1958
+ "limits.credits.create": {
1926
1959
  parameters: {
1927
1960
  query?: never;
1928
1961
  header?: {
@@ -1938,20 +1971,20 @@ export interface operations {
1938
1971
  };
1939
1972
  requestBody: {
1940
1973
  content: {
1941
- "application/json": components["schemas"]["LimitGrantInput"];
1974
+ "application/json": components["schemas"]["CreditInput"];
1942
1975
  };
1943
1976
  };
1944
1977
  responses: {
1945
- /** @description The grant — the balance is raised. */
1978
+ /** @description The credit — the balance is raised. */
1946
1979
  201: {
1947
1980
  headers: {
1948
1981
  [name: string]: unknown;
1949
1982
  };
1950
1983
  content: {
1951
- "application/json": components["schemas"]["LimitGrant"];
1984
+ "application/json": components["schemas"]["Credit"];
1952
1985
  };
1953
1986
  };
1954
- /** @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). */
1955
1988
  400: {
1956
1989
  headers: {
1957
1990
  [name: string]: unknown;
@@ -2032,7 +2065,7 @@ export interface operations {
2032
2065
  "application/json": components["schemas"]["Limit"];
2033
2066
  };
2034
2067
  };
2035
- /** @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). */
2036
2069
  400: {
2037
2070
  headers: {
2038
2071
  [name: string]: unknown;
@@ -2097,7 +2130,7 @@ export interface operations {
2097
2130
  };
2098
2131
  };
2099
2132
  responses: {
2100
- /** @description What changed, or with `dryRun`, what would. */
2133
+ /** @description What changed, or with `preview`, what would. */
2101
2134
  200: {
2102
2135
  headers: {
2103
2136
  [name: string]: unknown;
@@ -2106,7 +2139,7 @@ export interface operations {
2106
2139
  "application/json": components["schemas"]["LimitSyncResult"];
2107
2140
  };
2108
2141
  };
2109
- /** @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`). */
2110
2143
  400: {
2111
2144
  headers: {
2112
2145
  [name: string]: unknown;
@@ -2164,7 +2197,7 @@ export interface operations {
2164
2197
  };
2165
2198
  };
2166
2199
  responses: {
2167
- /** @description The reservation, settled. */
2200
+ /** @description The reservation. */
2168
2201
  200: {
2169
2202
  headers: {
2170
2203
  [name: string]: unknown;
@@ -2173,7 +2206,7 @@ export interface operations {
2173
2206
  "application/json": components["schemas"]["Reservation"];
2174
2207
  };
2175
2208
  };
2176
- /** @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). */
2177
2210
  400: {
2178
2211
  headers: {
2179
2212
  [name: string]: unknown;
@@ -2249,7 +2282,7 @@ export interface operations {
2249
2282
  };
2250
2283
  };
2251
2284
  responses: {
2252
- /** @description The reservation, settled. */
2285
+ /** @description The reservation. */
2253
2286
  200: {
2254
2287
  headers: {
2255
2288
  [name: string]: unknown;
@@ -2258,7 +2291,7 @@ export interface operations {
2258
2291
  "application/json": components["schemas"]["Reservation"];
2259
2292
  };
2260
2293
  };
2261
- /** @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). */
2262
2295
  400: {
2263
2296
  headers: {
2264
2297
  [name: string]: unknown;
@@ -2330,7 +2363,7 @@ export interface operations {
2330
2363
  };
2331
2364
  requestBody?: never;
2332
2365
  responses: {
2333
- /** @description The reservation, settled. */
2366
+ /** @description The reservation. */
2334
2367
  200: {
2335
2368
  headers: {
2336
2369
  [name: string]: unknown;
@@ -2339,7 +2372,7 @@ export interface operations {
2339
2372
  "application/json": components["schemas"]["Reservation"];
2340
2373
  };
2341
2374
  };
2342
- /** @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). */
2343
2376
  400: {
2344
2377
  headers: {
2345
2378
  [name: string]: unknown;
@@ -2489,7 +2522,7 @@ export interface operations {
2489
2522
  };
2490
2523
  };
2491
2524
  responses: {
2492
- /** @description The subject, with its new anchor. */
2525
+ /** @description The subject, with its new billing date. */
2493
2526
  200: {
2494
2527
  headers: {
2495
2528
  [name: string]: unknown;
@@ -2498,7 +2531,7 @@ export interface operations {
2498
2531
  "application/json": components["schemas"]["Subject"];
2499
2532
  };
2500
2533
  };
2501
- /** @description Invalid anchor (code: invalid_request). */
2534
+ /** @description Invalid billing date (code: invalid_request). */
2502
2535
  400: {
2503
2536
  headers: {
2504
2537
  [name: string]: unknown;
@@ -2631,10 +2664,8 @@ export interface operations {
2631
2664
  granularity?: "hour" | "day";
2632
2665
  /** @description The limit. */
2633
2666
  limitId: string;
2634
- /** @description With `subjectKind`: one subject's usage. */
2635
- subjectId?: string;
2636
- /** @description With `subjectId`: one subject's usage, not every subject's. */
2637
- subjectKind?: string;
2667
+ /** @description One subject's usage, not every subject's, as `kind:id`. */
2668
+ subject?: string;
2638
2669
  /** @description End of the range (ISO 8601). Default: now. */
2639
2670
  to?: string;
2640
2671
  };
@@ -2708,12 +2739,10 @@ export interface operations {
2708
2739
  "usage.standing": {
2709
2740
  parameters: {
2710
2741
  query: {
2711
- /** @description The subject's id, as your checks send it. */
2712
- id: string;
2713
- /** @description The subject's kind, as your checks send it. */
2714
- kind: string;
2715
2742
  /** @description Shared subjects to include, comma-separated `kind:id` (up to 4). */
2716
2743
  shared?: string;
2744
+ /** @description The subject, as `kind:id`: its kind and id as your checks send them. */
2745
+ subject: string;
2717
2746
  };
2718
2747
  header?: {
2719
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. */