Powerful REST APIs, webhooks, and SDKs to embed expense management directly into your applications. Build custom integrations in minutes, not months.
Follow these steps to start integrating Xpensetrim into your application.
Navigate to your dashboard Settings > API Keys and generate a new key. Store it securely—it will only be shown once.
# Add to your .env file
XPENSETRIM_API_KEY=xt_live_your_api_key_here
XPENSETRIM_BASE_URL=https://api.xpensetrim.com/v1Install the official Xpensetrim SDK for your preferred language.
npm install @xpensetrim/sdkCreate an expense programmatically with a single API call.
import { Xpensetrim } from '@xpensetrim/sdk';
const client = new Xpensetrim({
apiKey: process.env.XPENSETRIM_API_KEY,
});
// Create an expense
const expense = await client.expenses.create({
amount: 49.99,
currency: 'USD',
category: 'Software',
description: 'Monthly SaaS subscription',
date: '2026-03-07',
merchant: 'Acme Tools Inc.',
tags: ['recurring', 'tools'],
});
console.log('Expense created:', expense.id);
// List recent expenses
const expenses = await client.expenses.list({
limit: 10,
sort: 'date:desc',
status: 'approved',
});
console.log(`Found ${expenses.total} expenses`);All API requests must be authenticated using a Bearer token in the Authorization header.
GET /api/v1/expenses HTTP/1.1
Host: api.xpensetrim.com
Authorization: Bearer xt_live_your_api_key_here
Content-Type: application/jsonPOST /oauth/token HTTP/1.1
Host: auth.xpensetrim.com
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=AUTH_CODE
&redirect_uri=https://yourapp.com/callback
&client_id=YOUR_CLIENT_ID
&code_verifier=YOUR_CODE_VERIFIERBase URL: https://api.xpensetrim.com/v1
/api/v1/expensesList all expenses with pagination, filtering, and sorting
/api/v1/expensesCreate a new expense entry with optional receipt attachment
/api/v1/budgetsRetrieve budget configurations and current spending status
/api/v1/categoriesList expense categories including AI-generated suggestions
/api/v1/reportsGenerate spending reports with custom date ranges and filters
/api/v1/receipts/scanUpload and OCR-scan a receipt image for auto-extraction
/api/v1/team/membersList team members, roles, and permissions
/api/v1/virtual-cardsCreate and manage virtual expense cards
/api/v1/notificationsRetrieve alerts for budget thresholds and approvals
/api/v1/settingsUpdate organization preferences, currency, and timezone
{
"data": {
"id": "exp_a1b2c3d4e5",
"amount": 49.99,
"currency": "USD",
"category": {
"id": "cat_software",
"name": "Software",
"ai_confidence": 0.97
},
"description": "Monthly SaaS subscription",
"merchant": "Acme Tools Inc.",
"date": "2026-03-07",
"status": "approved",
"receipt_url": "https://cdn.xpensetrim.com/receipts/rec_xyz.jpg",
"tags": ["recurring", "tools"],
"created_at": "2026-03-07T10:30:00Z",
"updated_at": "2026-03-07T10:30:00Z"
},
"meta": {
"request_id": "req_f6g7h8i9j0"
}
}The API returns standard HTTP status codes. Errors include a structured JSON body with a code and message.
{
"error": {
"code": "validation_error",
"message": "Amount must be greater than 0",
"details": [
{
"field": "amount",
"message": "Must be a positive number"
}
]
},
"meta": {
"request_id": "req_f6g7h8i9j0"
}
}200Success201Resource created400Validation error401Unauthorized403Forbidden404Not found429Rate limited500Internal errorSubscribe to events and get notified instantly when something happens in your Xpensetrim account.
expense.createdTriggered when a new expense is logged
expense.updatedTriggered when an expense is modified
expense.approvedTriggered when an expense is approved
expense.rejectedTriggered when an expense is rejected
budget.thresholdTriggered when budget usage exceeds a threshold
receipt.scannedTriggered after OCR processing completes
team.member_addedTriggered when a new team member is added
report.generatedTriggered when a scheduled report is ready
{
"id": "evt_k1l2m3n4o5",
"type": "expense.created",
"created_at": "2026-03-07T10:30:00Z",
"data": {
"id": "exp_a1b2c3d4e5",
"amount": 49.99,
"currency": "USD",
"category": "Software",
"description": "Monthly SaaS subscription",
"merchant": "Acme Tools Inc.",
"status": "pending"
}
}Every webhook request includes an X-Xpensetrim-Signature header. Verify it to ensure the payload is authentic.
import { Xpensetrim } from '@xpensetrim/sdk';
const client = new Xpensetrim({ apiKey: process.env.XPENSETRIM_API_KEY });
// In your webhook handler
app.post('/webhooks/xpensetrim', (req, res) => {
const signature = req.headers['x-xpensetrim-signature'];
const isValid = client.webhooks.verify(
req.body,
signature,
process.env.XPENSETRIM_WEBHOOK_SECRET
);
if (!isValid) {
return res.status(401).json({ error: 'Invalid signature' });
}
const event = req.body;
switch (event.type) {
case 'expense.created':
console.log('New expense:', event.data.id);
break;
case 'budget.threshold':
console.log('Budget alert:', event.data);
break;
}
res.status(200).json({ received: true });
});First-class SDKs with full TypeScript support, auto-pagination, and built-in retry logic.
Node.js / TypeScript
npm install @xpensetrim/sdkPython
pip install xpensetrimGo
go get github.com/xpensetrim/xpensetrim-goRuby
gem install xpensetrimStep-by-step guides for integrating Xpensetrim with popular platforms and services.
All list endpoints support cursor-based pagination for efficient data retrieval.
# First page
GET /api/v1/expenses?limit=25
# Next page (use the cursor from the previous response)
GET /api/v1/expenses?limit=25&cursor=exp_a1b2c3d4e5
# Response includes pagination metadata
{
"data": [...],
"pagination": {
"has_more": true,
"next_cursor": "exp_f6g7h8i9j0",
"total": 1250
}
}Use query parameters to filter and sort results.
# Filter by date range and category
GET /api/v1/expenses?date_from=2026-01-01&date_to=2026-03-07&category=Software
# Sort by amount descending
GET /api/v1/expenses?sort=amount:desc
# Filter by status and team member
GET /api/v1/expenses?status=pending&assigned_to=user_abc123
# Search by description
GET /api/v1/expenses?search=subscriptionStart integrating Xpensetrim today. Get your API key, explore the SDKs, and ship your integration in minutes.
© 2025 xpensetrim.com. All rights reserved.