@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
34 lines • 2.3 kB
TypeScript
import { UnkeyCore } from "../core.js";
import { RequestOptions } from "../lib/sdks.js";
import * as components from "../models/components/index.js";
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
import * as errors from "../models/errors/index.js";
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
import { UnkeyError } from "../models/errors/unkeyerror.js";
import { APIPromise } from "../types/async.js";
import { Result } from "../types/fp.js";
/**
* Update key credits
*
* @remarks
* Update credit quotas in response to plan changes, billing cycles, or usage purchases.
*
* Use this for user upgrades/downgrades, monthly quota resets, credit purchases, or promotional bonuses. Supports three operations: set, increment, or decrement credits. Set to null for unlimited usage.
*
* **Important**: Setting unlimited credits automatically clears existing refill configurations.
*
* **Required Permissions**
*
* Your root key must have one of the following permissions:
* - `api.*.update_key` (to update keys in any API)
* - `api.<api_id>.update_key` (to update keys in a specific API)
*
* **Side Effects**
*
* Credit updates remove the key from cache immediately. Setting credits to unlimited automatically clears any existing refill settings. Changes take effect instantly but may take up to 30 seconds to propagate to all edge regions.
*
* If set, this operation will use {@link Security.rootKey} from the global security.
*/
export declare function keysUpdateCredits(client: UnkeyCore, request: components.V2KeysUpdateCreditsRequestBody, options?: RequestOptions): APIPromise<Result<components.V2KeysUpdateCreditsResponseBody, errors.BadRequestErrorResponse | errors.UnauthorizedErrorResponse | errors.ForbiddenErrorResponse | errors.NotFoundErrorResponse | errors.TooManyRequestsErrorResponse | errors.InternalServerErrorResponse | UnkeyError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
//# sourceMappingURL=keysUpdateCredits.d.ts.map