Skip to main content
POST
/
v1
/
agents
/
{agent_id}
/
tools
Add Agent Tool
curl --request POST \
  --url https://api.xpander.ai/v1/agents/{agent_id}/tools \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "connection_id": "<string>",
  "operation_ids": [
    "<string>"
  ],
  "type": "action"
}
'
import requests

url = "https://api.xpander.ai/v1/agents/{agent_id}/tools"

payload = {
"connection_id": "<string>",
"operation_ids": ["<string>"],
"type": "action"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({connection_id: '<string>', operation_ids: ['<string>'], type: 'action'})
};

fetch('https://api.xpander.ai/v1/agents/{agent_id}/tools', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xpander.ai/v1/agents/{agent_id}/tools",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'connection_id' => '<string>',
'operation_ids' => [
'<string>'
],
'type' => 'action'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.xpander.ai/v1/agents/{agent_id}/tools"

payload := strings.NewReader("{\n \"connection_id\": \"<string>\",\n \"operation_ids\": [\n \"<string>\"\n ],\n \"type\": \"action\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.xpander.ai/v1/agents/{agent_id}/tools")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"connection_id\": \"<string>\",\n \"operation_ids\": [\n \"<string>\"\n ],\n \"type\": \"action\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.xpander.ai/v1/agents/{agent_id}/tools")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"connection_id\": \"<string>\",\n \"operation_ids\": [\n \"<string>\"\n ],\n \"type\": \"action\"\n}"

response = http.request(request)
puts response.read_body
[
  {
    "id": "<string>",
    "name": "<string>",
    "connection_id": "<string>",
    "operation_id": "<string>",
    "operation_name": "<string>",
    "custom_function_id": "<string>",
    "mcp_id": "<string>",
    "allowed_tools": [
      "<string>"
    ],
    "target_id": "<string>"
  }
]
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
The request body is discriminated by type:
  • action{ "type": "action", "connection_id": "...", "operation_ids": ["<catalog id>"] }
  • custom_function{ "type": "custom_function", "custom_function_id": "..." }
  • mcp (registry) — { "type": "mcp", "mcp_id": "<registry id>" }
  • mcp (inline) — { "type": "mcp", "url": "https://...", "name": "...", "transport": "streamable-http" }
  • agent (sub-agent) — { "type": "agent", "agent_id": "..." }
  • workflow{ "type": "workflow", "workflow_id": "..." }

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

agent_id
string
required

Query Parameters

deploy
boolean
default:true

Deploy the agent after adding so the change takes effect immediately.

Body

application/json

Attach connector operations as agent tools.

connection_id
string
required

Connector connection id (the connection to call through).

operation_ids
string[]
required

Operation catalog ids — the id field from GET /tools/connectors/{connector_id}/operations.

type
string
default:action
Allowed value: "action"

Response

Successful Response

id
string
required

Stable handle for this attached tool. Pass it to DELETE to remove the tool.

type
enum<string>
required

The kind of attached tool.

Available options:
action,
custom_function,
mcp,
agent,
workflow
name
string | null

Human-readable tool name.

connection_id
string | null

Connector connection id. Actions only.

operation_id
string | null

Operation catalog id. Actions only.

operation_name
string | null

OpenAPI operationId. Actions only.

custom_function_id
string | null

Custom function id. Custom functions only.

mcp_id
string | null

MCP registry id. MCP only.

allowed_tools
string[] | null

Subset of MCP tools exposed. MCP only.

target_id
string | null

Referenced sub-agent or workflow id.