Skip to content

The Wallet & Payments API lets you manage user balances, process payments, issue and download invoices, and maintain payment methods. Use these endpoints to credit general or AI balances, transfer funds between balance types, retrieve fee history, and inspect transaction records for the authenticated user.

Get the user’s aggregate balances, including general balance and AI credit limit, usage, and remaining.

This endpoint takes no parameters.

{
"statusCode": 200,
"message": "Balances retrieved successfully",
"data": {
"general_balance": "125.50",
"ai_limit": "50.00",
"ai_usage": "23.45",
"ai_remaining": "26.55"
}
}
const balances = await client.api.wallet.getAggregateBalances();

Get the user’s general balance only.

This endpoint takes no parameters.

{
"statusCode": 200,
"message": "General balance retrieved successfully",
"data": {
"id": "507f1f77bcf86cd799439100",
"user_id": "507f1f77bcf86cd799439011",
"general_balance": "125.50",
"created_at": "2025-01-10T08:30:00.000Z",
"updated_at": "2025-01-21T20:00:00.000Z"
}
}
const balance = await client.api.wallet.getGeneralBalance();

Get the user’s AI balance — limit, usage, and remaining.

This endpoint takes no parameters.

{
"statusCode": 200,
"message": "AI balance retrieved successfully",
"data": {
"ai_limit": "50.00",
"ai_usage": "23.45",
"ai_remaining": "26.55"
}
}
const aiBalance = await client.api.wallet.getAiBalance();

One-way transfer from the general balance to the AI credit balance. The amount must be a strict string in USD with up to 2 decimals.

This endpoint takes no parameters.

Request Body

NameTypeRequiredDescription
amountstringYesUSD amount as a string with up to 2 decimals, e.g. "10.00". No exponent, no negatives.
{
"amount": "25.00"
}
{
"statusCode": 200,
"message": "Transfer completed and AI credit limit synced",
"data": {
"gross_transferred": "25.00",
"net_ai_credit": "23.75",
"fee": "1.25",
"general_balance": "100.50",
"ai_balance": "75.00",
"key_created": false
}
}
const result = await client.api.wallet.transferToAi({
amount: "25.00"
});

Paginated list of platform fees charged on AI credit transfers and admin credits.

NameInTypeRequiredDescription
pagequerynumberNoPage number. Default: 1.
limitquerynumberNoItems per page. Default: 20.
sort_byquerystringNoField to sort by. Allowed: "created_at", "amount", "transaction_id". Default: "created_at".
sort_orderquerystringNoSort direction. Allowed: "asc", "desc". Default: "desc".
{
"statusCode": 200,
"message": "AI fee history retrieved successfully",
"data": {
"fees": [
{
"id": "507f1f77bcf86cd799439150",
"transaction_id": "507f1f77bcf86cd799439140",
"amount": "1.25",
"created_at": "2025-01-21T20:00:00.000Z",
"transaction": {
"id": "507f1f77bcf86cd799439140",
"reason": "Transfer to AI credits",
"amount": "25.00"
}
}
],
"pagination": {
"total": 12,
"page": 1,
"limit": 20,
"totalPages": 1
}
}
}
const fees = await client.api.wallet.listAiFeeHistoryIterator({
page: 1,
limit: 20
});

List wallet transactions for the authenticated user.

NameInTypeRequiredDescription
limitquerynumberNoItems per page. Default: 20.
sort_byquerystringNoField to sort by. Allowed: "id", "transaction_type", "status", "amount", "created_at", "updated_at". Default: "created_at".
sort_orderquerystringNoSort direction. Allowed: "asc", "desc". Default: "desc".
{
"statusCode": 200,
"message": "Transactions retrieved successfully",
"data": {
"transactions": [],
"pagination": {
"total": 0,
"page": 1,
"limit": 20,
"totalPages": 0
}
}
}
const transactions = await client.api.wallet.listTransactionsIterator({
limit: 20
});

Get a single transaction by ID.

NameInTypeRequiredDescription
idpathstringYesTransaction ID.
{
"statusCode": 200,
"message": "Transaction retrieved successfully",
"data": {
"id": "507f1f77bcf86cd799439140"
}
}
const transaction = await client.api.wallet.getTransaction({
id: "507f1f77bcf86cd799439140"
});

List all invoices for the authenticated user.

NameInTypeRequiredDescription
limitquerynumberNoItems per page. Default: 20.
sort_byquerystringNoField to sort by. Default: "created_at".
sort_orderquerystringNoSort direction. Allowed: "asc", "desc". Default: "desc".
{
"statusCode": 200,
"message": "Invoices retrieved successfully",
"data": {
"invoices": [
{
"id": "507f1f77bcf86cd799439120",
"user_id": "507f1f77bcf86cd799439011",
"transaction_id": "507f1f77bcf86cd799439110",
"invoice_number": "INV-2025-000456",
"status": "paid",
"amount": 50,
"currency": "USD",
"issue_date": "2025-01-20T15:30:00.000Z",
"due_date": "2025-02-20T15:30:00.000Z",
"paid_date": "2025-01-20T15:30:00.000Z",
"created_at": "2025-01-20T15:30:00.000Z",
"updated_at": "2025-01-20T15:30:00.000Z",
"transaction": {
"id": "507f1f77bcf86cd799439110",
"transaction_type": "payment",
"status": "completed",
"amount": 50,
"currency": "USD",
"created_at": "2025-01-20T15:30:00.000Z"
}
}
],
"pagination": {
"total": 23,
"page": 1,
"limit": 10,
"totalPages": 3
}
}
}
const invoices = await client.api.wallet.listInvoicesIterator({
limit: 20
});

Get a specific invoice by ID.

NameInTypeRequiredDescription
idpathstringYesInvoice ID.
{
"statusCode": 200,
"message": "Invoice retrieved successfully",
"data": {
"id": "507f1f77bcf86cd799439120",
"user_id": "507f1f77bcf86cd799439011",
"transaction_id": "507f1f77bcf86cd799439110",
"invoice_number": "INV-2025-000456",
"status": "paid",
"amount": 50,
"currency": "USD",
"billing_details": {
"name": "John Doe",
"address": "123 Main St"
},
"items": [
{
"description": "Account credit",
"amount": 50
}
],
"issue_date": "2025-01-20T15:30:00.000Z",
"due_date": "2025-02-20T15:30:00.000Z",
"paid_date": "2025-01-20T15:30:00.000Z",
"created_at": "2025-01-20T15:30:00.000Z",
"updated_at": "2025-01-20T15:30:00.000Z",
"transaction": {
"id": "507f1f77bcf86cd799439110",
"transaction_type": "payment",
"status": "completed",
"amount": 50,
"currency": "USD",
"created_at": "2025-01-20T15:30:00.000Z"
}
}
}
const invoice = await client.api.wallet.getInvoice({
id: "507f1f77bcf86cd799439120"
});

Download an invoice as a PDF.

NameInTypeRequiredDescription
idpathstringYesInvoice ID.

Returns a binary PDF file with Content-Type: application/pdf.

const pdf = await client.api.wallet.downloadInvoicePdf({
id: "507f1f77bcf86cd799439120"
});

POST /api/v1/wallet/invoices/generate/{id}

Section titled “POST /api/v1/wallet/invoices/generate/{id}”

Generate an invoice for a specific transaction. Returns 200 with the existing invoice if one is already associated, or 201 when a new invoice is created.

NameInTypeRequiredDescription
idpathstringYesTransaction ID.
{
"statusCode": 200,
"message": "Invoice already exists",
"data": {
"invoice_id": "507f1f77bcf86cd799439120",
"invoice_number": "INV-2025-000456"
}
}
const result = await client.api.wallet.generateInvoice({
id: "507f1f77bcf86cd799439110"
});

List all payment methods for the authenticated user.

This endpoint takes no parameters.

{
"statusCode": 200,
"message": "Payment methods retrieved successfully",
"data": [
{
"id": "507f1f77bcf86cd799439130",
"user_id": "507f1f77bcf86cd799439011",
"type": "credit_card",
"name": "Visa ending in 4242",
"status": "active",
"details": {
"last4": "4242",
"brand": "visa",
"exp_month": 12,
"exp_year": 2026
},
"is_default": true,
"created_at": "2025-01-15T10:00:00.000Z",
"updated_at": "2025-01-15T10:00:00.000Z"
}
]
}
const methods = await client.api.wallet.listPaymentMethodsIterator();

Get a single payment method by ID.

NameInTypeRequiredDescription
idpathstringYesPayment method ID.
{
"statusCode": 200,
"message": "Payment method retrieved successfully",
"data": {
"id": "507f1f77bcf86cd799439130",
"user_id": "507f1f77bcf86cd799439011",
"type": "credit_card",
"name": "Visa ending in 4242",
"status": "active",
"details": {
"last4": "4242",
"brand": "visa",
"exp_month": 12,
"exp_year": 2026
},
"is_default": true,
"created_at": "2025-01-15T10:00:00.000Z",
"updated_at": "2025-01-15T10:00:00.000Z"
}
}
const method = await client.api.wallet.getPaymentMethod({
id: "507f1f77bcf86cd799439130"
});

Add a new payment method for the authenticated user.

This endpoint takes no parameters.

Request Body

NameTypeRequiredDescription
typestringYesPayment method type (e.g. credit_card).
namestringYesDisplay name for the payment method.
detailsobjectNoProvider-specific details (e.g. last4, brand, expiry).
is_defaultbooleanNoWhether to mark this method as the default.
{
"type": "credit_card",
"name": "Mastercard ending in 5555",
"details": {
"last4": "5555",
"brand": "mastercard",
"exp_month": 8,
"exp_year": 2027
},
"is_default": false
}
{
"statusCode": 201,
"message": "Payment method added successfully",
"data": {
"id": "507f1f77bcf86cd799439131",
"user_id": "507f1f77bcf86cd799439011",
"type": "credit_card",
"name": "Mastercard ending in 5555",
"status": "active",
"details": {
"last4": "5555",
"brand": "mastercard",
"exp_month": 8,
"exp_year": 2027
},
"is_default": false,
"created_at": "2025-01-21T20:30:00.000Z",
"updated_at": "2025-01-21T20:30:00.000Z"
}
}
const method = await client.api.wallet.addPaymentMethod({
type: "credit_card",
name: "Mastercard ending in 5555",
details: {
last4: "5555",
brand: "mastercard",
exp_month: 8,
exp_year: 2027
},
is_default: false
});

Update an existing payment method. Any of details, status, or is_default may be sent.

NameInTypeRequiredDescription
idpathstringYesPayment method ID.

Request Body

NameTypeRequiredDescription
detailsobjectNoUpdated provider-specific details.
statusstringNoNew status. Allowed: "active", "inactive".
is_defaultbooleanNoWhether this method should be the default.
{
"status": "active",
"is_default": true
}
{
"statusCode": 200,
"message": "Payment method updated successfully",
"data": {
"id": "507f1f77bcf86cd799439131",
"user_id": "507f1f77bcf86cd799439011",
"type": "credit_card",
"name": "Mastercard (primary)",
"status": "active",
"details": {
"last4": "5555",
"brand": "mastercard",
"exp_month": 10,
"exp_year": 2027
},
"is_default": true,
"created_at": "2025-01-21T20:30:00.000Z",
"updated_at": "2025-01-21T20:45:00.000Z"
}
}
const updated = await client.api.wallet.updatePaymentMethod({
id: "507f1f77bcf86cd799439131",
status: "active",
is_default: true
});

PATCH /api/v1/wallet/payment-methods/{id}/default

Section titled “PATCH /api/v1/wallet/payment-methods/{id}/default”

Mark an existing payment method as the default.

NameInTypeRequiredDescription
idpathstringYesPayment method ID.
{
"statusCode": 200,
"message": "Default payment method set successfully",
"data": {
"id": "507f1f77bcf86cd799439131",
"user_id": "507f1f77bcf86cd799439011",
"type": "credit_card",
"name": "Mastercard (primary)",
"status": "active",
"details": {
"last4": "5555",
"brand": "mastercard",
"exp_month": 10,
"exp_year": 2027
},
"is_default": true,
"created_at": "2025-01-21T20:30:00.000Z",
"updated_at": "2025-01-21T21:00:00.000Z"
}
}
const result = await client.api.wallet.setDefaultPaymentMethod({
id: "507f1f77bcf86cd799439131"
});

DELETE /api/v1/wallet/payment-methods/{id}

Section titled “DELETE /api/v1/wallet/payment-methods/{id}”

Delete an existing payment method.

NameInTypeRequiredDescription
idpathstringYesPayment method ID.
{
"statusCode": 200,
"message": "Payment method deleted successfully"
}
await client.api.wallet.deletePaymentMethod({
id: "507f1f77bcf86cd799439131"
});

Process a payment using a specified payment method. The amount is a strict string in USD with up to 2 decimals.

This endpoint takes no parameters.

Request Body

NameTypeRequiredDescription
payment_method_idstringYesID of the payment method to charge.
amountstringYesUSD amount as a strict string with up to 2 decimals (e.g. "10", "10.00"). No negatives, no exponent.
credit_distributionarrayNoOptional; currently informational. If provided, amounts must be strict dollar strings.
reasonstringNoFree-form reason or memo for the payment.
{
"payment_method_id": "507f1f77bcf86cd799439130",
"amount": "100.00",
"reason": "Monthly subscription payment"
}
{
"statusCode": 200,
"message": "Payment processed successfully",
"data": {
"transaction": {
"id": "507f1f77bcf86cd799439140",
"user_id": "507f1f77bcf86cd799439011",
"payment_method_id": "507f1f77bcf86cd799439130",
"transaction_type": "payment",
"status": "completed",
"amount": 100,
"currency": "USD",
"gateway_name": "stripe",
"gateway_transaction_id": "ch_3ABC123xyz",
"reason": "Monthly subscription payment",
"created_at": "2025-01-21T20:00:00.000Z",
"updated_at": "2025-01-21T20:00:00.000Z"
},
"invoice": {
"id": "507f1f77bcf86cd799439141",
"invoice_number": "INV-2025-000789"
},
"balance": {
"id": "507f1f77bcf86cd799439100",
"user_id": "507f1f77bcf86cd799439011",
"balance": 225.5,
"created_at": "2025-01-10T08:30:00.000Z",
"updated_at": "2025-01-21T20:00:00.000Z"
}
}
}
const result = await client.api.wallet.processPayment({
payment_method_id: "507f1f77bcf86cd799439130",
amount: "100.00",
reason: "Monthly subscription payment"
});

Get the status of a payment by ID.

NameInTypeRequiredDescription
idpathstringYesPayment ID.
{
"statusCode": 200,
"message": "Payment status retrieved successfully",
"data": {
"id": "507f1f77bcf86cd799439140",
"user_id": "507f1f77bcf86cd799439011",
"payment_method_id": "507f1f77bcf86cd799439130",
"transaction_type": "payment",
"status": "completed",
"amount": 100,
"currency": "USD",
"gateway_name": "stripe",
"gateway_transaction_id": "ch_3ABC123xyz",
"reason": "Monthly subscription payment",
"created_at": "2025-01-21T20:00:00.000Z",
"updated_at": "2025-01-21T20:00:00.000Z",
"details": [
{
"id": "507f1f77bcf86cd799439142",
"transaction_id": "507f1f77bcf86cd799439140",
"credit_type": "general",
"amount": 100,
"created_at": "2025-01-21T20:00:00.000Z"
}
],
"invoice": {
"id": "507f1f77bcf86cd799439141",
"invoice_number": "INV-2025-000789",
"status": "paid",
"issue_date": "2025-01-21T20:00:00.000Z",
"paid_date": "2025-01-21T20:00:00.000Z"
}
}
}
const status = await client.api.wallet.getPaymentStatus({
id: "507f1f77bcf86cd799439140"
});