Create a new agent span
const url = 'https://app.prefactorai.com/api/v1/agent_spans';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"agent_instance_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","finished_at":"2024-01-01T00:00:00Z","id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","parent_span_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","payload":{},"result_payload":null,"schema_name":"llm","sensitive_encoding":false,"started_at":"2024-01-01T00:00:00Z","status":"pending"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.prefactorai.com/api/v1/agent_spans \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "agent_instance_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "finished_at": "2024-01-01T00:00:00Z", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "parent_span_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "payload": {}, "result_payload": null, "schema_name": "llm", "sensitive_encoding": false, "started_at": "2024-01-01T00:00:00Z", "status": "pending" }'Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
A valid agent instance ID
Example
013xrzp12g3nqk8ns6jadrqmpgrjkenyA valid agent span ID
Example
013xrzp12g3nqk8ns6jadrqmpgrjkenyNull
A valid agent span ID
Example
013xrzp12g3nqk8ns6jadrqmpgrjkenyNull
Span payload data (arbitrary JSON object)
object
Name of the schema for this span
Example
llmWhen true, payload and result_payload are parsed as sensitive-encoded JSON; values marked with $sensitive are extracted and stored securely, separate from the rest of the payload. Defaults to false.
Status of the span (required)
Example
activeResponses
Section titled “Responses”Success
object
object
object
A valid account ID
A valid agent ID
A valid agent instance ID
object
object
Creates data
Destroys data
Sends external communications
Performs financial transactions
Reads data
Updates data
object
Authentication and secrets present
Behavioural and inferred data present
Classification level
Contact information present
Criminal justice data present
Financial information present
GDPR: biometric data for identification
GDPR: genetic data
GDPR: political opinions
GDPR: racial or ethnic origin
GDPR: religious or philosophical beliefs
GDPR: sex life or sexual orientation
GDPR: trade union membership
Health and medical data present
Location and tracking data present
Minors data present
Organisational confidential data present
Personal identifiers present
object
Authentication and secrets present
Behavioural and inferred data present
Classification level
Contact information present
Criminal justice data present
Financial information present
GDPR: biometric data for identification
GDPR: genetic data
GDPR: political opinions
GDPR: racial or ethnic origin
GDPR: religious or philosophical beliefs
GDPR: sex life or sexual orientation
GDPR: trade union membership
Health and medical data present
Location and tracking data present
Minors data present
Organisational confidential data present
Personal identifiers present
Null
A valid agent span ID
A valid agent span ID
Null
Span payload data (arbitrary JSON object)
object
Approximate JSON-encoded byte size of the span’s stored payload columns. This is an estimate, not an exact on-disk size.
Purpose of the span: ‘activity’ (normal agent activity), ‘quality’ (system-written span recording an agent instance quality payload update), or ‘alert’ (system-written span recording an alert lifecycle event). Quality-purpose and alert-purpose spans are excluded from standard span metrics.
Name of the schema for this span
Human-readable title for the schema (from JSON schema, defaults to schema_name)
When true, both payload and result_payload should be interpreted as containing sensitive markers as per the specification
Status of the span: ‘pending’ (not started), ‘active’ (started but not finished), ‘complete’ (finished successfully), ‘failed’ (ended with failure), or ‘cancelled’ (never started, cancelled)
Type of resource (always ‘agent_span’)
Example
{ "details": { "account_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_instance_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "data_risk": null, "finished_at": "2024-01-01T00:00:00Z", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "parent_span_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "purpose": "activity", "result_payload": null, "schema_name": "llm", "schema_title": "LLM", "started_at": "2024-01-01T00:00:00Z", "status": "pending", "summary": null, "type": "agent_span" }, "status": "success"}default
Section titled “default”Error