Skip to main content
POST
/
balances
/
debit
JavaScript
import Limitry from '@limitry/sdk';

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

const response = await client.balances.debit({
  amount: 1,
  customerId: 'x',
  description: 'description',
  name: 'x',
});

console.log(response.success);
{
"success": true,
"transaction": {
"id": "txn_abc123",
"balanceId": "bal_xyz",
"type": "debit",
"amount": 100,
"description": "API usage",
"reference": null,
"createdAt": "2024-01-15T10:30:00Z"
},
"balance": {
"id": "bal_xyz",
"projectId": "proj_abc",
"customerId": "cust_123",
"name": "credits",
"unit": "credits",
"currentBalance": 900,
"minimumBalance": 0,
"dimensionFilters": {},
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}
}

Authorizations

Authorization
string
header
required

API Key or Personal Access Token (PAT). When using PAT, include X-Project header.

Body

application/json
customerId
string
required

Customer ID

Minimum string length: 1
name
string
required

Balance name

Minimum string length: 1
amount
number
required

Amount to debit

Required range: x > 0
description
string
required

Transaction description

reference
string

External reference ID

Response

Debit result

success
boolean
required

Whether the transaction succeeded

transaction
object

Transaction details

balance
object

Updated balance

error
string

Error message if failed