Skip to content

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_KEY
SECRET_KEY=sk-ao-SECRET_VALUE

Distinguish 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/ingestion
  • POST /api/public/otel/v1/traces
  • The OpenTelemetry metrics write route (listed as /otel/v1/metrics in the API-key contract)
  • Legacy trace, span, generation, and event writes
  • POST /api/public/media
  • PATCH /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:

  1. Use full-access project keys for server-side integrations that must call read or management-style project endpoints.
  2. Use ingestion-only or other restricted project keys on developer machines and inside agents when they only need to emit telemetry.
  3. Expect 403 instead of 401 when 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 MB total
  • Event envelope fields include id, timestamp, optional event metadata, type, and body
  • The top-level request can also include optional request metadata
  • Inspect both arrays in a 207 response: a successful HTTP exchange does not mean every event succeeded. The per-event error contract does not guarantee 207 for authentication or other request-level failures.
  • The envelope id identifies an event for deduplication. Retrying that same event should retain its ID. To update the same trace with a new event, retain body.id and use a new envelope ID.

Supported event types include:

  • trace-create
  • score-create
  • span-create
  • span-update
  • generation-create
  • generation-update
  • event-create
  • sdk-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:

  1. GET /api/public/projects returns the project associated with the API key.
  2. POST /api/public/projects creates a project.
  3. PUT /api/public/projects/{projectId} updates a project.
  4. DELETE /api/public/projects/{projectId} starts asynchronous deletion and returns 202.

Project fields:

  • id
  • name
  • metadata
  • retentionDays

Retention rules are explicit in the contract:

  • Request field name: retention
  • Must be 0 or at least 3
  • Non-zero retention requires the data-retention entitlement
  • Returned field is retentionDays
  • null or 0 means 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:

  1. GET /api/public/projects/{projectId}/apiKeys
  2. POST /api/public/projects/{projectId}/apiKeys
  3. DELETE /api/public/projects/{projectId}/apiKeys/{apiKeyId}

Create request fields:

  • note optional
  • publicKey optional predefined public key; if provided, it must start with pk-lf-
  • secretKey optional predefined secret key; if provided, it must start with sk-lf-
  • If either predefined key is provided, the other must also be provided

Create response fields include:

  • id
  • createdAt
  • publicKey
  • secretKey
  • displaySecretKey
  • optional note

Implementation details relevant to integrators:

  • Generated key pairs use pk-ao-... and sk-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 ForbiddenError so routes can return 403 for capability failures

Integration advice:

  1. Treat 401-class auth failures as wrong host, wrong header format, invalid key pair, or expired credentials.
  2. Treat 403 as a scope or capability problem rather than bad credentials.
  3. If you use restricted project keys, make sure the target route explicitly supports the required capability.
  4. Do not rely on masked displaySecretKey values for authentication.