Agents
List Agents Retrieve all agents for your company
GET https://api.perform.chat/rest/v1/agents
{
"keyId" : "your-key-id" ,
"keySecret" : "your-key-secret"
}
Parameter Type Default Description pagenumber 1 Page number limitnumber 20 Items per page (max 100)
{
"data" : [
{
"id" : "agent_123" ,
"name" : "Customer Support Agent" ,
"active" : true ,
"created_at" : "2025-01-15T10:30:00Z" ,
"updated_at" : "2025-01-15T10:30:00Z"
},
{
"id" : "agent_456" ,
"name" : "Sales Assistant" ,
"active" : true ,
"created_at" : "2025-01-10T08:20:00Z" ,
"updated_at" : "2025-01-14T15:45:00Z"
}
],
"pagination" : {
"page" : 1 ,
"limit" : 20 ,
"total" : 45 ,
"total_pages" : 3
}
}
Field Type Description idstring Unique agent identifier namestring Agent display name activeboolean Whether the agent is active created_atstring ISO 8601 timestamp of creation updated_atstring ISO 8601 timestamp of last update
Field Type Description pagenumber Current page number limitnumber Items per page totalnumber Total number of agents total_pagesnumber Total number of pages
const axios = require ( 'axios' )
async function listAgents ( page = 1 , limit = 20 ) {
const response = await axios. get ( 'https://api.performchat.com/rest/v1/v1/agents' , {
params: { page, limit },
data: {
keyId: process.env. API_KEY_ID ,
keySecret: process.env. API_KEY_SECRET
}
})
return response.data
}
// Usage
const result = await listAgents ( 1 , 50 )
console. log ( `Found ${ result . pagination . total } agents` )
Status Description 401 Invalid API credentials 400 Invalid query parameters 500 Internal server error
async function getActiveAgents () {
const result = await listAgents ( 1 , 100 )
return result.data. filter ( agent => agent.active)
}
async function findAgentByName ( name ) {
let page = 1
let found = null
while ( ! found) {
const result = await listAgents (page, 100 )
found = result.data. find ( agent =>
agent.name. toLowerCase (). includes (name. toLowerCase ())
)
if (page >= result.pagination.total_pages) break
page ++
}
return found
}
async function getAllAgents () {
const allAgents = []
let page = 1
let hasMore = true
while (hasMore) {
const result = await listAgents (page, 100 )
allAgents. push ( ... result.data)
hasMore = page < result.pagination.total_pages
page ++
}
return allAgents
}
Cache agent data - Agents rarely change, so cache the list to reduce API calls
Check agent status - Always verify active: true before using an agent
Use appropriate page size - Use larger page sizes (100) when fetching all agents
Handle pagination - Don't assume all agents fit in one page