Skip to content

Manage your account wallet, balances, payment methods, invoices, and transactions. Use these endpoints to check general and AI balances, top up via Stripe Checkout, transfer funds between balance types, and review payment history.

All endpoints are scoped to the authenticated user. Amounts are submitted as strict decimal strings (e.g., "25.00", "10") — no exponents, no negatives, up to 2 decimal places.


Return the user’s aggregate balances (general + AI) in a single response.

This endpoint takes no parameters.

Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/balances" \
-H "Authorization: Bearer <token>"

Response

{
"statusCode": 200,
"message": "Balances retrieved successfully",
"data": {
"general_balance": "125.50",
"ai_limit": "50.00",
"ai_usage": "23.45",
"ai_remaining": "26.55"
}
}

Return the user’s general account balance only.

This endpoint takes no parameters.

Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/balances/general" \
-H "Authorization: Bearer <token>"

Response

{
"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"
}
}

Return the user’s AI credit limit, usage, and remaining balance.

This endpoint takes no parameters.

Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/balances/ai" \
-H "Authorization: Bearer <token>"

Response

{
"statusCode": 200,
"message": "AI balance retrieved successfully",
"data": {
"ai_limit": "50.00",
"ai_usage": "23.45",
"ai_remaining": "26.55"
}
}

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

NameInTypeRequiredDescription
pagequerynumberNoPage number. Default: 1
limitquerynumberNoItems per page. Default: 20
sort_byquerystringNoOne of: created_at, amount, transaction_id. Default: "created_at"
sort_orderquerystringNoOne of: asc, desc. Default: "desc"
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/ai-fee-history?page=1&limit=20&sort_by=created_at&sort_order=desc" \
-H "Authorization: Bearer <token>"

Response

{
"statusCode": 200,
"message": "AI fee history retrieved successfully",
"data": {
"fees": [
{
"id": "507f1f77bcf86cd799439200",
"transaction_id": "507f1f77bcf86cd799439110",
"amount": "1.25",
"created_at": "2025-01-21T20:00:00.000Z",
"transaction": {
"id": "507f1f77bcf86cd799439110",
"reason": "Transfer to AI credits",
"amount": "25.00"
}
}
],
"pagination": {
"total": 12,
"page": 1,
"limit": 20,
"totalPages": 1
}
}
}

One-way transfer from the general balance to AI credit balance. A platform fee is deducted from the gross amount; the net amount is added to the AI credit limit.

FieldTypeRequiredDescription
amountstringYesUSD amount as a string with up to 2 decimals (e.g., "10.00"). No exponent, no negatives.
{
"amount": "25.00"
}
Terminal window
curl -X POST "https://api.example.com/api/v1/wallet/transfers" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"amount": "25.00"
}'

Response

{
"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
}
}

List the user’s wallet transactions with sorting.

NameInTypeRequiredDescription
limitquerynumberNoItems per page. Default: 20
sort_byquerystringNoOne of: id, transaction_type, status, amount, created_at, updated_at. Default: "created_at"
sort_orderquerystringNoOne of: asc, desc. Default: "desc"
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/transactions?limit=20&sort_by=created_at&sort_order=desc" \
-H "Authorization: Bearer <token>"

Response

{}

Retrieve a single wallet transaction by ID.

NameInTypeRequiredDescription
idpathstringYesTransaction ID.
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/transactions/507f1f77bcf86cd799439140" \
-H "Authorization: Bearer <token>"

Response

{}

List all payment methods on file for the authenticated user.

This endpoint takes no parameters.

Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/payment-methods/" \
-H "Authorization: Bearer <token>"

Response

{
"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"
}
]
}

Retrieve a single payment method by ID.

NameInTypeRequiredDescription
idpathstringYesPayment method ID.
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/payment-methods/507f1f77bcf86cd799439130" \
-H "Authorization: Bearer <token>"

Response

{
"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"
}
}

Add a new payment method to the user’s account.

FieldTypeRequiredDescription
typestringYesPayment method type (e.g., credit_card).
namestringYesHuman-readable label (e.g., "Mastercard ending in 5555").
detailsobjectNoGateway-specific details (e.g., { last4, brand, exp_month, exp_year }).
is_defaultbooleanNoWhether to mark this as the default method.
{
"type": "credit_card",
"name": "Mastercard ending in 5555",
"details": {
"last4": "5555",
"brand": "mastercard",
"exp_month": 8,
"exp_year": 2027
},
"is_default": false
}
Terminal window
curl -X POST "https://api.example.com/api/v1/wallet/payment-methods/" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"type": "credit_card",
"name": "Mastercard ending in 5555",
"details": {
"last4": "5555",
"brand": "mastercard",
"exp_month": 8,
"exp_year": 2027
},
"is_default": false
}'

Response

{
"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"
}
}

Partially update an existing payment method (status, default flag, or details).

NameInTypeRequiredDescription
idpathstringYesPayment method ID.
FieldTypeRequiredDescription
detailsobjectNoReplacement gateway-specific details object.
statusstringNoOne of: active, inactive.
is_defaultbooleanNoMark this payment method as the default.
{
"status": "active",
"is_default": true,
"details": {
"last4": "5555",
"brand": "mastercard",
"exp_month": 10,
"exp_year": 2027
}
}
Terminal window
curl -X PATCH "https://api.example.com/api/v1/wallet/payment-methods/507f1f77bcf86cd799439131" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"is_default": true
}'

Response

{
"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"
}
}

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

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

Promote an existing payment method to be the user’s default.

NameInTypeRequiredDescription
idpathstringYesPayment method ID.
Terminal window
curl -X PATCH "https://api.example.com/api/v1/wallet/payment-methods/507f1f77bcf86cd799439131/default" \
-H "Authorization: Bearer <token>"

Response

{
"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"
}
}

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

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

Delete a payment method from the user’s account.

NameInTypeRequiredDescription
idpathstringYesPayment method ID.
Terminal window
curl -X DELETE "https://api.example.com/api/v1/wallet/payment-methods/507f1f77bcf86cd799439131" \
-H "Authorization: Bearer <token>"

Response

{
"statusCode": 200,
"message": "Payment method deleted successfully"
}

Process a payment using a saved payment method. Credits the user’s wallet, creates an invoice, and updates the balance atomically.

FieldTypeRequiredDescription
payment_method_idstringYesID of the payment method to charge.
amountstringYesUSD amount as a strict decimal string with up to 2 decimals (e.g., "10", "10.00"). No negatives, no exponent.
credit_distributionarrayNoOptional allocation hint. Each item: { type: "general", amount: "<decimal string>" }. Informational only; amounts must be strict dollar strings.
reasonstringNoFree-form description that appears on the invoice.
{
"payment_method_id": "507f1f77bcf86cd799439130",
"amount": "100.00",
"reason": "Monthly subscription payment"
}
Terminal window
curl -X POST "https://api.example.com/api/v1/wallet/payments/" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"payment_method_id": "507f1f77bcf86cd799439130",
"amount": "100.00",
"reason": "Monthly subscription payment"
}'

Response

{
"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"
}
}
}

Retrieve the status and details of a previously submitted payment.

NameInTypeRequiredDescription
idpathstringYesPayment transaction ID.
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/payments/507f1f77bcf86cd799439140" \
-H "Authorization: Bearer <token>"

Response

{
"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"
}
}
}

Possible payment intent statuses: creating, pending, processing, completed, failed, expired, cancelled, admin_review.

POST /api/v1/wallet/payments/stripe/checkout

Section titled “POST /api/v1/wallet/payments/stripe/checkout”

Create a payment intent and a hosted Stripe Checkout session for the user.

FieldTypeRequiredDescription
amountstringYesUSD amount as a strict decimal string (e.g., "25" or "25.00").
idempotency_keystringNoCaller-provided idempotency key (1–128 chars). Repeats with the same key return the original intent.
{
"amount": "25.00",
"idempotency_key": "topup-2026-06-10-001"
}
Terminal window
curl -X POST "https://api.example.com/api/v1/wallet/payments/stripe/checkout" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"amount": "25.00",
"idempotency_key": "topup-2026-06-10-001"
}'

Response

{
"statusCode": 201,
"message": "Checkout session created",
"data": {
"intent": {
"id": "665f1f77bcf86cd799439011",
"provider": "stripe",
"status": "pending",
"amount": 25,
"currency": "USD",
"redirect_url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3",
"credited_at": null,
"expires_at": "2026-06-11T12:00:00.000Z",
"created_at": "2026-06-10T12:00:00.000Z",
"updated_at": "2026-06-10T12:00:00.000Z"
},
"checkout_url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3"
}
}

GET /api/v1/wallet/payments/stripe/intents

Section titled “GET /api/v1/wallet/payments/stripe/intents”

List the authenticated user’s Stripe payment intents, newest first.

NameInTypeRequiredDescription
limitquerynumberNoItems per page. Default: 20
offsetquerynumberNoItems to skip. Default: 0
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/payments/stripe/intents?limit=20&offset=0" \
-H "Authorization: Bearer <token>"

Response

{
"statusCode": 200,
"message": "Payment intents retrieved successfully",
"data": {
"intents": [
{
"id": "665f1f77bcf86cd799439011",
"provider": "stripe",
"status": "pending",
"amount": 25,
"currency": "USD",
"redirect_url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3",
"credited_at": null,
"expires_at": "2026-06-11T12:00:00.000Z",
"created_at": "2026-06-10T12:00:00.000Z",
"updated_at": "2026-06-10T12:00:00.000Z"
}
],
"total": 1
}
}

GET /api/v1/wallet/payments/stripe/intents/{id}

Section titled “GET /api/v1/wallet/payments/stripe/intents/{id}”

Retrieve a single Stripe payment intent by ID. Use this after the user returns from Stripe Checkout to learn whether the payment settled.

NameInTypeRequiredDescription
idpathstringYesPayment intent ID.
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/payments/stripe/intents/665f1f77bcf86cd799439011" \
-H "Authorization: Bearer <token>"

Response

{
"statusCode": 200,
"message": "Payment intent retrieved successfully",
"data": {
"id": "665f1f77bcf86cd799439011",
"provider": "stripe",
"status": "completed",
"amount": 25,
"currency": "USD",
"redirect_url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3",
"credited_at": "2026-06-10T12:05:30.000Z",
"expires_at": "2026-06-11T12:00:00.000Z",
"created_at": "2026-06-10T12:00:00.000Z",
"updated_at": "2026-06-10T12:05:30.000Z"
}
}

List all invoices issued to the authenticated user.

NameInTypeRequiredDescription
limitquerynumberNoItems per page. Default: 20
sort_byquerystringNoField to sort by. Default: "created_at"
sort_orderquerystringNoOne of: asc, desc. Default: "desc"
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/invoices/?limit=20&sort_by=created_at&sort_order=desc" \
-H "Authorization: Bearer <token>"

Response

{
"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
}
}
}

Retrieve a single invoice with full line items and billing details.

NameInTypeRequiredDescription
idpathstringYesInvoice ID.
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/invoices/507f1f77bcf86cd799439120" \
-H "Authorization: Bearer <token>"

Response

{
"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"
}
}
}

Download an invoice as a PDF file (binary response, application/pdf).

NameInTypeRequiredDescription
idpathstringYesInvoice ID.
Terminal window
curl -X GET "https://api.example.com/api/v1/wallet/invoices/507f1f77bcf86cd799439120/pdf" \
-H "Authorization: Bearer <token>" \
-o invoice.pdf

Response

{
"description": "PDF binary file (application/pdf)"
}

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

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

Generate an invoice for a specific transaction. Returns 201 if a new invoice is created, or 200 if an invoice already exists for that transaction.

NameInTypeRequiredDescription
idpathstringYesTransaction ID to generate an invoice for.
Terminal window
curl -X POST "https://api.example.com/api/v1/wallet/invoices/generate/507f1f77bcf86cd799439110" \
-H "Authorization: Bearer <token>"

Response

{
"statusCode": 201,
"message": "Invoice generated successfully",
"data": {
"invoice_id": "507f1f77bcf86cd799439121",
"invoice_number": "INV-2025-000457"
}
}