Create agent action
curl --request POST \
--url https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions \
--header 'Content-Type: application/json' \
--header 'X-Maitai-Api-Key: <api-key>' \
--data '
{
"action_name": "Lookup Order",
"action_type": "api",
"description": "Fetch order details from the orders API",
"invocation_mode": "foreground",
"action_config": {
"base_url": "https://api.example.com",
"endpoint": "/orders/{order_id}",
"method": "GET",
"headers": {
"Accept": "application/json"
},
"auth": {
"type": "bearer",
"token": "{{secrets.ORDERS_API_TOKEN}}"
}
}
}
'import requests
url = "https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions"
payload = {
"action_name": "Lookup Order",
"action_type": "api",
"description": "Fetch order details from the orders API",
"invocation_mode": "foreground",
"action_config": {
"base_url": "https://api.example.com",
"endpoint": "/orders/{order_id}",
"method": "GET",
"headers": { "Accept": "application/json" },
"auth": {
"type": "bearer",
"token": "{{secrets.ORDERS_API_TOKEN}}"
}
}
}
headers = {
"X-Maitai-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-Maitai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action_name: 'Lookup Order',
action_type: 'api',
description: 'Fetch order details from the orders API',
invocation_mode: 'foreground',
action_config: {
base_url: 'https://api.example.com',
endpoint: '/orders/{order_id}',
method: 'GET',
headers: {Accept: 'application/json'},
auth: {type: 'bearer', token: '{{secrets.ORDERS_API_TOKEN}}'}
}
})
};
fetch('https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions', 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.trymaitai.ai/api/v1/agents/{agent_id}/actions",
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([
'action_name' => 'Lookup Order',
'action_type' => 'api',
'description' => 'Fetch order details from the orders API',
'invocation_mode' => 'foreground',
'action_config' => [
'base_url' => 'https://api.example.com',
'endpoint' => '/orders/{order_id}',
'method' => 'GET',
'headers' => [
'Accept' => 'application/json'
],
'auth' => [
'type' => 'bearer',
'token' => '{{secrets.ORDERS_API_TOKEN}}'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Maitai-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.trymaitai.ai/api/v1/agents/{agent_id}/actions"
payload := strings.NewReader("{\n \"action_name\": \"Lookup Order\",\n \"action_type\": \"api\",\n \"description\": \"Fetch order details from the orders API\",\n \"invocation_mode\": \"foreground\",\n \"action_config\": {\n \"base_url\": \"https://api.example.com\",\n \"endpoint\": \"/orders/{order_id}\",\n \"method\": \"GET\",\n \"headers\": {\n \"Accept\": \"application/json\"\n },\n \"auth\": {\n \"type\": \"bearer\",\n \"token\": \"{{secrets.ORDERS_API_TOKEN}}\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Maitai-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.trymaitai.ai/api/v1/agents/{agent_id}/actions")
.header("X-Maitai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action_name\": \"Lookup Order\",\n \"action_type\": \"api\",\n \"description\": \"Fetch order details from the orders API\",\n \"invocation_mode\": \"foreground\",\n \"action_config\": {\n \"base_url\": \"https://api.example.com\",\n \"endpoint\": \"/orders/{order_id}\",\n \"method\": \"GET\",\n \"headers\": {\n \"Accept\": \"application/json\"\n },\n \"auth\": {\n \"type\": \"bearer\",\n \"token\": \"{{secrets.ORDERS_API_TOKEN}}\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Maitai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action_name\": \"Lookup Order\",\n \"action_type\": \"api\",\n \"description\": \"Fetch order details from the orders API\",\n \"invocation_mode\": \"foreground\",\n \"action_config\": {\n \"base_url\": \"https://api.example.com\",\n \"endpoint\": \"/orders/{order_id}\",\n \"method\": \"GET\",\n \"headers\": {\n \"Accept\": \"application/json\"\n },\n \"auth\": {\n \"type\": \"bearer\",\n \"token\": \"{{secrets.ORDERS_API_TOKEN}}\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 200,
"action_name": "Lookup Order",
"action_type": "api",
"agent_id": 101,
"enabled": true
}
}Agents
Create agent action
Add a new action (LLM, API, or webhook capability) to an agent.
POST
/
agents
/
{agent_id}
/
actions
Create agent action
curl --request POST \
--url https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions \
--header 'Content-Type: application/json' \
--header 'X-Maitai-Api-Key: <api-key>' \
--data '
{
"action_name": "Lookup Order",
"action_type": "api",
"description": "Fetch order details from the orders API",
"invocation_mode": "foreground",
"action_config": {
"base_url": "https://api.example.com",
"endpoint": "/orders/{order_id}",
"method": "GET",
"headers": {
"Accept": "application/json"
},
"auth": {
"type": "bearer",
"token": "{{secrets.ORDERS_API_TOKEN}}"
}
}
}
'import requests
url = "https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions"
payload = {
"action_name": "Lookup Order",
"action_type": "api",
"description": "Fetch order details from the orders API",
"invocation_mode": "foreground",
"action_config": {
"base_url": "https://api.example.com",
"endpoint": "/orders/{order_id}",
"method": "GET",
"headers": { "Accept": "application/json" },
"auth": {
"type": "bearer",
"token": "{{secrets.ORDERS_API_TOKEN}}"
}
}
}
headers = {
"X-Maitai-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-Maitai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
action_name: 'Lookup Order',
action_type: 'api',
description: 'Fetch order details from the orders API',
invocation_mode: 'foreground',
action_config: {
base_url: 'https://api.example.com',
endpoint: '/orders/{order_id}',
method: 'GET',
headers: {Accept: 'application/json'},
auth: {type: 'bearer', token: '{{secrets.ORDERS_API_TOKEN}}'}
}
})
};
fetch('https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions', 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.trymaitai.ai/api/v1/agents/{agent_id}/actions",
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([
'action_name' => 'Lookup Order',
'action_type' => 'api',
'description' => 'Fetch order details from the orders API',
'invocation_mode' => 'foreground',
'action_config' => [
'base_url' => 'https://api.example.com',
'endpoint' => '/orders/{order_id}',
'method' => 'GET',
'headers' => [
'Accept' => 'application/json'
],
'auth' => [
'type' => 'bearer',
'token' => '{{secrets.ORDERS_API_TOKEN}}'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Maitai-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.trymaitai.ai/api/v1/agents/{agent_id}/actions"
payload := strings.NewReader("{\n \"action_name\": \"Lookup Order\",\n \"action_type\": \"api\",\n \"description\": \"Fetch order details from the orders API\",\n \"invocation_mode\": \"foreground\",\n \"action_config\": {\n \"base_url\": \"https://api.example.com\",\n \"endpoint\": \"/orders/{order_id}\",\n \"method\": \"GET\",\n \"headers\": {\n \"Accept\": \"application/json\"\n },\n \"auth\": {\n \"type\": \"bearer\",\n \"token\": \"{{secrets.ORDERS_API_TOKEN}}\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Maitai-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.trymaitai.ai/api/v1/agents/{agent_id}/actions")
.header("X-Maitai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action_name\": \"Lookup Order\",\n \"action_type\": \"api\",\n \"description\": \"Fetch order details from the orders API\",\n \"invocation_mode\": \"foreground\",\n \"action_config\": {\n \"base_url\": \"https://api.example.com\",\n \"endpoint\": \"/orders/{order_id}\",\n \"method\": \"GET\",\n \"headers\": {\n \"Accept\": \"application/json\"\n },\n \"auth\": {\n \"type\": \"bearer\",\n \"token\": \"{{secrets.ORDERS_API_TOKEN}}\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trymaitai.ai/api/v1/agents/{agent_id}/actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Maitai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action_name\": \"Lookup Order\",\n \"action_type\": \"api\",\n \"description\": \"Fetch order details from the orders API\",\n \"invocation_mode\": \"foreground\",\n \"action_config\": {\n \"base_url\": \"https://api.example.com\",\n \"endpoint\": \"/orders/{order_id}\",\n \"method\": \"GET\",\n \"headers\": {\n \"Accept\": \"application/json\"\n },\n \"auth\": {\n \"type\": \"bearer\",\n \"token\": \"{{secrets.ORDERS_API_TOKEN}}\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 200,
"action_name": "Lookup Order",
"action_type": "api",
"agent_id": 101,
"enabled": true
}
}Authorizations
Your Maitai API key from the Portal.
Path Parameters
Body
application/json
llm | api | webhook | maitai_workflow | integration
Shape depends on action_type. LLM: {prompt, user_prompt, model_config:{model,temperature,max_tokens}}. API/webhook: {base_url,endpoint,method,headers,auth}.
Show child attributes
Show child attributes
Response
201 - application/json
Create agent action.
A capability that an agent can invoke — an LLM call, API call, or webhook.
Show child attributes
Show child attributes
Was this page helpful?
⌘I