Developer Documentation

Integrate Xpensetrim Into Your Workflow

Powerful REST APIs, webhooks, and SDKs to embed expense management directly into your applications. Build custom integrations in minutes, not months.

Quick Start

Get Up and Running in 5 Minutes

Follow these steps to start integrating Xpensetrim into your application.

1

Get Your API Key

Navigate to your dashboard Settings > API Keys and generate a new key. Store it securely—it will only be shown once.

env
# Add to your .env file
XPENSETRIM_API_KEY=xt_live_your_api_key_here
XPENSETRIM_BASE_URL=https://api.xpensetrim.com/v1
2

Install the SDK

Install the official Xpensetrim SDK for your preferred language.

bash
npm install @xpensetrim/sdk
3

Make Your First API Call

Create an expense programmatically with a single API call.

javascript
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`);
Authentication

Secure API Authentication

All API requests must be authenticated using a Bearer token in the Authorization header.

API Key Authentication
Use your API key as a Bearer token for server-to-server requests.
http
GET /api/v1/expenses HTTP/1.1
Host: api.xpensetrim.com
Authorization: Bearer xt_live_your_api_key_here
Content-Type: application/json
OAuth 2.0 (Enterprise)
For enterprise integrations, use OAuth 2.0 with PKCE for user-delegated access.
http
POST /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_VERIFIER

Security Best Practices

  • Never expose API keys in client-side code or public repositories
  • Rotate API keys periodically and use environment variables
  • Use IP allowlisting to restrict API access to known servers
  • All API traffic is encrypted with TLS 1.3 (256-bit SSL)
  • Rate limits: 1,000 requests/minute (Pro), 10,000 requests/minute (Enterprise)
API Reference

RESTful API Endpoints

Base URL: https://api.xpensetrim.com/v1

GET
/api/v1/expenses

List all expenses with pagination, filtering, and sorting

POST
/api/v1/expenses

Create a new expense entry with optional receipt attachment

GET
/api/v1/budgets

Retrieve budget configurations and current spending status

GET
/api/v1/categories

List expense categories including AI-generated suggestions

GET
/api/v1/reports

Generate spending reports with custom date ranges and filters

POST
/api/v1/receipts/scan

Upload and OCR-scan a receipt image for auto-extraction

GET
/api/v1/team/members

List team members, roles, and permissions

POST
/api/v1/virtual-cards

Create and manage virtual expense cards

GET
/api/v1/notifications

Retrieve alerts for budget thresholds and approvals

PUT
/api/v1/settings

Update organization preferences, currency, and timezone

Example Response

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

Error Handling

The API returns standard HTTP status codes. Errors include a structured JSON body with a code and message.

json
{
  "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"
  }
}
200Success
201Resource created
400Validation error
401Unauthorized
403Forbidden
404Not found
429Rate limited
500Internal error
Webhooks

Real-Time Event Notifications

Subscribe to events and get notified instantly when something happens in your Xpensetrim account.

expense.created

Triggered when a new expense is logged

expense.updated

Triggered when an expense is modified

expense.approved

Triggered when an expense is approved

expense.rejected

Triggered when an expense is rejected

budget.threshold

Triggered when budget usage exceeds a threshold

receipt.scanned

Triggered after OCR processing completes

team.member_added

Triggered when a new team member is added

report.generated

Triggered when a scheduled report is ready

Webhook Payload Example

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

Verifying Webhook Signatures

Every webhook request includes an X-Xpensetrim-Signature header. Verify it to ensure the payload is authentic.

javascript
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 });
});
Official SDKs

SDKs for Every Stack

First-class SDKs with full TypeScript support, auto-pagination, and built-in retry logic.

JS

Node.js / TypeScript

npm install @xpensetrim/sdk
PY

Python

pip install xpensetrim
GO

Go

go get github.com/xpensetrim/xpensetrim-go
RB

Ruby

gem install xpensetrim
Integration Guides

Connect With Your Tools

Step-by-step guides for integrating Xpensetrim with popular platforms and services.

Accounting Software
Sync expenses with QuickBooks, Xero, FreshBooks, and other accounting platforms automatically.
Zapier & Make
Build no-code workflows with 5,000+ apps. Trigger actions on new expenses, approvals, and more.
Custom Integrations
Use our REST API and webhooks to build bespoke integrations tailored to your exact requirements.

Pagination

All list endpoints support cursor-based pagination for efficient data retrieval.

bash
# 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
  }
}

Filtering & Sorting

Use query parameters to filter and sort results.

bash
# 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=subscription

Ready to Build?

Start integrating Xpensetrim today. Get your API key, explore the SDKs, and ship your integration in minutes.

logo

Xpensetrim

AI-driven expense-tracking platform designed to simplify financial management.

© 2025 xpensetrim.com. All rights reserved.