Skip to content

API Standards

API Standards

This document defines the API conventions used across the autom8y platform. Following these standards ensures consistency and interoperability between services.

General Principles

1. RESTful Design

APIs follow REST principles where applicable:

  • Use HTTP methods semantically (GET, POST, PUT, DELETE)
  • Resources are nouns, not verbs
  • Use plural resource names (/workflows, not /workflow)

2. Versioning

All APIs are versioned in the URL path:

https://api.autom8y.io/v1/workflows
https://api.autom8y.io/v2/workflows

Request Format

Headers

Required headers for all requests:

HeaderDescriptionExample
Content-TypeRequest body formatapplication/json
AcceptResponse formatapplication/json
AuthorizationAuthenticationBearer <token>
X-Request-IDTracing identifieruuid-v4

Body Structure

Request bodies use JSON with snake_case keys:

{
"workflow_name": "data-sync",
"trigger_type": "schedule",
"schedule_config": {
"cron_expression": "0 */6 * * *",
"timezone": "UTC"
}
}

Response Format

Success Responses

Successful responses wrap data in a consistent envelope:

{
"data": {
"id": "wf_abc123",
"name": "data-sync",
"status": "active",
"created_at": "2024-01-15T10:30:00Z"
},
"meta": {
"request_id": "req_xyz789",
"timestamp": "2024-01-15T10:30:00Z"
}
}

List Responses

Collections include pagination metadata:

{
"data": [
{ "id": "wf_abc123", "name": "workflow-1" },
{ "id": "wf_def456", "name": "workflow-2" }
],
"meta": {
"total": 42,
"page": 1,
"per_page": 20,
"total_pages": 3
}
}

Error Responses

Errors follow RFC 7807 Problem Details format:

{
"type": "https://api.autom8y.io/errors/validation",
"title": "Validation Error",
"status": 400,
"detail": "The 'workflow_name' field is required",
"instance": "/v1/workflows",
"errors": [
{
"field": "workflow_name",
"code": "required",
"message": "This field is required"
}
]
}

Status Codes

Success Codes

CodeMeaningWhen to Use
200OKSuccessful GET, PUT
201CreatedSuccessful POST creating resource
204No ContentSuccessful DELETE

Client Error Codes

CodeMeaningWhen to Use
400Bad RequestInvalid request format
401UnauthorizedMissing/invalid authentication
403ForbiddenInsufficient permissions
404Not FoundResource doesn’t exist
409ConflictResource state conflict
422UnprocessableSemantic validation failure
429Too Many RequestsRate limit exceeded

Server Error Codes

CodeMeaningWhen to Use
500Internal ErrorUnexpected server failure
502Bad GatewayUpstream service failure
503Service UnavailableTemporary unavailability
504Gateway TimeoutUpstream timeout

Authentication

Bearer Tokens

API authentication uses Bearer tokens:

Terminal window
curl -H "Authorization: Bearer <token>" \
https://api.autom8y.io/v1/workflows

Token Scopes

Tokens are scoped to specific permissions:

ScopeAccess
workflows:readRead workflow definitions
workflows:writeCreate/modify workflows
workflows:executeTrigger workflow runs
analytics:readQuery analytics data

Rate Limiting

Limits

Default rate limits per authentication level:

LevelRequests/Minute
Unauthenticated60
Authenticated1000
Service Account5000

Headers

Rate limit status is returned in response headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 950
X-RateLimit-Reset: 1705312800

Pagination

Request Parameters

ParameterDescriptionDefault
pagePage number (1-indexed)1
per_pageItems per page20
sortSort fieldcreated_at
orderSort directiondesc

Example

Terminal window
GET /v1/workflows?page=2&per_page=50&sort=name&order=asc

Filtering

Use query parameters for filtering:

Terminal window
GET /v1/workflows?status=active&trigger_type=schedule

Complex filters use bracket notation:

Terminal window
GET /v1/workflows?created_at[gte]=2024-01-01&created_at[lt]=2024-02-01

Idempotency

For POST/PUT requests, include an idempotency key:

Terminal window
curl -X POST \
-H "Idempotency-Key: unique-request-id" \
https://api.autom8y.io/v1/workflows

The same key within 24 hours returns the cached response.

Next Steps