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","execution_mode":"hosted","external_identifier":"workflow-abc123","id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","name":"Support bot","owner_person_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","risk_profile_id":"013xrzp12g3nqk8ns6jadrqmpgrjkeny","role":"standard","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", "execution_mode": "hosted", "external_identifier": "workflow-abc123", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "name": "Support bot", "owner_person_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "risk_profile_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "role": "standard", "team_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny" }'Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
Optional agent description
Example
Handles tier-1 support requestsWhether this agent is expected to run hosted or remote (optional; defaults to hosted for a judge and remote otherwise). This does not limit which versions the agent can have.
Example
remoteOptional 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
What this agent does. Use judge for an agent that scores other agents’ runs (optional; standard if omitted).
Example
standardResponses
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
Whether this agent is expected to run hosted or remote. This does not limit which versions the agent can have
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 preparing
Number of instances with status terminated
Total number of agent instances
Knowledgebases linked to this agent
Agent name
A valid risk profile ID
Null
What this agent does: ‘standard’ for a customer agent, or ‘judge’ for an agent that scores other agents’ runs
Agent status
Type of resource (always ‘agent’)
When the agent was last updated
Example
{ "details": { "description": "Agent description", "execution_mode": "hosted", "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, "preparing": 0, "terminated": 0, "total": 10 }, "last_activity_span_at": "2024-01-01T00:00:00Z", "linked_knowledgebase_refs": [ "013xrzp12g3nqk8ns6jadrqmpgrjkeny" ], "name": "My Agent", "owner_person_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "risk_profile_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "role": "standard", "status": "pending", "team_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "type": "agent", "updated_at": "2024-01-01T00:00:00Z" }, "status": "success"}default
Section titled “default”Error
object
object
object
object
Milliseconds until the client may retry.
object
A valid knowledgebase document revision ID
Example
{ "code": "bad_request", "status": "error"}