Create a new agent
const url = 'https://app.prefactorai.com/api/v1/agent';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"description":"Handles tier-1 support requests","external_identifier":"workflow-abc123","id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","name":"Support bot","owner_person_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","risk_profile_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","team_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny"}'};
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 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "description": "Handles tier-1 support requests", "external_identifier": "workflow-abc123", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "name": "Support bot", "owner_person_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "risk_profile_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "team_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny" }'Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
Optional agent description
Example
Handles tier-1 support requestsOptional external identifier for this agent in an external system (unique per account)
Example
workflow-abc123Agent name
Example
Support botA valid risk profile ID
Example
013xrzp12g3nqk8ns6jadrqmpgrjkenyNull
Responses
Section titled “Responses”Success
object
object
Available actions for this agent based on its status and instance counts
object
Whether the agent can be deleted
Whether the agent can be reinstated from retired
Whether the agent can be retired
Whether the agent can be updated
A valid agent ID
When the agent was created
object
Number of instances with status active (running)
Number of instances with status cancelled
Number of instances with status complete
Number of instances with status failed
Number of instances in a finished state (complete + failed + cancelled + terminated)
Number of instances with status pending
Number of instances with status terminated
Total number of agent instances
Agent name
A valid risk profile ID
Null
Agent status
Type of resource (always ‘agent’)
When the agent was last updated
Example
{ "details": { "description": "Agent description", "external_identifier": "workflow-abc123", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "inserted_at": "2024-01-01T00:00:00Z", "instance_counts": { "active": 2, "cancelled": 0, "complete": 5, "failed": 0, "finished": 5, "pending": 0, "terminated": 0, "total": 10 }, "last_activity_span_at": "2024-01-01T00:00:00Z", "name": "My Agent", "owner_person_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "risk_profile_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "status": "pending", "team_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "type": "agent", "updated_at": "2024-01-01T00:00:00Z" }, "status": "success"}default
Section titled “default”Error