List Credit Transactions
Retrieve a paginated list of all credit transactions with filtering and sorting options
Retrieve a paginated list of all credit transactions on your account, including usage, purchases, bonuses, and refunds.
/v1/credits/transactionsRequest
Headers
| Parameter | Type | Description |
|---|---|---|
X-API-Keyrequired | string | Your API key for authentication |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number for pagination (1-indexed) Default: 1 |
limit | integer | Number of transactions per page (max 100) Default: 20 |
type | string | Filter by transaction type: usage, purchase, bonus, refund |
startDate | string | Filter transactions from this date (ISO 8601 format) |
endDate | string | Filter transactions until this date (ISO 8601 format) |
sortBy | string | Sort field: createdAt, amount, type Default: createdAt |
sortOrder | string | Sort order: asc, desc Default: desc |
Example Requests
# Get all transactions (default pagination)
curl -X GET "https://api.docurift.com/v1/credits/transactions" \
-H "X-API-Key: frc_your_api_key_here"
# Filter by transaction type
curl -X GET "https://api.docurift.com/v1/credits/transactions?type=usage&limit=50" \
-H "X-API-Key: frc_your_api_key_here"
# Filter by date range
curl -X GET "https://api.docurift.com/v1/credits/transactions?startDate=2024-01-01&endDate=2024-01-31" \
-H "X-API-Key: frc_your_api_key_here"
# Sort by amount (highest first)
curl -X GET "https://api.docurift.com/v1/credits/transactions?sortBy=amount&sortOrder=desc" \
-H "X-API-Key: frc_your_api_key_here"import requests
import os
from datetime import datetime, timedelta
API_KEY = os.getenv('DOCURIFT_API_KEY')
API_URL = 'https://api.docurift.com/v1'
# Get last 30 days of usage transactions
start_date = (datetime.now() - timedelta(days=30)).isoformat()
end_date = datetime.now().isoformat()
response = requests.get(
f'{API_URL}/credits/transactions',
headers={'X-API-Key': API_KEY},
params={
'type': 'usage',
'startDate': start_date,
'endDate': end_date,
'limit': 100
}
)
data = response.json()
transactions = data['data']['transactions']
for tx in transactions:
print(f"{tx['createdAt']}: {tx['type']} - {tx['amount']} credits - {tx['description']}")const API_KEY = process.env.DOCURIFT_API_KEY;
const API_URL = 'https://api.docurift.com/v1';
// Get paginated transactions with filters
async function getTransactions(options = {}) {
const params = new URLSearchParams({
page: options.page || 1,
limit: options.limit || 20,
...(options.type && { type: options.type }),
...(options.startDate && { startDate: options.startDate }),
...(options.endDate && { endDate: options.endDate }),
sortBy: options.sortBy || 'createdAt',
sortOrder: options.sortOrder || 'desc'
});
const response = await fetch(
`${API_URL}/credits/transactions?${params}`,
{
headers: { 'X-API-Key': API_KEY }
}
);
return await response.json();
}
// Get all purchase transactions
const purchases = await getTransactions({ type: 'purchase' });
console.log('Purchases:', purchases.data.transactions);
// Get usage for current month
const now = new Date();
const firstOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
const usage = await getTransactions({
type: 'usage',
startDate: firstOfMonth.toISOString()
});
console.log('Monthly usage:', usage.data.transactions);Response
{
"success": true,
"data": {
"transactions": [
{
"id": "txn_abc123def456",
"type": "usage",
"amount": -3,
"balance": 420,
"description": "Document processing: invoice.pdf (3 pages)",
"documentId": "doc_789xyz",
"createdAt": "2024-01-26T14:30:00Z"
},
{
"id": "txn_ghi789jkl012",
"type": "purchase",
"amount": 500,
"balance": 423,
"description": "Credit purchase - 500 pages",
"paymentId": "pay_mno345pqr",
"createdAt": "2024-01-25T10:15:00Z"
},
{
"id": "txn_stu678vwx901",
"type": "bonus",
"amount": 50,
"balance": -77,
"description": "Welcome bonus - Free tier credits",
"createdAt": "2024-01-20T08:00:00Z"
},
{
"id": "txn_yza234bcd567",
"type": "refund",
"amount": 10,
"balance": -127,
"description": "Refund for failed processing: doc_failed123",
"documentId": "doc_failed123",
"createdAt": "2024-01-22T16:45:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"totalPages": 5,
"totalItems": 94,
"hasNext": true,
"hasPrev": false
}
}
}Response Fields
| Parameter | Type | Description |
|---|---|---|
transactions | array | Array of transaction objects |
transactions[].id | string | Unique transaction identifier |
transactions[].type | string | Transaction type: usage, purchase, bonus, refund |
transactions[].amount | integer | Credit amount (negative for usage, positive for additions) |
transactions[].balance | integer | Account balance after this transaction |
transactions[].description | string | Human-readable transaction description |
transactions[].documentId | string | Related document ID (for usage/refund transactions) |
transactions[].paymentId | string | Related payment ID (for purchase transactions) |
transactions[].createdAt | string | ISO 8601 timestamp when transaction occurred |
pagination | object | Pagination metadata |
pagination.page | integer | Current page number |
pagination.limit | integer | Items per page |
pagination.totalPages | integer | Total number of pages |
pagination.totalItems | integer | Total number of transactions |
pagination.hasNext | boolean | Whether more pages exist after current |
pagination.hasPrev | boolean | Whether pages exist before current |
Transaction Types
| Type | Amount | Description |
|------|--------|-------------|
| usage | Negative | Credits consumed for document processing |
| purchase | Positive | Credits added from a purchase |
| bonus | Positive | Credits from promotions, referrals, or free tier |
| refund | Positive | Credits returned for failed processing or disputes |
Credits Never Expire
All credits, regardless of transaction type, never expire. Your balance remains available indefinitely.
Error Responses
{
"success": false,
"error": {
"code": "INVALID_PARAMETER",
"message": "Invalid value for 'type'. Must be one of: usage, purchase, bonus, refund"
}
}Error Codes
| Code | HTTP Status | Description |
|------|-------------|-------------|
| UNAUTHORIZED | 401 | Missing or invalid API key |
| INVALID_API_KEY | 401 | API key is malformed or does not exist |
| INVALID_PARAMETER | 400 | Invalid query parameter value |
| INVALID_DATE_FORMAT | 400 | Date parameters must be ISO 8601 format |
| PAGE_OUT_OF_RANGE | 400 | Requested page exceeds available pages |
| RATE_LIMIT_EXCEEDED | 429 | Too many requests, please retry later |
| INTERNAL_ERROR | 500 | Server error, please retry or contact support |
Next Steps
- Check your balance - View current credit balance
- View usage statistics - Analyze consumption patterns
- Process a document - Use credits to extract data