Skip to content

API Reference

This section documents the Anvil REST API for developers integrating with or extending the platform.

Base URL

EnvironmentURL
Productionhttps://api.anvil.app
Developmenthttp://localhost:3001

Authentication

All API endpoints require authentication via JWT tokens:

http
Authorization: Bearer <your-jwt-token>

Additional headers for enhanced security:

  • X-Session-ID - Session identifier
  • X-Device-Fingerprint - Client device fingerprint

See Authentication for details on obtaining tokens.

Interactive Documentation

When running the Anvil server locally, interactive Swagger UI is available at:

http://localhost:3001/api/docs

You can:

  • Browse all endpoints
  • View request/response schemas
  • Try out API calls directly
  • Download OpenAPI specification

OpenAPI Specification

Download the full OpenAPI 3.0 specification:

  • JSON: GET /api/docs/openapi.json
  • YAML: GET /api/docs/openapi.yaml

API Sections

Core Resources

SectionDescription
AuthenticationLogin, logout, MFA, sessions
Work OrdersJob/work order management
TasksWork order task management
ContactsClient and vendor management

Operations

SectionDescription
Time TrackingClock in/out, time entries
InventoryMaterial catalog, stock levels
PayrollPayroll periods and processing

Administration

SectionDescription
RolesRole and permission management
UsersUser management
OrganizationOrganization settings

Common Patterns

Response Format

Successful responses:

json
{
  "ok": true,
  "data": { ... }
}

Error responses:

json
{
  "error": "Human-readable message",
  "code": "ERROR_CODE",
  "details": { ... }
}

HTTP Status Codes

CodeMeaning
200Success
201Created
400Bad Request (validation error)
401Unauthorized (invalid/missing token)
403Forbidden (insufficient permissions)
404Not Found
429Rate Limited
500Internal Server Error

Pagination

List endpoints support pagination:

http
GET /api/work-orders?page=1&limit=20

Response includes pagination info:

json
{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  }
}

Filtering

Most list endpoints support filtering via query parameters:

http
GET /api/work-orders?status=pending&priority=high&employee_id=5

Multi-Tenancy

All data is automatically scoped to the authenticated user's organization. Cross-tenant access is blocked at multiple layers.

Superadmins can specify a target organization:

http
GET /api/work-orders?organization_id=123

Rate Limiting

User TypeLimit
Authenticated100 requests/minute
Unauthenticated20 requests/minute

Rate limit headers:

http
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1703001600

SDKs & Libraries

Currently available:

  • JavaScript/TypeScript: Coming soon
  • Python: Coming soon

For now, use any HTTP client with the REST API directly.

Support

Released under the MIT License.