Sparkient Docs
API Reference

API Reference

Complete reference for all Sparkient API endpoints.

The Sparkient API is a RESTful JSON API. All endpoints are prefixed with /api/v1 and require authentication via API key or Firebase JWT.

Base URL: https://api.sparkient.ai/api/v1

Endpoints Overview

GroupEndpointsDescription
DecisionsPOST /decide, POST /decide/batchMake single or batch decisions
Decision TypesCRUD on /decision-typesCreate, list, get, update, delete decision types
Examples/decision-types/{id}/examplesManage training examples
Training/decision-types/{id}/trainTrigger model training
Policies/decision-types/{id}/policiesList and deploy trained models
Logs/decision-types/{id}/logsQuery decision history
Export/decision-types/{id}/exportDownload edge bundles
Auth/auth/me, /auth/orgUser and organization management
API Keys/api-keysCreate, list, and revoke API keys
Metrics/metricsOrganization-level aggregate statistics
System/health, /readyHealth and readiness probes

Interactive endpoint documentation is generated automatically from the OpenAPI specification. If you're viewing a freshly built docs site, the detailed endpoint pages will appear below once the OpenAPI spec has been processed.

Common Patterns

Authentication

All requests require a Bearer token:

-H "Authorization: Bearer YOUR_API_KEY"

Error Responses

All errors follow a consistent envelope format with a machine-readable code field:

{
  "error": {
    "code": "decision_type_not_found",
    "message": "Decision type 'nonexistent' not found."
  }
}

Validation errors (422) include a details array:

{
  "error": {
    "code": "validation_error",
    "message": "Request validation failed.",
    "details": [
      {
        "type": "missing",
        "loc": ["body", "decision_type"],
        "msg": "Field required"
      }
    ]
  }
}
StatusCodeDescription
400bad_requestMalformed request
401unauthorizedMissing or invalid credentials
403forbiddenInsufficient permissions
404not_foundResource not found
404decision_type_not_foundDecision type does not exist
413payload_too_largeRequest body exceeds size limit
422validation_errorRequest validation failed
429rate_limitedRate limit exceeded
500internal_errorUnexpected server error

Rate Limiting

API key requests include rate limit headers on every response:

HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets
Retry-AfterSeconds to wait (only on 429 responses)

Pagination

List endpoints support pagination via query parameters:

ParameterDefaultRangeDescription
page1≥ 1Page number
page_size201–100Items per page

Paginated responses return:

{
  "items": ["..."],
  "total": 42,
  "page": 1,
  "page_size": 20,
  "pages": 3
}