DEVELOPER DOCS

REST API

Alignment

On this page

Alignment checks agent behaviour against your written policy. You upload the policy documents; the alignment engine flags where agent output diverged from them.


Get alignment policy

HTTP
GET /v1/observ/orgs/{org}/workspaces/{ws}/alignment/policy

Auth: API key or JWT · Role: viewer

Response 200 — not schema-modelled

JSON
{ "enabled": true, "description": "Support agents must never promise a refund window shorter than 30 days." }

Examples

p = evigauge.get("/v1/observ/orgs/{org}/workspaces/{ws}/alignment/policy")
print(p["enabled"], p["description"])

Set alignment policy

HTTP
PUT /v1/observ/orgs/{org}/workspaces/{ws}/alignment/policy

Auth: API key or JWT · Role: admin

Request body — _PolicyBody

FieldTypeRequiredDefaultDescription
descriptionstring➖""Natural-language statement of the policy
enabledboolean➖falseWhether the alignment engine runs for this workspace

Examples

evigauge.put("/v1/observ/orgs/{org}/workspaces/{ws}/alignment/policy", json={
    "enabled": True,
    "description": "Never promise a refund window shorter than 30 days.",
})

Upload an alignment document

HTTP
POST /v1/observ/orgs/{org}/workspaces/{ws}/alignment/docs

Upload a policy document. Ingestion is asynchronous — the document is chunked and embedded into the workspace's vector store before it influences flags.

Auth: API key or JWT · Role: admin

Request body — multipart/form-data

FieldTypeRequiredDescription
filebinary✅The document to upload

Examples

import httpx, os

with open("refund-policy.pdf", "rb") as fh:
    r = httpx.post(
        "https://api.opexia.dev/v1/observ/orgs/acme/workspaces/prod/alignment/docs",
        headers={"x-opexia-api-key": os.environ["OPEXIA_API_KEY"]},
        files={"file": ("refund-policy.pdf", fh, "application/pdf")},
        timeout=120,
    )
r.raise_for_status()
print(r.json())

Do not set content-type manually on a multipart request. Both httpx and fetch derive the boundary automatically; overriding it corrupts the body.


Delete an alignment document

HTTP
DELETE /v1/observ/orgs/{org}/workspaces/{ws}/alignment/docs/{doc_id}

Removes the document and its embeddings from the workspace store.

Auth: API key or JWT · Role: admin

Path parameters

NameTypeRequiredDescription
orgstring✅Organization slug
wsstring✅Workspace slug
doc_idstring✅Document ID returned at upload

Examples

evigauge.delete(f"/v1/observ/orgs/{{org}}/workspaces/{{ws}}/alignment/docs/{doc_id}")

List alignment flags

HTTP
GET /v1/observ/orgs/{org}/workspaces/{ws}/alignment/flags

Cases where agent output diverged from policy.

Auth: API key or JWT · Role: viewer

Query parameters

NameTypeRequiredDefaultDescription
limitinteger➖50Page size
offsetinteger➖0Offset for paging
include_unclearboolean➖falseInclude low-confidence flags the engine could not resolve

This endpoint uses offset paging, not cursors — it is one of the few that does.

Response 200 — not schema-modelled

JSON
{
  "flags": [
    {
      "flag_id": "af_01J8...",
      "trace_id": "4bf92f...",
      "policy_excerpt": "Refunds are available for 30 days from delivery.",
      "agent_output": "You can request a refund within 14 days.",
      "severity": "high",
      "confidence": 0.91,
      "created_at": "2026-09-01T14:23:05Z"
    }
  ],
  "total": 1
}

Examples

f = evigauge.get("/v1/observ/orgs/{org}/workspaces/{ws}/alignment/flags",
                 params={"limit": 25, "include_unclear": False})
for x in f["flags"]:
    print(f"[{x['severity']}] {x['trace_id']}: {x['agent_output'][:70]}")

Alignment by user

HTTP
GET /v1/observ/orgs/{org}/workspaces/{ws}/alignment/by-user

Alignment flags aggregated per end user (opexia.end_user), showing which users' sessions most often produce policy divergence.

Auth: API key or JWT · Role: viewer

Examples

bu = evigauge.get("/v1/observ/orgs/{org}/workspaces/{ws}/alignment/by-user")
print(bu)

Requires that your instrumentation sets the opexia.end_user span attribute. Without it this endpoint returns an empty result rather than an error.