AFAdocs
REST API

REST API

AFA REST API reference -- endpoints, authentication, rate limits, and error handling.

REST API

The AFA REST API provides programmatic access to code analysis, enhancement, and gate evaluation. Use it for CI/CD integration, custom tooling, or webhook-driven pipelines.

Base URL

EnvironmentURL
Productionhttps://api.afa.undercurrentholdings.com
Self-hostedhttp://localhost:8080 (default)

Authentication

All endpoints except /v1/health require authentication. Pass your API key as a Bearer token:

curl -H "Authorization: Bearer uk_afa_..." \
  https://api.afa.undercurrentholdings.com/v1/health

See Authentication for details on auth methods and rate limits.

Endpoints

Core

MethodPathDescriptionAuth
GET/v1/healthHealth checkNo
POST/v1/analyzeAnalyze codeYes
POST/v1/enhanceGenerate and validate enhancementsYes
POST/v1/gate-checkEvaluate metrics against gatesYes
GET/v1/historyQuery audit trailYes
GET/v1/metricsPrometheus metricsYes

Customer

MethodPathDescriptionAuth
GET/v1/customer/profileCustomer record + tierYes
GET/v1/customer/usageUsage summaryYes
GET/v1/customer/keysList API keysYes
POST/v1/customer/keysCreate API keyYes
DELETE/v1/customer/keys/\{key_id\}Revoke API keyYes
POST/v1/customer/provisionProvision customer (service auth only)Service

Billing

MethodPathDescriptionAuth
POST/billing/checkoutCreate Stripe checkout sessionYes
POST/billing/webhookStripe webhook receiverStripe signature

Rate limits

Rate limits are enforced per API key via Unkey:

TierRequests/minute
Community15
Developer30
Team100
Enterprise500

When rate-limited, you receive HTTP 429 with a Retry-After: 60 header.

Error format

All errors return a JSON body:

{
  "error": "Error type",
  "detail": "Human-readable description"
}
StatusMeaning
400Bad request (invalid input, unsupported language)
401Authentication required or invalid
403Feature not available on your tier
404Resource not found
422Gate hard floor violation
429Rate limit exceeded
500Internal error (details never exposed)
501Feature not yet implemented

Code size limit

The code field in analyze and enhance requests is capped at 500KB to prevent resource exhaustion via LLM billing amplification.

Starting the server

# Default (port 8080)
afa serve --transport http

# Custom port
afa serve --transport http --port 9090

On this page