Skip to main content
Tools let your agent perform actions like calling APIs, displaying data, and collecting information through forms.

Endpoints

MethodEndpointDescription
GET/toolsList all tools for an agent
GET/tools/:idGet a specific tool
GET/tools/limitsGet tool limits for current plan
POST/toolsCreate a new tool
PUT/tools/:idUpdate a tool
DELETE/tools/:idDelete a tool

List Tools

GET /tools?agentId={agentId}

Query Parameters

ParameterTypeRequiredDescription
agentIdstringYesThe agent ID to list tools for

Response

[
  {
    "id": "tool_abc123",
    "agentId": "agent_xyz789",
    "name": "get_order_status",
    "description": "Look up the status of a customer order",
    "executionType": "http",
    "inputSchema": {
      "type": "object",
      "properties": {
        "order_id": {
          "type": "string",
          "description": "The order ID to look up"
        }
      },
      "required": ["order_id"]
    },
    "httpUrl": "https://api.example.com/orders/{order_id}",
    "httpMethod": "GET",
    "isEnabled": true,
    "createdAt": "2024-12-20T10:00:00.000Z",
    "updatedAt": "2024-12-20T10:00:00.000Z"
  }
]

Get Tool

GET /tools/{id}

Response

Returns the full tool object.

Get Tool Limits

GET /tools/limits?agentId={agentId}
Check how many tools you can create based on your plan.

Response

{
  "current": 3,
  "limit": 10,
  "planId": "starter",
  "canCreate": true
}
FieldDescription
currentNumber of tools currently created
limitMaximum tools allowed (null = unlimited)
planIdYour current plan
canCreateWhether you can create more tools

Create Tool

POST /tools

Request Body

{
  "agentId": "agent_xyz789",
  "name": "get_order_status",
  "description": "Look up the status of a customer order by order ID",
  "executionType": "http",
  "inputSchema": {
    "type": "object",
    "properties": {
      "order_id": {
        "type": "string",
        "description": "The order ID to look up"
      }
    },
    "required": ["order_id"]
  },
  "httpUrl": "https://api.example.com/orders/{order_id}",
  "httpMethod": "GET",
  "httpHeaders": {
    "Authorization": "Bearer {{API_KEY}}"
  },
  "isEnabled": true
}

Parameters

FieldTypeRequiredDescription
agentIdstringYesAgent to add the tool to
namestringYesUnique name (lowercase, underscores)
descriptionstringYesWhat the tool does (shown to AI)
executionTypestringYesmock, http, or form
inputSchemaobjectYesJSON Schema for tool parameters
isEnabledbooleanNoWhether tool is active (default: true)

HTTP Tool Fields

FieldTypeDescription
httpUrlstringURL to call (supports {param} placeholders)
httpMethodstringGET, POST, PUT, or DELETE
httpHeadersobjectHeaders to include in request

Form Tool Fields

FieldTypeDescription
formSchemaobjectForm field definitions
formExecutionModestringwebhook, client, or both
formWebhookUrlstringURL to send submissions
formClientHandlerstringClient-side handler name
formPostActionsarrayAdditional actions (Slack, email)

Mock Tool Fields

FieldTypeDescription
mockResponsestringStatic response to return

Display Configuration

FieldTypeDescription
displayConfigobjectHow to render the tool result

Response

{
  "id": "tool_abc123",
  "agentId": "agent_xyz789",
  "name": "get_order_status",
  "description": "Look up the status of a customer order",
  "executionType": "http",
  "inputSchema": { ... },
  "httpUrl": "https://api.example.com/orders/{order_id}",
  "httpMethod": "GET",
  "httpHeaders": { ... },
  "isEnabled": true,
  "createdAt": "2024-12-20T10:00:00.000Z",
  "updatedAt": "2024-12-20T10:00:00.000Z"
}

Errors

StatusCodeDescription
400-Invalid request body or duplicate name
403TOOL_LIMIT_REACHEDPlan tool limit exceeded
404-Agent not found

Update Tool

PUT /tools/{id}

Request Body

Only include fields you want to update:
{
  "description": "Updated description",
  "httpUrl": "https://api.example.com/v2/orders/{order_id}",
  "isEnabled": false
}

Response

Returns the updated tool object.

Delete Tool

DELETE /tools/{id}

Response

{
  "success": true
}

Input Schema

The inputSchema defines what parameters the tool accepts. It follows JSON Schema format:
{
  "type": "object",
  "properties": {
    "order_id": {
      "type": "string",
      "description": "The order ID to look up"
    },
    "include_items": {
      "type": "boolean",
      "description": "Whether to include line items"
    }
  },
  "required": ["order_id"]
}

Property Types

TypeDescription
stringText input
numberNumeric value
booleanTrue/false
arrayList of values
objectNested object

Enum Values

Restrict to specific values:
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "description": "Order status filter",
      "enum": ["pending", "shipped", "delivered"]
    }
  }
}

Display Config

Control how tool results are rendered in the widget:
{
  "displayConfig": {
    "type": "product_card",
    "fieldMappings": {
      "title": "name",
      "price": "price",
      "image": "imageUrl",
      "description": "description"
    },
    "options": {
      "showPrice": true,
      "showImage": true,
      "showAddToCart": true
    }
  }
}

Display Types

TypeDescription
textPlain text (default)
product_cardSingle product card
product_carouselMultiple products
imageImage display
tableTabular data
buttonsAction buttons
formForm display
customCustom template

Form Schema

For form tools, define fields with formSchema:
{
  "formSchema": {
    "fields": [
      {
        "name": "email",
        "label": "Email Address",
        "type": "email",
        "validation": {
          "required": { "value": true, "message": "Email is required" }
        }
      },
      {
        "name": "priority",
        "label": "Priority",
        "type": "select",
        "options": [
          { "label": "Low", "value": "low" },
          { "label": "Medium", "value": "medium" },
          { "label": "High", "value": "high" }
        ]
      }
    ],
    "submitLabel": "Submit",
    "successMessage": "Thanks for your submission!"
  }
}

Field Types

TypeDescription
textSingle-line text
emailEmail with validation
telPhone number
numberNumeric input
textareaMulti-line text
selectDropdown
multiselectMulti-select dropdown
dateDate picker
datetimeDate and time
fileFile upload
imageImage upload

Post Actions

Configure actions after form submission:
{
  "formPostActions": [
    {
      "type": "webhook",
      "url": "https://your-server.com/api/leads",
      "headers": {
        "Authorization": "Bearer xxx"
      }
    },
    {
      "type": "slack",
      "webhookUrl": "https://hooks.slack.com/services/xxx",
      "messageTemplate": "New lead: {{email}}"
    },
    {
      "type": "email",
      "recipientIds": ["user_123", "user_456"]
    }
  ]
}

Examples

HTTP Tool - Order Lookup

curl -X POST https://api.ansa.so/tools \
  -H "Authorization: Bearer $ANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "agent_xyz789",
    "name": "lookup_order",
    "description": "Look up order details by order number",
    "executionType": "http",
    "inputSchema": {
      "type": "object",
      "properties": {
        "order_number": {
          "type": "string",
          "description": "The order number (e.g., ORD-12345)"
        }
      },
      "required": ["order_number"]
    },
    "httpUrl": "https://api.mystore.com/orders/{order_number}",
    "httpMethod": "GET",
    "httpHeaders": {
      "X-API-Key": "your-api-key"
    }
  }'

Form Tool - Contact Form

curl -X POST https://api.ansa.so/tools \
  -H "Authorization: Bearer $ANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "agent_xyz789",
    "name": "contact_form",
    "description": "Collect contact information from visitors",
    "executionType": "form",
    "inputSchema": {
      "type": "object",
      "properties": {},
      "required": []
    },
    "formSchema": {
      "fields": [
        { "name": "name", "label": "Name", "type": "text" },
        { "name": "email", "label": "Email", "type": "email" },
        { "name": "message", "label": "Message", "type": "textarea" }
      ],
      "submitLabel": "Send Message"
    },
    "formExecutionMode": "webhook",
    "formWebhookUrl": "https://your-server.com/api/contacts"
  }'