cURL
curl --request POST \
--url https://commet.co/api/v1/subscriptions/{id}/credits \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"creditPackId": "<string>",
"quantity": "<unknown>"
}
'import { Commet } from "@commet/node";
const commet = new Commet({ apiKey: "ck_xxx" });
const creditGrant = await commet.subscriptions.purchaseCredits({
id: "sub_xxx",
creditPackId: "cpk_xxx",
});from commet import Commet
commet = Commet("ck_xxx")
credit_grant = commet.subscriptions.purchase_credits(
"sub_xxx",
credit_pack_id="cpk_xxx",
)client, err := commet.New("ck_xxx")
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
creditGrant, err := client.Subscriptions.PurchaseCredits(ctx, "sub_xxx", &commet.PurchaseCreditsParams{
CreditPackID: "cpk_xxx",
})
if err != nil {
log.Fatal(err)
}import co.commet.Commet;
import co.commet.params.PurchaseCreditsParams;
var commet = Commet.builder().apiKey("ck_xxx").build();
var creditGrant = commet.subscriptions().purchaseCredits(
"sub_xxx",
PurchaseCreditsParams.builder("cpk_xxx").build()
);use Commet\Commet;
$commet = new Commet('ck_xxx');
$creditGrant = $commet->subscriptions->purchaseCredits(
id: 'sub_xxx',
creditPackId: 'cpk_xxx',
);{
"credits": 1000,
"object": "credit_grant",
"livemode": false
}{
"error": {
"type": "validation_error",
"code": "validation_error",
"message": "The request contains an invalid parameter.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/validation_error.md"
}
}{
"error": {
"type": "authentication_error",
"code": "unauthorized",
"message": "A valid API key is required.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/unauthorized.md"
}
}{
"error": {
"type": "billing_error",
"code": "payment_failed",
"message": "The payment could not be completed.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/payment_failed.md"
}
}{
"error": {
"type": "authentication_error",
"code": "forbidden",
"message": "You do not have permission to perform this operation.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/forbidden.md"
}
}{
"error": {
"type": "not_found_error",
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/not_found.md"
}
}{
"error": {
"type": "conflict_error",
"code": "idempotency_in_progress",
"message": "A request with this idempotency key is still being processed.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/idempotency_in_progress.md"
}
}{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "Too many requests. Retry after the interval specified in the Retry-After header.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/rate_limited.md"
}
}{
"error": {
"type": "internal_error",
"code": "internal_error",
"message": "An unexpected error occurred while processing the request.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/internal_error.md"
}
}{
"error": {
"type": "internal_error",
"code": "idempotency_unavailable",
"message": "Idempotency storage is temporarily unavailable. Retry with the same idempotency key.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/idempotency_unavailable.md"
}
}Credit Packs
Purchase credits
Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Charges the saved payment method and adds purchased credits.
POST
/
subscriptions
/
{id}
/
credits
cURL
curl --request POST \
--url https://commet.co/api/v1/subscriptions/{id}/credits \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"creditPackId": "<string>",
"quantity": "<unknown>"
}
'import { Commet } from "@commet/node";
const commet = new Commet({ apiKey: "ck_xxx" });
const creditGrant = await commet.subscriptions.purchaseCredits({
id: "sub_xxx",
creditPackId: "cpk_xxx",
});from commet import Commet
commet = Commet("ck_xxx")
credit_grant = commet.subscriptions.purchase_credits(
"sub_xxx",
credit_pack_id="cpk_xxx",
)client, err := commet.New("ck_xxx")
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
creditGrant, err := client.Subscriptions.PurchaseCredits(ctx, "sub_xxx", &commet.PurchaseCreditsParams{
CreditPackID: "cpk_xxx",
})
if err != nil {
log.Fatal(err)
}import co.commet.Commet;
import co.commet.params.PurchaseCreditsParams;
var commet = Commet.builder().apiKey("ck_xxx").build();
var creditGrant = commet.subscriptions().purchaseCredits(
"sub_xxx",
PurchaseCreditsParams.builder("cpk_xxx").build()
);use Commet\Commet;
$commet = new Commet('ck_xxx');
$creditGrant = $commet->subscriptions->purchaseCredits(
id: 'sub_xxx',
creditPackId: 'cpk_xxx',
);{
"credits": 1000,
"object": "credit_grant",
"livemode": false
}{
"error": {
"type": "validation_error",
"code": "validation_error",
"message": "The request contains an invalid parameter.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/validation_error.md"
}
}{
"error": {
"type": "authentication_error",
"code": "unauthorized",
"message": "A valid API key is required.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/unauthorized.md"
}
}{
"error": {
"type": "billing_error",
"code": "payment_failed",
"message": "The payment could not be completed.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/payment_failed.md"
}
}{
"error": {
"type": "authentication_error",
"code": "forbidden",
"message": "You do not have permission to perform this operation.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/forbidden.md"
}
}{
"error": {
"type": "not_found_error",
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/not_found.md"
}
}{
"error": {
"type": "conflict_error",
"code": "idempotency_in_progress",
"message": "A request with this idempotency key is still being processed.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/idempotency_in_progress.md"
}
}{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "Too many requests. Retry after the interval specified in the Retry-After header.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/rate_limited.md"
}
}{
"error": {
"type": "internal_error",
"code": "internal_error",
"message": "An unexpected error occurred while processing the request.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/internal_error.md"
}
}{
"error": {
"type": "internal_error",
"code": "idempotency_unavailable",
"message": "Idempotency storage is temporarily unavailable. Retry with the same idempotency key.",
"doc_url": "https://commet.co/docs/api-reference/2026-08-27/errors/idempotency_unavailable.md"
}
}Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Charges the saved payment method and adds purchased credits.
Authorizations
Headers
Unique key used to safely retry this write for 24 hours without applying it twice.
Required string length:
1 - 200API version used by this reference. Send this header to select this contract explicitly.
Path Parameters
Body
application/json
Was this page helpful?