comecerodocs

Set up credit

POST
/usage/agreements/{id}/credit_setup

Revision checked credit operation. Secret and trusted tokens require the applicable resource permission. New writes require header idempotency. Immutable rates do not reprice existing agreements. Core validates exact conversion, current funding, prepared work and protected billing boundaries.

Authorization

headerAuthorizationBearer <token>

A secret, trusted or limited token. See Authentication.

Path Parameters

id*string

Resource identity owned by this account and mode.

Header Parameters

Idempotency-Key*string

Same key and canonical body replay the saved result. A different body returns CreditRequestConflict; pending work returns CreditRequestPending.

Match^[ -~]+$
Length1 <= length <= 128

Request Body

application/json
  1. body
expected_revision*integer
Range0 <= value
credit_entitlement_id?string

Existing balance to link, if unambiguous.

metered_entitlement_ids*array<string>
effective_from*string

Whole UTC hour. Volume, gauge and latest changes require the next regular boundary.

Formatdate-time
initial_amount?string

Exact invariant decimal string, at most six decimal places.

Match^(0|[1-9][0-9]*)(\.[0-9]{1,6})?$
initial_credits?string

Exact invariant decimal string, at most six decimal places.

Match^(0|[1-9][0-9]*)(\.[0-9]{1,6})?$
description?string

Merchant note.

Lengthlength <= 200
at_zero?string
Value in"charge""stop"
balance_alerts?

Response Body

Success.

application/json
  1. response
command_id?string
completed?unknown
credit_revision?integer
Range0 <= value
effective_from?string
Formatdate-time
funding_effective_from?string
Formatdate-time
agreement_id?string
credit_entitlement?

A metered entitlement bills a metric on a pinned rate plan version. A credit entitlement holds prepaid credit. See https://docs.comecero.com/docs/usage-billing/entitlements

linked_entitlement_ids?array<string>
old_entitlement_ids?array<string>
replacement_entitlement_ids?array<string>
balance?number
credit_balance?string|null
Example Request
curl -X POST 'https://api.comecero.com/api/v1/usage/agreements/string/credit_setup' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "expected_revision": 0,  "metered_entitlement_ids": [],  "effective_from": "2026-12-01T00:00:00Z",  "initial_credits": "1000"}'
Example Response
{  "agreement_id": "agr_cust_8412",  "credit_revision": 1,  "credit_entitlement": {    "object": "entitlement_grant",    "entitlement_id": "credit_cust_8412",    "kind": "credit",    "billing_agreement_id": "agr_cust_8412",    "metric_id": "met_ai_tokens",    "rate_plan_id": "ai_tokens_standard",    "rate_plan_version": 1,    "funding_source_entitlement_id": "credit_cust_8412",    "overage_policy": "allow",    "drawdown_priority": 0,    "capacity": null,    "status": "active",    "effective_from": "2026-11-01T00:00:00Z",    "effective_to": null,    "customer_id": "cust_8412",    "billing_region": "us",    "test": false  },  "linked_entitlement_ids": [],  "funding_effective_from": "2026-12-01T00:00:00Z",  "balance": 10,  "credit_balance": "1000",  "command_id": "command_setup_1",  "completed": true}