Skip to content

List agent spans

GET
/api/v1/agent_spans
curl --request GET \
--url 'https://app.prefactorai.com/api/v1/agent_spans?agent_instance_id=013xrzp12g3nqk8ns6jadrqmpgrjkeny&agent_id=013xrzp12g3nqk8ns6jadrqmpgrjkeny&include_summaries=false&include_risk_level=false&redacted=false' \
--header 'Authorization: Bearer <token>'
agent_instance_id
AgentInstance_Id

A valid agent instance ID

string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkeny
agent_id
Agent_Id

A valid agent ID

string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkeny
environment_id
One of:
Environment_Id

A valid environment ID

string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkeny
idempotency_key
One of:

Optional idempotency key for ensuring request idempotency

string
start_time
end_time
purpose
One of:
string
Allowed values: activity quality alert
Example
activity
alert_id
One of:
Alert_Id

A valid alert ID

string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkeny
sorting

Sort order; a field name, optionally prefixed with - for descending (e.g. -id). Supported fields: id, started_at, finished_at, status.

string

Sort order; a field name, optionally prefixed with - for descending (e.g. -id). Supported fields: id, started_at, finished_at, status.

pagination[offset]
integer

Zero-based offset of the first item to return.

pagination[page_size]
integer
>= 1 <= 100

Number of items to return per page (1-100).

include_summaries

Include human-readable summaries from schema templates (default: false for performance)

boolean
include_risk_level

When true, score each activity-purpose span against the agent’s risk profile and populate risk_level and risk_score on the summary.

boolean
redacted

When true, strip sensitive values from payload and result_payload, and render the summary with redaction labels. Defaults to false.

boolean

Success

Media typeapplication/json
object
pagination
One of:
PaginationOutput

Pagination information

object
item_count

The total number of items

integer
item_end

The index of the last item in the page (one-based)

integer
item_start

The index of the first item in the page (one-based)

integer
next_page_offset
One of:

The offset of the next page (null if last page)

integer
page_count

The total number of pages

integer
page_index

The index of the current page (one-based)

integer
page_offset

The offset of the first item in the page (zero-based)

integer
page_size

The number of items per page

integer
previous_page_offset
One of:

The offset of the previous page (null if first page)

integer
sorting
One of:
Sorting

Sorting information

object
direction

The direction to sort by

string
Allowed values: asc desc
field

The field to sort by (values depend on the type of list)

string
Allowed values: id status started_at finished_at email name external_identifier raised_at cleared_at severity last_activity_span_at
nulls

Where to place null values. auto leaves placement to the database default.

string
Allowed values: first last auto
status
string
Allowed values: success
summaries
Array<object>
AgentSpan_Summary
object
account_id
Account_Id

A valid account ID

string
agent_id
Agent_Id

A valid agent ID

string
agent_instance_id
AgentInstance_Id

A valid agent instance ID

string
data_risk
One of:
DataRisk
object
action_profile
required
ActionProfile
object
create_data
required

Creates data

string
Allowed values: unknown allowed disallowed
destroy_data
required

Destroys data

string
Allowed values: unknown allowed disallowed
external_communication
required

Sends external communications

string
Allowed values: unknown allowed disallowed
financial_transactions
required

Performs financial transactions

string
Allowed values: unknown allowed disallowed
read_data
required

Reads data

string
Allowed values: unknown allowed disallowed
update_data
required

Updates data

string
Allowed values: unknown allowed disallowed
params_data_categories
required
DataCategories
object
authentication_and_secrets
required

Authentication and secrets present

string
Allowed values: unknown included excluded
behavioural_and_inferred
required

Behavioural and inferred data present

string
Allowed values: unknown included excluded
classification
required

Classification level

string
Allowed values: unknown public internal confidential restricted secret
contact_information
required

Contact information present

string
Allowed values: unknown included excluded
criminal_justice
required

Criminal justice data present

string
Allowed values: unknown included excluded
financial_information
required

Financial information present

string
Allowed values: unknown included excluded
gdpr_biometric_for_identification
required

GDPR: biometric data for identification

string
Allowed values: unknown included excluded
gdpr_genetic_data
required

GDPR: genetic data

string
Allowed values: unknown included excluded
gdpr_political_opinions
required

GDPR: political opinions

string
Allowed values: unknown included excluded
gdpr_racial_or_ethnic_origin
required

GDPR: racial or ethnic origin

string
Allowed values: unknown included excluded
gdpr_religious_or_philosophical_beliefs
required

GDPR: religious or philosophical beliefs

string
Allowed values: unknown included excluded
gdpr_sex_life_or_sexual_orientation
required

GDPR: sex life or sexual orientation

string
Allowed values: unknown included excluded
gdpr_trade_union_membership
required

GDPR: trade union membership

string
Allowed values: unknown included excluded
health_and_medical
required

Health and medical data present

string
Allowed values: unknown included excluded
location_and_tracking
required

Location and tracking data present

string
Allowed values: unknown included excluded
minors_data
required

Minors data present

string
Allowed values: unknown included excluded
organisational_confidential
required

Organisational confidential data present

string
Allowed values: unknown included excluded
personal_identifiers
required

Personal identifiers present

string
Allowed values: unknown included excluded
result_data_categories
required
DataCategories
object
authentication_and_secrets
required

Authentication and secrets present

string
Allowed values: unknown included excluded
behavioural_and_inferred
required

Behavioural and inferred data present

string
Allowed values: unknown included excluded
classification
required

Classification level

string
Allowed values: unknown public internal confidential restricted secret
contact_information
required

Contact information present

string
Allowed values: unknown included excluded
criminal_justice
required

Criminal justice data present

string
Allowed values: unknown included excluded
financial_information
required

Financial information present

string
Allowed values: unknown included excluded
gdpr_biometric_for_identification
required

GDPR: biometric data for identification

string
Allowed values: unknown included excluded
gdpr_genetic_data
required

GDPR: genetic data

string
Allowed values: unknown included excluded
gdpr_political_opinions
required

GDPR: political opinions

string
Allowed values: unknown included excluded
gdpr_racial_or_ethnic_origin
required

GDPR: racial or ethnic origin

string
Allowed values: unknown included excluded
gdpr_religious_or_philosophical_beliefs
required

GDPR: religious or philosophical beliefs

string
Allowed values: unknown included excluded
gdpr_sex_life_or_sexual_orientation
required

GDPR: sex life or sexual orientation

string
Allowed values: unknown included excluded
gdpr_trade_union_membership
required

GDPR: trade union membership

string
Allowed values: unknown included excluded
health_and_medical
required

Health and medical data present

string
Allowed values: unknown included excluded
location_and_tracking
required

Location and tracking data present

string
Allowed values: unknown included excluded
minors_data
required

Minors data present

string
Allowed values: unknown included excluded
organisational_confidential
required

Organisational confidential data present

string
Allowed values: unknown included excluded
personal_identifiers
required

Personal identifiers present

string
Allowed values: unknown included excluded
finished_at
One of:

When the span finished (null if still in progress)

string format: date-time
id
AgentSpan_Id

A valid agent span ID

string
parent_span_id
One of:
AgentSpan_Id

A valid agent span ID

string
payload

Span payload data (arbitrary JSON object)

object
key
additional properties
any
payload_byte_size_estimate

Approximate JSON-encoded byte size of the span’s stored payload columns. This is an estimate, not an exact on-disk size.

integer
purpose

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.

string
Allowed values: activity quality alert
result_payload
One of:

Result payload (arbitrary JSON), only present when span is finished

object
key
additional properties
any
risk_level
One of:

Risk level for this span based on its schema’s data_risk and the agent’s risk profile. Only populated for activity-purpose spans when the request includes include_risk_level, the agent has a risk profile, and the span’s schema has scoreable data_risk.

string
Allowed values: low medium high critical
risk_score
One of:

Numeric risk score for this span based on its schema’s data_risk and the agent’s risk profile. Only populated for activity-purpose spans, together with risk_level, when the request includes include_risk_level.

number
schema_name

Name of the schema for this span

string
schema_title

Human-readable title for the schema (from JSON schema, defaults to schema_name)

string
sensitive_encoding

When true, both payload and result_payload should be interpreted as containing sensitive markers as per the specification

boolean
started_at
One of:

When the span started (null when status is pending)

string format: date-time
status

Status of the span: ‘pending’ (not started), ‘active’ (started but not finished), ‘complete’ (finished successfully), ‘failed’ (ended with failure), or ‘cancelled’ (never started, cancelled)

string
Allowed values: pending active complete failed cancelled
summary
One of:

Human-readable summary rendered from the schema template using payload and result_payload (null when template is missing). When the request sets redacted to true, sensitive values in the summary are replaced with redaction labels.

string
type

Type of resource (always ‘agent_span’)

string
Allowed values: agent_span
Example
{
"pagination": {
"item_count": 200,
"item_end": 100,
"item_start": 91,
"next_page_offset": 110,
"page_count": 20,
"page_index": 10,
"page_offset": 90,
"page_size": 10,
"previous_page_offset": 80
},
"sorting": null,
"status": "success",
"summaries": [
{
"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,
"risk_level": "low",
"risk_score": 40,
"schema_name": "llm",
"schema_title": "LLM",
"started_at": "2024-01-01T00:00:00Z",
"status": "pending",
"summary": null,
"type": "agent_span"
}
]
}

Error

Media typeapplication/json
One of:
object
code
string
Allowed values: bad_request bad_authtoken not_authenticated not_permitted not_implemented unknown not_found unexpected_ref_type unexpected invalid_action alert_unknown alert_already_cleared invalid_value required_value idempotency_key_already_used
message
string
status
string
Allowed values: error
Example
{
"code": "bad_request",
"status": "error"
}