@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
52 lines • 2.98 kB
TypeScript
import * as z from "zod/v3";
import { OpenEnum } from "../../types/enums.js";
/**
* Defines how to modify the key's remaining credits. Use 'set' to replace current credits with a specific value or unlimited usage, 'increment' to add credits for plan upgrades or credit purchases, and 'decrement' to reduce credits for refunds or policy violations.
*
* @remarks
*/
export declare const Operation: {
readonly Set: "set";
readonly Increment: "increment";
readonly Decrement: "decrement";
};
/**
* Defines how to modify the key's remaining credits. Use 'set' to replace current credits with a specific value or unlimited usage, 'increment' to add credits for plan upgrades or credit purchases, and 'decrement' to reduce credits for refunds or policy violations.
*
* @remarks
*/
export type Operation = OpenEnum<typeof Operation>;
export type V2KeysUpdateCreditsRequestBody = {
/**
* The ID of the key to update (begins with `key_`). This is the database reference ID for the key, not the actual API key string that users authenticate with. This ID uniquely identifies which key's credits will be updated.
*/
keyId: string;
/**
* The credit value to use with the specified operation. The meaning depends on the operation: for 'set', this becomes the new remaining credits value; for 'increment', this amount is added to current credits; for 'decrement', this amount is subtracted from current credits.
*
* @remarks
*
* Set to null when using 'set' operation to make the key unlimited (removes usage restrictions entirely). When decrementing, if the result would be negative, remaining credits are automatically set to zero. Credits are consumed during successful key verification, and when credits reach zero, verification fails with `code=USAGE_EXCEEDED`.
*
* Required when using 'increment' or 'decrement' operations. Optional for 'set' operation (null creates unlimited usage).
*/
value?: number | null | undefined;
/**
* Defines how to modify the key's remaining credits. Use 'set' to replace current credits with a specific value or unlimited usage, 'increment' to add credits for plan upgrades or credit purchases, and 'decrement' to reduce credits for refunds or policy violations.
*
* @remarks
*/
operation: Operation;
};
/** @internal */
export declare const Operation$outboundSchema: z.ZodType<string, z.ZodTypeDef, Operation>;
/** @internal */
export type V2KeysUpdateCreditsRequestBody$Outbound = {
keyId: string;
value?: number | null | undefined;
operation: string;
};
/** @internal */
export declare const V2KeysUpdateCreditsRequestBody$outboundSchema: z.ZodType<V2KeysUpdateCreditsRequestBody$Outbound, z.ZodTypeDef, V2KeysUpdateCreditsRequestBody>;
export declare function v2KeysUpdateCreditsRequestBodyToJSON(v2KeysUpdateCreditsRequestBody: V2KeysUpdateCreditsRequestBody): string;
//# sourceMappingURL=v2keysupdatecreditsrequestbody.d.ts.map