Docs/Api Reference

API Reference Overview

The Anvil API gives you programmatic access to your leads, collections, conversations, and analytics data. This page provides a high-level overview of the API design and conventions.

Base URL

All API requests should be made to:

https://api.anvilhk.com/v1

All requests must be made over HTTPS. HTTP requests will be rejected.

Authentication

The API uses Bearer token authentication. Include your API key in the Authorization header:

Authorization: Bearer your_api_key_here

You can generate API keys from **Settings > API Keys** in the dashboard. Starter plans have read-only API access, Pro plans have read-write access, and Enterprise plans have full access including admin endpoints.

Request Format

  • Request bodies should be sent as JSON with the `Content-Type: application/json` header
  • Query parameters are used for filtering, pagination, and sorting
  • Dates should be in ISO 8601 format (e.g., `2025-01-15T08:30:00Z`)
  • Response Format

    All responses return JSON with a consistent envelope:

    {
      "success": true,
      "data": { ... },
      "meta": {
        "page": 1,
        "per_page": 20,
        "total": 150
      }
    }

    Error responses follow the same pattern:

    {
      "success": false,
      "error": {
        "code": "RATE_LIMIT_EXCEEDED",
        "message": "You have exceeded the rate limit. Please retry after 60 seconds."
      }
    }

    Error Handling

    Standard HTTP status codes are used:

  • 200: Success
  • 201: Created
  • 400: Bad request (invalid parameters)
  • 401: Unauthorized (invalid or missing API key)
  • 403: Forbidden (insufficient permissions)
  • 404: Not found
  • 429: Rate limit exceeded
  • 500: Internal server error
  • Rate Limits

    Rate limits vary by plan:

    PlanRequests / minuteRequests / day
    Starter6010,000
    Pro300100,000
    Enterprise1,000Unlimited

    Rate limit headers are included in every response: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.

    SDKs

    We provide official SDKs for popular languages:

  • JavaScript / TypeScript: `npm install @anvil/sdk`
  • Python: `pip install anvil`
  • Go: `go get github.com/anvil/anvil-go`
  • Community SDKs are also available for Ruby, PHP, and Java.