Public API integration
Authenticate with project and organization API keys
Section titled “Authenticate with project and organization API keys”AOS server APIs declare Basic Auth as the primary authentication method. For Basic Auth, send the public key as the username and the secret key as the password.
- Username: project or organization public key
- Password: matching secret key
- Auth scheme: Basic Auth
Project API keys are created with either full access or a restricted capability set. Full-access keys satisfy the capability requirement for project endpoints, but project scope and the endpoint’s other authorization and availability checks still apply. Restricted keys are denied unless the route explicitly allows the required capability; if a route does not request a capability, restricted keys are refused with 403.
A separate legacy Bearer path accepts only the project public key and sets accessLevel: "scores". That route access level is different from the key’s stored capabilities, which are still checked. It is not a substitute for Basic Auth with a restricted key pair. Organization-scoped keys are refused on this Bearer path.
Example Basic Auth header:
Authorization: Basic BASE64(PUBLIC_KEY:SECRET_KEY)Example placeholders:
PUBLIC_KEY=pk-ao-PROJECT_OR_ORG_KEYSECRET_KEY=sk-ao-SECRET_VALUEDistinguish project and organization endpoint scope
Section titled “Distinguish project and organization endpoint scope”Project-scoped and organization-scoped authentication are distinct in AOS.
Project-scoped usage:
- Telemetry ingestion endpoints under
/api/public - Project-associated lookup with
GET /api/public/projects - Project keys may be full-access or restricted by capabilities
Organization-scoped usage:
- Required to create a project with
POST /api/public/projects - Required to update or delete a project by ID
- Required to list, create, or delete API keys for a project
The auth layer returns a scope object that identifies whether a validated Basic Auth key is project or organization access. For Basic Auth, the returned access level is derived from the key scope.
Use organization-scoped keys for administrative automation across projects. Use project-scoped keys for project data operations and ingestion.
Use full-access and ingestion-only project keys correctly
Section titled “Use full-access and ingestion-only project keys correctly”AOS documents two project API key access levels:
- Full access: satisfies project endpoint capability checks within the key’s project; other route checks still apply
- Ingestion only: limited to telemetry write routes and selected write-only media and score routes
The documented ingestion-only allowlist includes:
POST /api/public/ingestionPOST /api/public/otel/v1/traces- The OpenTelemetry metrics write route (listed as
/otel/v1/metricsin the API-key contract) - Legacy trace, span, generation, and event writes
POST /api/public/mediaPATCH /api/public/media/{mediaId}POST /api/public/scores
Every other endpoint returns 403 for ingestion-only keys.
In enforcement code, restricted project keys are capability-checked per route. If a route does not declare a required capability, restricted keys are rejected by default. Full-access keys are represented by [*] and pass this capability check; this does not bypass key expiry, project sealing, or other endpoint checks.
Practical guidance:
- Use full-access project keys for server-side integrations that must call read or management-style project endpoints.
- Use ingestion-only or other restricted project keys on developer machines and inside agents when they only need to emit telemetry.
- Expect
403instead of401when a key is valid but lacks the needed capability.
Send telemetry to the legacy ingestion endpoint
Section titled “Send telemetry to the legacy ingestion endpoint”For new telemetry integrations, the API contract recommends OpenTelemetry at POST /api/public/otel/v1/traces. The legacy batch endpoint is deprecated.
The legacy batch ingestion endpoint is POST /api/public/ingestion and requires authentication. It accepts a batch of discriminated ingestion events and responds with HTTP 207 containing separate successes and errors arrays.
Key contract details:
- Base path:
/api/public - Endpoint:
POST /ingestion - Response status:
207 - Batch size ceiling:
3.5 MBtotal - Event envelope fields include
id,timestamp, optional eventmetadata,type, andbody - The top-level request can also include optional request
metadata - Inspect both arrays in a
207response: a successful HTTP exchange does not mean every event succeeded. The per-event error contract does not guarantee207for authentication or other request-level failures. - The envelope
ididentifies an event for deduplication. Retrying that same event should retain its ID. To update the same trace with a new event, retainbody.idand use a new envelope ID.
Supported event types include:
trace-createscore-createspan-createspan-updategeneration-creategeneration-updateevent-createsdk-log- Deprecated:
observation-create,observation-update
Example request with placeholders:
{ "batch": [ { "id": "EVENT_ID", "timestamp": "2026-01-01T00:00:00.000Z", "type": "trace-create", "body": { "id": "TRACE_ID", "timestamp": "2026-01-01T00:00:00.000Z", "environment": "production", "name": "Example trace", "input": "Example input", "output": "Example output" } } ]}Example response shape:
{ "successes": [ { "id": "EVENT_ID", "status": 201 } ], "errors": []}Create and manage projects with organization-scoped keys
Section titled “Create and manage projects with organization-scoped keys”Project management endpoints are under /api/public/projects and require an organization-scoped API key for create, update, delete, and project API key management.
Available endpoints:
GET /api/public/projectsreturns the project associated with the API key.POST /api/public/projectscreates a project.PUT /api/public/projects/{projectId}updates a project.DELETE /api/public/projects/{projectId}starts asynchronous deletion and returns202.
Project fields:
idnamemetadataretentionDays
Retention rules are explicit in the contract:
- Request field name:
retention - Must be
0or at least3 - Non-zero retention requires the
data-retentionentitlement - Returned field is
retentionDays nullor0means no retention; field may also be omitted when not configured
Example create request:
{ "name": "PROJECT_NAME", "metadata": { "team": "example" }, "retention": 7}Deletion is asynchronous, so callers should treat a 202 response as accepted rather than completed.
Create project API keys and understand returned credentials
Section titled “Create project API keys and understand returned credentials”AOS exposes project API key management endpoints under /api/public/projects/{projectId}/apiKeys. These endpoints require an organization-scoped API key.
Available operations:
GET /api/public/projects/{projectId}/apiKeysPOST /api/public/projects/{projectId}/apiKeysDELETE /api/public/projects/{projectId}/apiKeys/{apiKeyId}
Create request fields:
noteoptionalpublicKeyoptional predefined public key; if provided, it must start withpk-lf-secretKeyoptional predefined secret key; if provided, it must start withsk-lf-- If either predefined key is provided, the other must also be provided
Create response fields include:
idcreatedAtpublicKeysecretKeydisplaySecretKey- optional
note
Implementation details relevant to integrators:
- Generated key pairs use
pk-ao-...andsk-ao-...formats in the key generation helper. - The display form of a secret key is masked and is not the full secret.
- Secret keys are stored hashed; a fast SHA-based hash is also stored for lookup.
- API key creation logic defaults capabilities to full access when no capability list is supplied.
Example create request with placeholders:
{ "note": "CI key"}Example predefined key request with placeholders:
{ "note": "Imported key", "publicKey": "pk-lf-PUBLIC_KEY", "secretKey": "sk-lf-SECRET_KEY"}Handle auth and key failures in integrations
Section titled “Handle auth and key failures in integrations”AOS distinguishes invalid credentials from insufficient capability.
Expected behaviors:
- Missing or malformed auth header: authentication fails
- Expired key: treated as invalid credentials
- Valid restricted key without the required capability:
403 - Invalid public key or secret key: authentication fails
- Organization key used with Bearer auth: rejected
Implementation-backed details:
- Basic Auth credentials are parsed from
Authorization: Basic ... - Bearer auth uses only the public key
- Expiry is enforced for both cached Basic keys and database-backed Bearer keys
- Error handling preserves
ForbiddenErrorso routes can return403for capability failures
Integration advice:
- Treat
401-class auth failures as wrong host, wrong header format, invalid key pair, or expired credentials. - Treat
403as a scope or capability problem rather than bad credentials. - If you use restricted project keys, make sure the target route explicitly supports the required capability.
- Do not rely on masked
displaySecretKeyvalues for authentication.