5 min read

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.

GET/v1/credits/transactions

Request

Headers

ParameterTypeDescription
X-API-Keyrequired
stringYour API key for authentication

Query Parameters

ParameterTypeDescription
page
integerPage number for pagination (1-indexed)
Default: 1
limit
integerNumber of transactions per page (max 100)
Default: 20
type
stringFilter by transaction type: usage, purchase, bonus, refund
startDate
stringFilter transactions from this date (ISO 8601 format)
endDate
stringFilter transactions until this date (ISO 8601 format)
sortBy
stringSort field: createdAt, amount, type
Default: createdAt
sortOrder
stringSort order: asc, desc
Default: desc

Example Requests

curl
# 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"
python
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']}")
javascript
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

response.json
{
"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

ParameterTypeDescription
transactions
arrayArray of transaction objects
transactions[].id
stringUnique transaction identifier
transactions[].type
stringTransaction type: usage, purchase, bonus, refund
transactions[].amount
integerCredit amount (negative for usage, positive for additions)
transactions[].balance
integerAccount balance after this transaction
transactions[].description
stringHuman-readable transaction description
transactions[].documentId
stringRelated document ID (for usage/refund transactions)
transactions[].paymentId
stringRelated payment ID (for purchase transactions)
transactions[].createdAt
stringISO 8601 timestamp when transaction occurred
pagination
objectPagination metadata
pagination.page
integerCurrent page number
pagination.limit
integerItems per page
pagination.totalPages
integerTotal number of pages
pagination.totalItems
integerTotal number of transactions
pagination.hasNext
booleanWhether more pages exist after current
pagination.hasPrev
booleanWhether 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

error.json
{
"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