API Reference
API Reference
The TradeKitt API is a RESTful JSON API available at https://api.tradekitt.com/api/v1. All endpoints use the /api/v1 prefix. Successful responses are wrapped as { "ok": true, "data": ... } and errors as { "ok": false, "error": { "code": "...", "message": "..." } }.
Interactive Swagger documentation is available at /api/docs on development instances.
Authentication
TradeKitt uses JWT (JSON Web Token) bearer authentication. Access tokens expire after 15 minutes. Use the refresh token to obtain a new access token without re-authenticating.
Login Flow
- Resolve the tenant by business code.
- Authenticate with username and password.
- If MFA is required, complete the MFA challenge.
- Use the returned access token for subsequent requests.
Step 1: Resolve Tenant
curl https://api.tradekitt.com/api/v1/tenants/resolve/MYCOMPANY
Response:
{
"ok": true,
"data": {
"businessCode": "MYCOMPANY",
"businessName": "My Company LLC",
"apiUrl": "https://api.tradekitt.com",
"tenantId": "uuid-here",
"branding": {
"display_name": "My Company",
"primary_color": "#2563eb"
}
}
}
Step 2: Login
Include the X-Tenant-Id header with the tenant UUID from the resolve step.
curl -X POST https://api.tradekitt.com/api/v1/auth/login \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"username": "admin", "password": "your-password"}'
Response (no MFA):
{
"ok": true,
"data": {
"access_token": "eyJ...",
"refresh_token": "eyJ...",
"user": {
"id": 1,
"username": "admin",
"name": "Admin User",
"is_admin": true,
"roles": ["admin"]
}
}
}
Response (MFA required):
{
"ok": true,
"data": {
"mfa_required": true,
"mfa_challenge_token": "eyJ..."
}
}
Step 3: MFA Verification (if required)
curl -X POST https://api.tradekitt.com/api/v1/auth/mfa-verify \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"challenge_token": "eyJ...", "code": "123456"}'
Accepts TOTP codes from authenticator apps, email OTP codes, or backup codes.
Step 4: Refresh Token
curl -X POST https://api.tradekitt.com/api/v1/auth/refresh \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"refresh_token": "eyJ..."}'
Response:
{
"ok": true,
"data": {
"access_token": "eyJ..."
}
}
JavaScript Login Example
const API_BASE = 'https://api.tradekitt.com/api/v1';
async function login(businessCode, username, password) {
// Step 1: Resolve tenant
const resolveRes = await fetch(`${API_BASE}/tenants/resolve/${businessCode}`);
const { data: tenant } = await resolveRes.json();
// Step 2: Authenticate
const loginRes = await fetch(`${API_BASE}/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Tenant-Id': tenant.tenantId,
},
body: JSON.stringify({ username, password }),
});
const { data } = await loginRes.json();
if (data.mfa_required) {
// Prompt user for MFA code, then call /auth/mfa-verify
return { mfaRequired: true, challengeToken: data.mfa_challenge_token };
}
return {
accessToken: data.access_token,
refreshToken: data.refresh_token,
user: data.user,
};
}
Self-Service Registration
curl -X POST https://api.tradekitt.com/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"username": "mycompany",
"password": "securePassword123!",
"first_name": "Jane",
"last_name": "Smith",
"company_name": "Smith HVAC"
}'
Returns tokens for immediate auto-login along with the new business_code and business_name.
SSO Authentication
TradeKitt supports Google, Apple, and Microsoft SSO. Pass the identity token from each provider:
# Google SSO login
curl -X POST https://api.tradekitt.com/api/v1/auth/sso/google \
-H "Content-Type: application/json" \
-d '{"id_token": "eyJ..."}'
SSO is also available for registration (/auth/sso/google/register) and account linking (/auth/sso/google/link).
Sales
Record and manage sales with automatic commission calculation.
Record a Sale
curl -X POST https://api.tradekitt.com/api/v1/sales \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-H "Idempotency-Key: unique-key-123" \
-d '{
"technician_id": 1,
"item_id": 5,
"sale_price_cents": 150000,
"customer_name": "John Doe",
"notes": "Annual maintenance package",
"payment_type": "credit_card"
}'
Idempotency: Include an Idempotency-Key header to prevent duplicate sales. Duplicate requests within 24 hours return the cached response.
Commission snapshot: When a sale is recorded, the current commission rates for that technician and line item are frozen into the sale record. Future rate changes do not affect past commissions.
List Sales
curl "https://api.tradekitt.com/api/v1/sales?date_from=2026-01-01&date_to=2026-03-31" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Update Payment Status
curl -X PATCH https://api.tradekitt.com/api/v1/sales/42/payment-status \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"status": "paid", "payment_date": "2026-03-15"}'
Void a Sale
curl -X PATCH https://api.tradekitt.com/api/v1/sales/42/void \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"voided": true}'
JavaScript Example
async function recordSale(accessToken, tenantId, saleData) {
const res = await fetch(`${API_BASE}/sales`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'X-Tenant-Id': tenantId,
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify(saleData),
});
const { ok, data, error } = await res.json();
if (!ok) throw new Error(error.message);
return data;
}
Technicians
List Technicians
curl "https://api.tradekitt.com/api/v1/admin/technicians?page=1&limit=50" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Create a Technician
curl -X POST https://api.tradekitt.com/api/v1/admin/technicians \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"name": "Mike Johnson",
"pay_type": "hourly",
"base_pay_cents": 2500
}'
Update a Technician
curl -X PATCH https://api.tradekitt.com/api/v1/admin/technicians/1 \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"base_pay_cents": 2800}'
Configure Commission Rates
Set a per-item commission rate for a technician:
curl -X PUT https://api.tradekitt.com/api/v1/admin/commission-config/tech/1/item/5 \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"commission_rate_bps": 750,
"ov_rate_bps": 0,
"discount_scale_enabled": false
}'
This sets a 7.5% commission rate (750 basis points) for technician 1 on line item 5.
Performance Scorecard
curl "https://api.tradekitt.com/api/v1/admin/technicians/metrics?date_from=2026-01-01&date_to=2026-03-31" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Returns completion rates, average job duration, customer ratings, revenue per job, and leaderboard rankings.
Customers
List Customers
curl "https://api.tradekitt.com/api/v1/admin/customers?page=1&limit=50" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Customer Analytics
curl "https://api.tradekitt.com/api/v1/admin/analytics/customers?sortBy=totalSpend&page=1&limit=20" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Returns spend totals, visit frequency, and recency metrics per customer.
Customer Portal
Customers have their own authentication system separate from the main user system:
# Customer registration
curl -X POST https://api.tradekitt.com/api/v1/customer/register \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "customerPassword123!",
"first_name": "Jane",
"last_name": "Doe"
}'
# Customer login
curl -X POST https://api.tradekitt.com/api/v1/customer/login \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "password": "customerPassword123!"}'
Customer portal features include service request submission, invoice viewing, and review posting.
Dispatch
Create a Dispatch Job
curl -X POST https://api.tradekitt.com/api/v1/admin/dispatch \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"title": "AC Repair - Smith Residence",
"description": "Unit not cooling, thermostat reads 85F",
"priority": "high",
"customer_name": "John Smith",
"service_address": "123 Oak St",
"service_city": "Tampa",
"service_state": "FL",
"service_zip": "33601",
"scheduled_start": "2026-03-28T09:00:00Z",
"scheduled_end": "2026-03-28T11:00:00Z"
}'
Dispatch Job Status Workflow
Jobs follow this status progression:
pending -> dispatched -> acknowledged -> en_route -> on_site -> in_progress -> completed
-> cancelled
Assign a Technician
curl -X PATCH https://api.tradekitt.com/api/v1/admin/dispatch/42/assign \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"technician_id": 3}'
Smart Dispatch
Get AI-powered technician assignment suggestions based on skills, service zones, and current location:
curl "https://api.tradekitt.com/api/v1/admin/dispatch/42/suggestions" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Dispatch Board (Real-Time)
curl "https://api.tradekitt.com/api/v1/admin/dispatch/board?date=2026-03-28" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Real-Time Updates via SSE
Subscribe to dispatch board events via Server-Sent Events:
const eventSource = new EventSource(
`${API_BASE}/admin/dispatch/stream`,
{
headers: {
'Authorization': `Bearer ${accessToken}`,
'X-Tenant-Id': tenantId,
},
}
);
eventSource.onmessage = (event) => {
const update = JSON.parse(event.data);
console.log('Dispatch update:', update);
};
Route Optimization
curl -X POST https://api.tradekitt.com/api/v1/admin/dispatch/optimize-routes \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"date": "2026-03-28"}'
Technician Dispatch Endpoints
Technicians interact with their assigned jobs:
# View my jobs
curl "https://api.tradekitt.com/api/v1/tech/dispatch/my-jobs?date=2026-03-28" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
# Acknowledge a job
curl -X PATCH https://api.tradekitt.com/api/v1/tech/dispatch/my-jobs/42/acknowledge \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
# Update status with GPS
curl -X PATCH https://api.tradekitt.com/api/v1/tech/dispatch/my-jobs/42/status \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"status": "on_site", "latitude": 27.9506, "longitude": -82.4572}'
# Report GPS location
curl -X POST https://api.tradekitt.com/api/v1/tech/dispatch/location \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"latitude": 27.9506, "longitude": -82.4572, "speed": 35.5, "heading": 180}'
Invoices
Create an Invoice
curl -X POST https://api.tradekitt.com/api/v1/admin/invoices \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"customer_name": "John Doe",
"customer_email": "[email protected]",
"line_items": [
{"description": "AC Repair", "amount_cents": 15000, "quantity": 1}
],
"due_date": "2026-04-15"
}'
Recurring Invoices
Recurring invoices are auto-generated daily from active service agreements. Manage them via:
# List recurring invoices
curl "https://api.tradekitt.com/api/v1/admin/recurring-invoices?page=1&limit=50" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Estimates
Create an Estimate
curl -X POST https://api.tradekitt.com/api/v1/admin/estimates \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"customer_name": "Jane Smith",
"customer_email": "[email protected]",
"line_items": [
{"description": "New HVAC System", "amount_cents": 850000, "quantity": 1},
{"description": "Installation Labor", "amount_cents": 250000, "quantity": 1}
],
"valid_until": "2026-04-30"
}'
Estimates can be sent to the customer for review, and they can accept or decline online.
Inventory
Parts Catalog
# List parts
curl "https://api.tradekitt.com/api/v1/admin/parts?page=1&limit=50" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
# Create a part
curl -X POST https://api.tradekitt.com/api/v1/admin/parts \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"name": "Capacitor 35/5 MFD",
"sku": "CAP-355-MFD",
"cost_cents": 1200,
"price_cents": 4500,
"min_stock": 10
}'
Stock Management
# View stock levels
curl "https://api.tradekitt.com/api/v1/admin/inventory/stock" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
# Record stock receipt
curl -X POST https://api.tradekitt.com/api/v1/admin/inventory/receive \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"part_id": 1, "location_id": 1, "quantity": 50, "notes": "PO #1234"}'
When stock falls below a part’s min_stock threshold, an inventory.low-stock event is emitted and (if enabled) an auto-reorder purchase order is created.
Purchase Orders
# Create a purchase order
curl -X POST https://api.tradekitt.com/api/v1/admin/purchase-orders \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"supplier_id": 1,
"items": [
{"part_id": 1, "quantity": 100, "unit_cost_cents": 1100}
]
}'
Time Tracking
Clock In/Out
# Clock in
curl -X POST https://api.tradekitt.com/api/v1/time-tracking/clock-in \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"latitude": 27.9506, "longitude": -82.4572}'
# Clock out
curl -X POST https://api.tradekitt.com/api/v1/time-tracking/clock-out \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{"latitude": 27.9506, "longitude": -82.4572}'
List Time Entries
curl "https://api.tradekitt.com/api/v1/time-tracking/entries?date_from=2026-03-01&date_to=2026-03-31" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Duration is calculated as (clockOut - clockIn) - breakMinutes. Entries with a null clockOut indicate the technician is still clocked in.
Webhooks
Create a Webhook Endpoint
curl -X POST https://api.tradekitt.com/api/v1/admin/webhooks \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: <tenant-uuid>" \
-d '{
"url": "https://your-server.com/webhooks/tradekitt",
"events": ["sale.created", "dispatch.completed", "inventory.low-stock"]
}'
Available Webhook Events
| Event | Description |
|---|---|
sale.created | A new sale has been recorded |
sale.approved | A sale has been approved |
sale.rejected | A sale has been rejected |
dispatch.created | A new dispatch job was created |
dispatch.assigned | A technician was assigned to a job |
dispatch.completed | A dispatch job was completed |
commission.calculated | Commission was calculated for a sale |
payment.reconciled | A payment was matched via reconciliation |
agreement.renewed | A service agreement was auto-renewed |
agreement.expired | A service agreement expired |
inventory.low-stock | Stock fell below minimum threshold |
Webhook Delivery
- Payloads are JSON with the event type and full event data.
- Failed deliveries (non-2xx responses) are retried automatically.
- Each delivery attempt is logged with response code and timing.
- Payloads are signed for verification.
List Webhook Endpoints
curl "https://api.tradekitt.com/api/v1/admin/webhooks" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Pay Periods
List Pay Periods
curl "https://api.tradekitt.com/api/v1/admin/pay-periods" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Close a Pay Period
Closing a pay period freezes commission snapshots for all technicians:
curl -X PATCH https://api.tradekitt.com/api/v1/admin/pay-periods/1/close \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Export Pay Period as CSV
curl "https://api.tradekitt.com/api/v1/admin/csv-export/pay-period/1" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>" \
-o pay-period-1.csv
Analytics
Sales Projections
Seasonal projections using trade-specific decomposition:
curl "https://api.tradekitt.com/api/v1/admin/analytics/projections?horizon=6&metric=revenue" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Growth Metrics
curl "https://api.tradekitt.com/api/v1/admin/analytics/growth?dateFrom=2025-01-01&dateTo=2026-03-31" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Returns month-over-month, year-over-year, CAGR, and moving averages.
Geographic Heatmap
curl "https://api.tradekitt.com/api/v1/admin/analytics/geo-heatmap?metric=revenue&groupBy=zip" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Service Agreements
# List agreements
curl "https://api.tradekitt.com/api/v1/admin/service-agreements?page=1&limit=50" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
# Get expiring agreements
curl "https://api.tradekitt.com/api/v1/admin/service-agreements/expiring?days=30" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>"
Agreements with autoRenew=true are automatically renewed 30 days before expiry. Maintenance visits are auto-scheduled based on visitsPerYear.
Rate Limits
| Scope | Limit | Window |
|---|---|---|
| Global (per IP) | 300 requests | 60 seconds |
| Per tenant | 200 requests | 60 seconds |
| Auth endpoints | 5 requests | 60 seconds |
When you exceed the limit, the API returns 429 Too Many Requests with a Retry-After header.
Pagination
All list endpoints support pagination via query parameters:
| Parameter | Default | Max | Description |
|---|---|---|---|
page | 1 | — | Page number (must be > 0) |
limit | 50 | 200 | Items per page (must be > 0) |
Response format:
{
"ok": true,
"data": {
"items": [...],
"total": 150,
"page": 1,
"limit": 50,
"total_pages": 3
}
}
Error Responses
All error responses follow this format:
{
"ok": false,
"error": {
"code": "ERROR_CODE",
"message": "Human-readable description"
}
}
Common Error Codes
| HTTP Status | Code | Description |
|---|---|---|
| 400 | BAD_REQUEST | Invalid request body or parameters |
| 401 | UNAUTHORIZED | Missing or invalid authentication token |
| 403 | FORBIDDEN | Insufficient permissions |
| 404 | NOT_FOUND | Resource not found |
| 409 | CONFLICT | Resource already exists (e.g., duplicate username) |
| 422 | VALIDATION_ERROR | Request body failed validation |
| 429 | TOO_MANY_REQUESTS | Rate limit exceeded |
| 500 | INTERNAL_ERROR | Server error |
Wire Format
The API uses snake_case for all JSON field names in both requests and responses. Internally the platform uses camelCase, but conversion happens automatically at the API boundary.
Money values are always represented as integer cents (e.g., 150000 = $1,500.00). Never use floating-point for monetary values.
Rates are stored as basis points (1 bps = 0.01%). For example, 750 bps = 7.50%.
CSV Export
CSV export endpoints bypass the standard JSON response wrapper and return raw CSV data with Content-Type: text/csv:
# Export commission report
curl "https://api.tradekitt.com/api/v1/admin/csv-export/commission-report?date_from=2026-01-01&date_to=2026-03-31" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>" \
-o commission-report.csv
# Export sales data
curl "https://api.tradekitt.com/api/v1/admin/csv-export/sales" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>" \
-o sales.csv
Cents are converted to dollars in CSV output for readability.
PDF Export
PDF endpoints return raw PDF data with Content-Type: application/pdf:
# Commission statement for a technician
curl "https://api.tradekitt.com/api/v1/export/commission-statement/1/3/pdf" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>" \
-o statement.pdf
# Full pay period report
curl "https://api.tradekitt.com/api/v1/export/pay-period/3/pdf" \
-H "Authorization: Bearer <access_token>" \
-H "X-Tenant-Id: <tenant-uuid>" \
-o pay-period.pdf
Additional Endpoints
The API includes many more endpoints for advanced features. Key endpoint groups not covered in detail above:
- Expenses (
/admin/expenses) — expense tracking with approval workflow - Job Costing (
/admin/job-costing) — per-job cost aggregation - Form Builder (
/admin/forms) — custom forms for work orders and inspections - Report Builder (
/admin/reports) — dynamic report templates with scheduled delivery - SLA Management (
/admin/sla) — response/resolution time policies and violation tracking - Fleet Management (
/admin/vehicles) — vehicle tracking and maintenance alerts - Service Zones (
/admin/service-zones) — geographic zone management - Technician Skills (
/admin/technician-skills) — skill tracking for smart dispatch - Customer Communications (
/admin/customer-communications) — unified communications log - Automated Follow-ups (
/admin/follow-ups) — configurable follow-up rules - Leads (
/admin/leads) — lead tracking and conversion
For the complete endpoint listing with all request/response schemas, consult the Swagger UI at /api/docs on your development instance.
Next Steps
- Getting Started — set up your account
- Admin Guide — full admin configuration reference
- Integrations — connect payment processors and field service tools
- FAQ — common questions answered