Skip to main content
POST
/
api
/
v1
/
credits
/
grants
JavaScript
import Stigg from '@stigg/typescript';

const client = new Stigg({
  apiKey: process.env['STIGG_API_KEY'], // This is the default and can be omitted
});

const creditGrantResponse = await client.v1.events.credits.grants.create({
  amount: 0,
  currencyId: 'currencyId',
  customerId: 'customerId',
  displayName: 'displayName',
  grantType: 'PAID',
});

console.log(creditGrantResponse.data);
{
  "data": {
    "id": "cred-grant-abc123",
    "displayName": "Monthly credits",
    "amount": 1000,
    "consumedAmount": 250,
    "grantType": "PROMOTIONAL",
    "sourceType": null,
    "priority": 1,
    "effectiveAt": "2024-01-01T00:00:00.000Z",
    "expireAt": "2024-12-31T23:59:59.000Z",
    "voidedAt": null,
    "metadata": {},
    "cost": {
      "amount": 0,
      "currency": "usd"
    },
    "comment": null,
    "customerId": "customer-123",
    "resourceId": null,
    "currencyId": "credits",
    "invoiceId": null,
    "latestInvoice": null,
    "paymentCollection": "NOT_REQUIRED",
    "status": "ACTIVE",
    "createdAt": "2027-02-01T03:53:44.800Z",
    "updatedAt": "2027-02-01T03:53:44.801Z"
  }
}

Authorizations

X-API-KEY
string
header
required

Server API Key

Body

application/json

Request body for creating a credit grant

displayName
string
required

The display name for the credit grant

Maximum string length: 255
amount
number
required

The credit amount to grant

grantType
enum<string>
required

The type of credit grant (PAID, PROMOTIONAL, RECURRING)

Available options:
PAID,
PROMOTIONAL,
RECURRING,
OVERDRAFT
customerId
string
required

The customer ID to grant credits to (required)

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.@-]*$
currencyId
string
required

The credit currency ID (required)

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
priority
integer

The priority of the credit grant (lower number = higher priority)

Required range: 0 <= x <= 100
effectiveAt
string<date-time>

The date when the credit grant becomes effective

expireAt
string<date-time>

The date when the credit grant expires

metadata
object

Additional metadata for the credit grant

cost
Money · object

The monetary cost of the credit grant

comment
string

An optional comment on the credit grant

Maximum string length: 255
resourceId
string

The resource ID to scope the grant to

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
paymentCollectionMethod
enum<string>

The payment collection method (CHARGE, INVOICE, NONE)

Available options:
CHARGE,
INVOICE,
NONE
awaitPaymentConfirmation
boolean

Whether to wait for payment confirmation before returning (default: true)

billingInformation
CreditGrantBillingInfo · object

Billing information for the credit grant

Response

The newly created credit grant object.

Response object

data
CreditGrant · object
required

Credit grant object representing allocated credits for a customer