API Documentation

Learn how to integrate with SupportContract.app's API to automate your support contract billing.

Getting Started

To use the SupportContract.app API, you'll need an API token for your project. API tokens are scoped to specific projects within your account.

Note: All API endpoints require account and project scoping for security.

Authentication

Include your API token in the Authorization header:

Authorization: Bearer YOUR_API_TOKEN

Metric Readings API

Submit usage data for your support contracts.

Create Metric Reading

POST /api/v1/{account_slug}/projects/{project_slug}/metric_readings

Request Body:

{
  "metric_reading": {
    "metric_type": "new_signups",
    "value": 150.0,
    "period_start_at": "2024-01-01T00:00:00Z",
    "period_end_at": "2024-01-07T23:59:59Z",
    "week_number": 1
  }
}

Parameters:

  • metric_type - Name of the metric type (required)
  • value - Numeric value for the metric (required)
  • period_start_at - Start of the measurement period (required)
  • period_end_at - End of the measurement period (required)
  • week_number - Week number for weekly metrics (optional)

Response:

{
  "success": true,
  "message": "Metric reading created successfully",
  "data": {
    "id": 123,
    "metric_type": "new_signups",
    "value": "150.0",
    "period_start_at": "2024-01-01T00:00:00Z",
    "period_end_at": "2024-01-07T23:59:59Z",
    "recorded_at": "2024-01-08T10:30:00Z",
    "week_number": 1,
    "project_id": 456,
    "account_slug": "your-account",
    "project_slug": "your-project"
  }
}

Error Handling

The API returns standard HTTP status codes and JSON error responses:

  • 401 Unauthorized - Invalid or missing API token
  • 403 Forbidden - API token not valid for the specified project
  • 404 Not Found - Account or project not found
  • 422 Unprocessable Entity - Validation errors

Need Help?

If you need assistance with the API or have questions about integration, contact our support team.