Authentication
Every request to a /v1/* endpoint authenticates with one header: an API key sent as a bearer token. A recognized key returns 200 with the standard data + meta envelope:
curl -s https://astral-external-api-iksoi6t3nq-ue.a.run.app/v1/western/positions \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"subject": {"datetime": "1990-05-15T14:30:00-04:00"}}' | jqThat single header is the entire model — no token endpoint, no refresh step, no expiring token to manage. Only the health probes GET /health and GET /ready are unauthenticated, so load balancers and uptime checks can reach them without a key.
Key format
Section titled “Key format”Keys are prefixed by environment:
| Prefix | Use |
|---|---|
ak_test_ |
Development and evaluation |
ak_live_ |
Production traffic |
The prefix is safe to expose: in a log line, a config diff, or a secret-scanner rule you can tell which environment a key belongs to without revealing the rest of it. Log the prefix; never the full key.
Getting a key
Section titled “Getting a key”The API is in early access, so keys are provisioned by hand. Request one through your Astral contact and you receive an ak_test_ key, plus an ak_live_ key when you are ready for production.
Export your key so the examples across these docs can use it:
export API_KEY=ak_test_your_key_hereWhen authentication fails
Section titled “When authentication fails”Every auth failure returns 401 with an RFC 9457 problem body, and one of two codes says which failure it was. Branch on the code field, not the title text.
A request with no Authorization header returns auth.missing:
curl -s https://astral-external-api-iksoi6t3nq-ue.a.run.app/v1/western/positions \ -H "Content-Type: application/json" \ -d '{"subject": {"datetime": "1990-05-15T14:30:00-04:00"}}'A key the API does not recognize — revoked, mistyped, or from the wrong environment — returns auth.invalid_key:
curl -s https://astral-external-api-iksoi6t3nq-ue.a.run.app/v1/western/positions \ -H "Authorization: Bearer ak_test_not_a_real_key" \ -H "Content-Type: application/json" \ -d '{"subject": {"datetime": "1990-05-15T14:30:00-04:00"}}'See Errors for the full catalog.
Rotating keys
Section titled “Rotating keys”An account can hold two active keys at once, so a replacement can be live before you retire the key it replaces — rotation never requires downtime.
- Request a second key. Both keys now authenticate.
- Deploy the new key to your services.
- Confirm no requests are still arriving on the old key.
- Revoke the old key.
Rotate on whatever schedule you set, and immediately if a key may have leaked. During early access, steps 1 and 4 go through your Astral contact.
Keeping keys secret
Section titled “Keeping keys secret”- Environment variables, not source code. Inject keys through your deployment environment or secret manager. A key committed to a repository is a key to rotate.
- Server-side only. Never ship a key in a browser bundle, a mobile app, or anything else running on hardware you don’t control — anyone can extract it. Route those clients through your own backend, which holds the key and calls the API.
- Log the prefix, not the key. The
ak_test_/ak_live_prefix is safe in logs; the remainder is not.
API spec v0.1.0 · docs 1123b41