Skip to main content

Get All Agents by Organization

Retrieve all AI agents associated with your organization.

Endpoint

GET /api/v1/agents

Authentication

This endpoint requires API key authentication. Include your API key in the Authorization header using the Bearer scheme.

Header Format:

Authorization: Bearer {PUBLIC_KEY}:{SECRET_KEY}

Request

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesYour API key in the format Bearer pk_xxx:sk_xxx

Query Parameters

This endpoint does not accept any query parameters.

Response

Success Response

Status Code: 200 OK

Response Body:

{
"success": true,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Customer Support Agent",
"description": "AI agent for handling customer inquiries",
"system_prompt": "You are a helpful customer support assistant...",
"slug": "customer-support",
"model": {
"name": "gpt-4",
"display_name": "GPT-4",
"pricing": {
"input_per_1k_tokens": 0.03,
"output_per_1k_tokens": 0.06
},
"context_window": 8192
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-20T14:45:00Z",
"url": "https://agentsgt.com/api/v1/agents/basic/550e8400-e29b-41d4-a716-446655440000"
},
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "Sales Assistant",
"description": "AI agent for sales support and lead qualification",
"system_prompt": "You are a sales assistant that helps qualify leads...",
"slug": "sales-assistant",
"model": {
"name": "gpt-3.5-turbo",
"display_name": "GPT-3.5 Turbo",
"pricing": {
"input_per_1k_tokens": 0.0015,
"output_per_1k_tokens": 0.002
},
"context_window": 4096
},
"created_at": "2024-01-10T08:20:00Z",
"updated_at": "2024-01-18T16:30:00Z",
"url": "https://agentsgt.com/api/v1/agents/basic/660e8400-e29b-41d4-a716-446655440001"
}
]
}

Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful
dataarrayArray of agent objects
data[].idstring (UUID)Unique identifier for the agent
data[].namestringName of the agent
data[].descriptionstring | nullDescription of the agent's purpose
data[].system_promptstring | nullThe system prompt that defines the agent's behavior
data[].slugstring | nullURL-friendly identifier for the agent
data[].modelobjectInformation about the AI model used by the agent
data[].model.namestringInternal name of the model
data[].model.display_namestringHuman-readable name of the model
data[].model.pricingobjectPricing information for the model
data[].model.pricing.input_per_1k_tokensnumberCost per 1,000 input tokens (in USD)
data[].model.pricing.output_per_1k_tokensnumberCost per 1,000 output tokens (in USD)
data[].model.context_windownumberMaximum context window size in tokens
data[].created_atstring (ISO 8601)Timestamp when the agent was created
data[].updated_atstring (ISO 8601)Timestamp when the agent was last updated
data[].urlstringDirect API URL to interact with this specific agent

Error Responses

401 Unauthorized

Missing Authorization Header:

Status: 401 Unauthorized
Body: "Unauthorized"

Invalid Authorization Format:

Status: 401 Unauthorized
Body: "Invalid authorization format"

Invalid API Key:

Status: 401 Unauthorized
Body: "Invalid API key"

API Key Not Associated with Organization:

Status: 401 Unauthorized
Body: "API key not associated with a valid organization"

500 Internal Server Error

Status: 500 Internal Server Error
Body: "Internal server error"

Example Usage

cURL

curl -X GET https://agentsgt.com/api/v1/agents \
-H "Authorization: Bearer pk_1234567890abcdef:sk_abcdef1234567890"

JavaScript (Fetch API)

const publicKey = 'pk_1234567890abcdef';
const secretKey = 'sk_abcdef1234567890';

fetch('https://agentsgt.com/api/v1/agents', {
method: 'GET',
headers: {
'Authorization': `Bearer ${publicKey}:${secretKey}`,
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
console.log('Agents:', data.data);
})
.catch(error => {
console.error('Error:', error);
});

Python (Requests)

import requests

public_key = 'pk_1234567890abcdef'
secret_key = 'sk_abcdef1234567890'

headers = {
'Authorization': f'Bearer {public_key}:{secret_key}',
'Content-Type': 'application/json'
}

response = requests.get(
'https://agentsgt.com/api/v1/agents',
headers=headers
)

if response.status_code == 200:
data = response.json()
print(f"Found {len(data['data'])} agents")
for agent in data['data']:
print(f"- {agent['name']} ({agent['id']})")
else:
print(f"Error: {response.status_code} - {response.text}")

Node.js (Axios)

const axios = require('axios');

const publicKey = 'pk_1234567890abcdef';
const secretKey = 'sk_abcdef1234567890';

axios.get('https://agentsgt.com/api/v1/agents', {
headers: {
'Authorization': `Bearer ${publicKey}:${secretKey}`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(`Found ${response.data.data.length} agents`);
response.data.data.forEach(agent => {
console.log(`- ${agent.name} (${agent.id})`);
});
})
.catch(error => {
console.error('Error:', error.response?.data || error.message);
});

Notes

  • Agents are returned in descending order by creation date (newest first)
  • The API key's last_used_at timestamp is automatically updated when this endpoint is called
  • Only agents belonging to the organization associated with the API key are returned
  • The API key must be enabled (is_enabled: true) to authenticate successfully
  • Each agent includes a direct url field that can be used to interact with that specific agent via the API