perform.chat
Agents

List Agents

Retrieve all agents for your company

Endpoint

GET https://api.perform.chat/rest/v1/agents

Request Body

{
  "keyId": "your-key-id",
  "keySecret": "your-key-secret"
}

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page (max 100)

Response

{
  "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
  }
}

Response Fields

Agent Object

FieldTypeDescription
idstringUnique agent identifier
namestringAgent display name
activebooleanWhether the agent is active
created_atstringISO 8601 timestamp of creation
updated_atstringISO 8601 timestamp of last update

Pagination Object

FieldTypeDescription
pagenumberCurrent page number
limitnumberItems per page
totalnumberTotal number of agents
total_pagesnumberTotal number of pages

Example Request

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`)

Error Responses

StatusDescription
401Invalid API credentials
400Invalid query parameters
500Internal server error

Use Cases

Get All Active Agents

async function getActiveAgents() {
  const result = await listAgents(1, 100)
  return result.data.filter(agent => agent.active)
}

Find Agent by Name

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
}

Pagination Example

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
}

Best Practices

  1. Cache agent data - Agents rarely change, so cache the list to reduce API calls
  2. Check agent status - Always verify active: true before using an agent
  3. Use appropriate page size - Use larger page sizes (100) when fetching all agents
  4. Handle pagination - Don't assume all agents fit in one page