Skip to content
Docs

Purchase credits

POSThttps://api.vercel.com/v1/billing/buy
Purchases credits for a Vercel team using the default payment method on file. The purchase is charged immediately via Stripe invoice. Supported credit types are v0, gateway, and agent. The amount field specifies the number of credits to purchase and must be a positive integer. An optional source query parameter can be provided to identify the caller. Defaults to api if not specified. This is only available for Owner, Member, Developer, Security, and Billing roles for the supplied team.
Request
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.billing.buyCredits({
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
requestBody: {
item: {
type: "credits",
creditType: "agent",
amount: 890808,
},
},
});
console.log(result);
}
run();
Response
{
"checkoutSessionId": "example_id",
"checkoutSessionUrl": "https://example.com"
}
AuthorizationbearerToken

Default authentication mechanism

sourcestringOptional
The source of the purchase request. Defaults to api if not specified.
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
itemobjectRequired
200Success
checkoutSessionIdstringRequired
checkoutSessionUrlstringRequired
400One of the provided values in the request query is invalid.
401The request is not authorized.
402Error
403You do not have permission to access this resource.
404Error
409Error
410Error
500Error