curl -X POST "https://api.magpipe.ai/functions/v1/custom-functions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "check_order_status",
"description": "Look up customer order status by order ID",
"http_method": "POST",
"endpoint_url": "https://api.yourstore.com/orders/status",
"body_schema": [
{
"name": "order_id",
"type": "string",
"description": "The customer order ID or confirmation number",
"required": true
}
],
"response_variables": [
{"name": "status", "json_path": "$.data.status"},
{"name": "eta", "json_path": "$.data.estimated_delivery"}
]
}'
{
"id": "789e0123-e89b-12d3-a456-426614174000",
"agent_id": "123e4567-e89b-12d3-a456-426614174000",
"user_id": "456e7890-e89b-12d3-a456-426614174000",
"name": "check_order_status",
"description": "Look up customer order status by order ID",
"http_method": "POST",
"endpoint_url": "https://api.yourstore.com/orders/status",
"headers": [],
"body_schema": [
{
"name": "order_id",
"type": "string",
"description": "The customer order ID or confirmation number",
"required": true
}
],
"response_variables": [
{"name": "status", "json_path": "$.data.status"},
{"name": "eta", "json_path": "$.data.estimated_delivery"}
],
"timeout_ms": 120000,
"max_retries": 2,
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": "Function name must be snake_case"
}
{
"error": "A function with this name already exists for this agent"
}
Custom Functions
Create Custom Function
Create a new custom function for an agent
POST
/
custom-functions
curl -X POST "https://api.magpipe.ai/functions/v1/custom-functions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "check_order_status",
"description": "Look up customer order status by order ID",
"http_method": "POST",
"endpoint_url": "https://api.yourstore.com/orders/status",
"body_schema": [
{
"name": "order_id",
"type": "string",
"description": "The customer order ID or confirmation number",
"required": true
}
],
"response_variables": [
{"name": "status", "json_path": "$.data.status"},
{"name": "eta", "json_path": "$.data.estimated_delivery"}
]
}'
{
"id": "789e0123-e89b-12d3-a456-426614174000",
"agent_id": "123e4567-e89b-12d3-a456-426614174000",
"user_id": "456e7890-e89b-12d3-a456-426614174000",
"name": "check_order_status",
"description": "Look up customer order status by order ID",
"http_method": "POST",
"endpoint_url": "https://api.yourstore.com/orders/status",
"headers": [],
"body_schema": [
{
"name": "order_id",
"type": "string",
"description": "The customer order ID or confirmation number",
"required": true
}
],
"response_variables": [
{"name": "status", "json_path": "$.data.status"},
{"name": "eta", "json_path": "$.data.estimated_delivery"}
],
"timeout_ms": 120000,
"max_retries": 2,
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": "Function name must be snake_case"
}
{
"error": "A function with this name already exists for this agent"
}
Create a custom webhook function that your AI agent can call during conversations.
Request Body
Custom headers to include with requests
[
{"name": "Authorization", "value": "Bearer token123"}
]
Parameters the AI should collect before calling
[
{
"name": "order_id",
"type": "string",
"description": "The customer's order ID",
"required": true
}
]
Variables to extract from the response using JSON paths
[
{"name": "status", "json_path": "$.data.status"}
]
Response
curl -X POST "https://api.magpipe.ai/functions/v1/custom-functions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "check_order_status",
"description": "Look up customer order status by order ID",
"http_method": "POST",
"endpoint_url": "https://api.yourstore.com/orders/status",
"body_schema": [
{
"name": "order_id",
"type": "string",
"description": "The customer order ID or confirmation number",
"required": true
}
],
"response_variables": [
{"name": "status", "json_path": "$.data.status"},
{"name": "eta", "json_path": "$.data.estimated_delivery"}
]
}'
{
"id": "789e0123-e89b-12d3-a456-426614174000",
"agent_id": "123e4567-e89b-12d3-a456-426614174000",
"user_id": "456e7890-e89b-12d3-a456-426614174000",
"name": "check_order_status",
"description": "Look up customer order status by order ID",
"http_method": "POST",
"endpoint_url": "https://api.yourstore.com/orders/status",
"headers": [],
"body_schema": [
{
"name": "order_id",
"type": "string",
"description": "The customer order ID or confirmation number",
"required": true
}
],
"response_variables": [
{"name": "status", "json_path": "$.data.status"},
{"name": "eta", "json_path": "$.data.estimated_delivery"}
],
"timeout_ms": 120000,
"max_retries": 2,
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": "Function name must be snake_case"
}
{
"error": "A function with this name already exists for this agent"
}