{"openapi":"3.1.0","info":{"title":"SupaTrace Management API","version":"1.0.0-alpha","description":"Alpha. Authenticate with a personal access token created in the dashboard (Settings). Send it as `Authorization: Bearer <token>`; on https://supatrace.dev send it as `X-Supatrace-Key: <token>`, because the hosted edge replaces the Authorization header. A token issued with an explicit `write` scope may also create and revoke write keys on `/api/v1/keys`; every other token stays read-only. Errors are `{\"error\": \"<code>\"}`."},"servers":[{"url":"/"}],"security":[{"bearerToken":[]},{"keyHeader":[]}],"paths":{"/api/v1/me":{"get":{"operationId":"getMe","summary":"The account and token making the request","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/workspaces":{"get":{"operationId":"listWorkspaces","summary":"Workspaces the account can open","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceList"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects":{"get":{"operationId":"listProjects","summary":"Projects the account can open","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProjectList"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/keys":{"get":{"operationId":"listKeys","summary":"Write keys of a workspace environment (owner or admin)","parameters":[{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."},{"name":"project","in":"query","schema":{"type":"string"},"description":"Project id. Defaults to the workspace default project; a secret key defaults to its bound project."},{"name":"environment","in":"query","schema":{"type":"string"},"description":"Environment id. Defaults to `default`."},{"name":"after","in":"query","schema":{"type":"string"},"description":"Cursor from the previous page's `next`."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyList"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Viewer role, or workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"createKey","summary":"Create a publishable or secret write key and return it once (owner or admin, write token)","parameters":[{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."},{"name":"project","in":"query","schema":{"type":"string"},"description":"Project id. Defaults to the workspace default project; a secret key defaults to its bound project."},{"name":"environment","in":"query","schema":{"type":"string"},"description":"Environment id. Defaults to `default`."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyCreate"}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyCreated"}}}},"400":{"description":"Invalid key request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Plan key limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Read-only token, or viewer/developer/member, or workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Key collision","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/keys/{id}":{"delete":{"operationId":"revokeKey","summary":"Revoke a write key of a workspace environment by its SHA-256 (owner or admin, write token)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^[a-f0-9]{64}$"}},{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."},{"name":"project","in":"query","schema":{"type":"string"},"description":"Project id. Defaults to the workspace default project; a secret key defaults to its bound project."},{"name":"environment","in":"query","schema":{"type":"string"},"description":"Environment id. Defaults to `default`."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyRevoked"}}}},"400":{"description":"Invalid key id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Read-only token, or viewer/developer/member, or workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Key not found in this workspace environment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/usage":{"get":{"operationId":"getUsage","summary":"Storage use and plan of a workspace","parameters":[{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Usage"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/logs":{"get":{"operationId":"listIngestLog","summary":"Recorded upload attempts of a workspace environment, newest first","parameters":[{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."},{"name":"project","in":"query","schema":{"type":"string"},"description":"Project id. Defaults to the workspace default project; a secret key defaults to its bound project."},{"name":"environment","in":"query","schema":{"type":"string"},"description":"Environment id. Defaults to `default`."},{"name":"stream","in":"query","schema":{"type":"string","enum":["issues","accepted"],"default":"issues"},"description":"`issues`: refused and partly stored requests. `accepted`: fully stored requests."},{"name":"route","in":"query","schema":{"type":"string","enum":["batches","otlp","langfuse"]}},{"name":"reason","in":"query","schema":{"type":"string"},"description":"Exact reason code."},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"after","in":"query","schema":{"type":"string"},"description":"Cursor from the previous page's `next`."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IngestLog"}}}},"400":{"description":"Invalid query","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/traces":{"get":{"operationId":"listTraces","summary":"Traces (runs) of a workspace environment","parameters":[{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."},{"name":"project","in":"query","schema":{"type":"string"},"description":"Project id. Defaults to the workspace default project; a secret key defaults to its bound project."},{"name":"environment","in":"query","schema":{"type":"string"},"description":"Environment id. Defaults to `default`."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"maximum":100000,"default":0}},{"name":"sort","in":"query","schema":{"type":"string","enum":["started","agent","duration","events","status"],"default":"started"}},{"name":"dir","in":"query","schema":{"type":"string","enum":["asc","desc"],"default":"desc"}},{"name":"q","in":"query","schema":{"type":"string"},"description":"Substring of the trace id."},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TraceList"}}}},"400":{"description":"Invalid query","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/traces/{trace_id}":{"get":{"operationId":"getTrace","summary":"Metadata of one trace","parameters":[{"name":"trace_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."},{"name":"project","in":"query","schema":{"type":"string"},"description":"Project id. Defaults to the workspace default project; a secret key defaults to its bound project."},{"name":"environment","in":"query","schema":{"type":"string"},"description":"Environment id. Defaults to `default`."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Trace"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Trace not found in this workspace environment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/traces/{trace_id}/events":{"get":{"operationId":"listTraceEvents","summary":"Events (spans) of one trace, one stored batch per page","parameters":[{"name":"trace_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"workspace","in":"query","schema":{"type":"string"},"description":"Workspace id. Defaults to the token owner's own workspace."},{"name":"project","in":"query","schema":{"type":"string"},"description":"Project id. Defaults to the workspace default project; a secret key defaults to its bound project."},{"name":"environment","in":"query","schema":{"type":"string"},"description":"Environment id. Defaults to `default`."},{"name":"after","in":"query","schema":{"type":"string"},"description":"Cursor from the previous page's `next`."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventPage"}}}},"401":{"description":"Missing, unknown, expired or revoked token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Workspace not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited; see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearerToken":{"type":"http","scheme":"bearer","description":"Personal access token (`stpat_…`). A secret key (`st_sec_…`) is accepted on the traces and events routes for its own workspace and environment only."},"keyHeader":{"type":"apiKey","in":"header","name":"X-Supatrace-Key","description":"The same token, for the hosted edge."}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"Me":{"type":"object","required":["account_id","token"],"properties":{"account_id":{"type":"string"},"token":{"type":"object","required":["id","name","scope","expires_at"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"scope":{"type":"string","enum":["read","write"]},"expires_at":{"type":"string","format":"date-time"}}}}},"KeyCreate":{"type":"object","required":["key_type"],"additionalProperties":false,"properties":{"key_type":{"type":"string","enum":["publishable","secret"]},"expires_in":{"type":["integer","null"]}}},"KeyCreated":{"type":"object","required":["id","key","key_type","project_id","scope","expires_at","no_expiry","created_at"],"properties":{"id":{"type":"string","description":"SHA-256 of the key."},"key":{"type":"string","description":"The full key. Returned once and never stored or shown again."},"key_type":{"type":"string","enum":["publishable","secret"]},"project_id":{"type":"string"},"scope":{"type":"string","enum":["write_only","read_write"]},"environment_id":{"type":"string"},"expires_at":{"type":"integer"},"no_expiry":{"type":"boolean"},"created_at":{"type":"integer"}}},"KeyRevoked":{"type":"object","required":["revoked"],"properties":{"revoked":{"type":"boolean"}}},"WorkspaceList":{"type":"object","required":["workspaces"],"properties":{"workspaces":{"type":"array","items":{"type":"object","required":["id","name","role","shared"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"role":{"type":"string","enum":["owner","admin","viewer"]},"shared":{"type":"boolean"}}}}}},"ProjectList":{"type":"object","required":["projects"],"properties":{"projects":{"type":"array","items":{"type":"object","required":["id","name","workspace_id","role"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"workspace_id":{"type":"string"},"role":{"type":"string"}}}}}},"KeyList":{"type":"object","required":["keys","next"],"properties":{"next":{"type":["string","null"]},"environment_id":{"type":"string"},"keys":{"type":"array","items":{"type":"object","required":["id","project_id","scope","environment_id","revoked"],"properties":{"id":{"type":"string","description":"SHA-256 of the key; the key itself is never returned."},"project_id":{"type":"string"},"scope":{"type":"string"},"environment_id":{"type":"string"},"authorization_active":{"type":"boolean"},"expires_at":{"type":"integer"},"revoked":{"type":"boolean"},"created_at":{"type":"integer"}}}}}},"Usage":{"type":"object","required":["quota_scope","storage"],"properties":{"quota_scope":{"type":"object","required":["workspace_id","project_id"],"properties":{"workspace_id":{"type":"string"},"project_id":{"type":"string"},"environment_id":{"type":"string"}}},"storage":{"type":"object","required":["used_bytes","limit_bytes","remaining_bytes"],"properties":{"used_bytes":{"type":"integer"},"limit_bytes":{"type":"integer"},"remaining_bytes":{"type":"integer"}}},"billing":{"type":"object"},"commercial":{"type":"object"},"account_plan":{"type":"object"},"plan_configuration":{"type":"object"}}},"Trace":{"type":"object","required":["id","created_at","status"],"properties":{"id":{"type":"string"},"display_name":{"type":"string"},"agent_name":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"ended_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"event_count":{"type":["integer","null"]},"batch_count":{"type":["integer","null"]},"byte_count":{"type":["integer","null"]},"agents":{"type":"array","items":{"type":"string"}},"status":{"type":["string","null"],"enum":["ok","error",null]},"expires_at":{"type":["string","null"],"format":"date-time"}}},"TraceList":{"type":"object","required":["runs","total","offset","limit","next"],"properties":{"total":{"type":"integer"},"offset":{"type":"integer"},"limit":{"type":"integer"},"truncated":{"type":"boolean"},"next":{"type":["string","null"]},"environment_id":{"type":"string"},"runs":{"type":"array","items":{"type":"object","required":["id","created_at","status"],"properties":{"id":{"type":"string"},"display_name":{"type":"string"},"agent_name":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"ended_at":{"type":["string","null"],"format":"date-time"},"duration_ms":{"type":["integer","null"]},"event_count":{"type":["integer","null"]},"batch_count":{"type":["integer","null"]},"byte_count":{"type":["integer","null"]},"agents":{"type":"array","items":{"type":"string"}},"status":{"type":["string","null"],"enum":["ok","error",null]},"expires_at":{"type":["string","null"],"format":"date-time"}}}}}},"IngestLog":{"type":"object","required":["workspace_id","environment_id","stream","retention_days","attempts","next","truncated"],"properties":{"workspace_id":{"type":"string"},"environment_id":{"type":"string"},"stream":{"type":"string","enum":["issues","accepted"]},"retention_days":{"type":"integer"},"routes":{"type":"array","items":{"type":"string"}},"recorded":{"type":"object","description":"What the log does and does not hold: refusals are recorded up to a per-minute rate, requests without a valid key are not recorded, and a row can be missing.","properties":{"issues_per_minute":{"type":"integer"},"unauthenticated_requests":{"type":"boolean"},"best_effort":{"type":"boolean"}}},"next":{"type":["string","null"]},"truncated":{"type":"boolean","description":"The read stopped at its row limit with rows left; continue with `next`."},"attempts":{"type":"array","items":{"type":"object","required":["id","time","route","outcome","http_status","reason"],"properties":{"id":{"type":"string"},"time":{"type":"string","format":"date-time"},"route":{"type":"string","enum":["batches","otlp","langfuse"]},"outcome":{"type":"string","enum":["accepted","partial","rejected"]},"http_status":{"type":"integer"},"reason":{"type":["string","null"],"description":"Reason code; null for an accepted request."},"message":{"type":["string","null"]},"detail":{"type":["string","null"]},"key_prefix":{"type":["string","null"],"description":"First 12 characters of the key id."},"batches":{"type":["integer","null"]},"repeated_batches":{"type":["integer","null"]},"stored_events":{"type":["integer","null"]},"rejected_events":{"type":["integer","null"]},"stored_bytes":{"type":["integer","null"]},"stored_trace_id":{"type":["string","null"],"description":"The trace the request stored events for, when that was exactly one trace. A trace whose events were all refused is not named."},"stored_trace_count":{"type":["integer","null"],"description":"Traces the request stored events for."}}}}}},"EventPage":{"type":"object","required":["events","next"],"properties":{"next":{"type":["string","null"]},"environment_id":{"type":"string"},"events":{"type":"array","items":{"type":"object","required":["id","time","kind","name","data"],"properties":{"id":{"type":"string"},"time":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["request","tool_call","tool_result","response","error","note"]},"name":{"type":"string"},"data":{}}}}}}}}}