Transactions API
View transaction history and create manual transactions.
About Transactions
Transactions are the permanent ledger of all credit movements. Most transactions are created automatically when you add credits, deduct credits, or confirm reservations. You can also create manual transactions for adjustments, refunds, or migrations.
GET
/v1/transactions?accountId=...List all transactions for a specific account (or all accounts if omitted) with pagination. Optional: externalId, limit, offset, startDate, endDate, include=reservation,usage for audit data.
List account transactions
curl -X GET "https://api.credits.dev/v1/transactions?accountId=acc_123&limit=50&offset=0" \
-H "X-API-Key: YOUR_API_KEY"Response
{
"items": [
{
"id": "txn_xyz789",
"accountId": "acc_123",
"type": "debit",
"amount": 50,
"description": "Chat completion",
"balanceAfter": 450,
"metadata": {},
"createdAt": "2024-01-15T10:00:00Z"
}
],
"pagination": {
"limit": 50,
"offset": 0,
"totalCount": 1,
"hasMore": false
}
}POST
/v1/transactions/createCreate a manual transaction for adjustments, refunds, or migrations.
Create manual transaction
curl -X POST "https://api.credits.dev/v1/transactions/create" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accountId": "acc_123",
"amount": 100,
"type": "credit",
"description": "Manual adjustment - refund"
}'Request Body
{
"accountId": "acc_123",
"amount": 100,
"type": "credit",
"description": "Manual adjustment - refund",
"metadata": {
"reason": "customer_request",
"refundId": "ref_123"
}
}Response
{
"success": true,
"transaction": {
"id": "txn_xyz789",
"accountId": "acc_123",
"type": "credit",
"amount": 100,
"balanceAfter": 550,
"createdAt": "2024-01-15T10:00:00Z"
}
}