Import agents
curl --request POST \
--url https://api.trymaitai.ai/api/v1/agents/import \
--header 'Content-Type: application/json' \
--header 'X-Maitai-Api-Key: <api-key>' \
--data '
{
"application": {
"ref_name": "customer-support",
"name": "Customer Support"
},
"source": "openai-agents-sdk",
"on_conflict": "error",
"agents": [
{
"name": "Onboarding Agent",
"description": "Guides new users through account setup",
"instructions": "Always verify identity before proceeding.",
"execution_mode": "reasoning",
"actions": [
{
"action_name": "lookup_order",
"action_type": "api_call",
"description": "Fetch order details",
"action_config": {
"parameters": {
"order_id": {
"type": "string",
"required": true
}
}
}
}
],
"handoffs": [
"KYC Agent"
]
},
{
"name": "KYC Agent",
"description": "Verifies user identity",
"actions": []
}
]
}
'import requests
url = "https://api.trymaitai.ai/api/v1/agents/import"
payload = {
"application": {
"ref_name": "customer-support",
"name": "Customer Support"
},
"source": "openai-agents-sdk",
"on_conflict": "error",
"agents": [
{
"name": "Onboarding Agent",
"description": "Guides new users through account setup",
"instructions": "Always verify identity before proceeding.",
"execution_mode": "reasoning",
"actions": [
{
"action_name": "lookup_order",
"action_type": "api_call",
"description": "Fetch order details",
"action_config": { "parameters": { "order_id": {
"type": "string",
"required": True
} } }
}
],
"handoffs": ["KYC Agent"]
},
{
"name": "KYC Agent",
"description": "Verifies user identity",
"actions": []
}
]
}
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({
application: {ref_name: 'customer-support', name: 'Customer Support'},
source: 'openai-agents-sdk',
on_conflict: 'error',
agents: [
{
name: 'Onboarding Agent',
description: 'Guides new users through account setup',
instructions: 'Always verify identity before proceeding.',
execution_mode: 'reasoning',
actions: [
{
action_name: 'lookup_order',
action_type: 'api_call',
description: 'Fetch order details',
action_config: {parameters: {order_id: {type: 'string', required: true}}}
}
],
handoffs: ['KYC Agent']
},
{name: 'KYC Agent', description: 'Verifies user identity', actions: []}
]
})
};
fetch('https://api.trymaitai.ai/api/v1/agents/import', 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/import",
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([
'application' => [
'ref_name' => 'customer-support',
'name' => 'Customer Support'
],
'source' => 'openai-agents-sdk',
'on_conflict' => 'error',
'agents' => [
[
'name' => 'Onboarding Agent',
'description' => 'Guides new users through account setup',
'instructions' => 'Always verify identity before proceeding.',
'execution_mode' => 'reasoning',
'actions' => [
[
'action_name' => 'lookup_order',
'action_type' => 'api_call',
'description' => 'Fetch order details',
'action_config' => [
'parameters' => [
'order_id' => [
'type' => 'string',
'required' => true
]
]
]
]
],
'handoffs' => [
'KYC Agent'
]
],
[
'name' => 'KYC Agent',
'description' => 'Verifies user identity',
'actions' => [
]
]
]
]),
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/import"
payload := strings.NewReader("{\n \"application\": {\n \"ref_name\": \"customer-support\",\n \"name\": \"Customer Support\"\n },\n \"source\": \"openai-agents-sdk\",\n \"on_conflict\": \"error\",\n \"agents\": [\n {\n \"name\": \"Onboarding Agent\",\n \"description\": \"Guides new users through account setup\",\n \"instructions\": \"Always verify identity before proceeding.\",\n \"execution_mode\": \"reasoning\",\n \"actions\": [\n {\n \"action_name\": \"lookup_order\",\n \"action_type\": \"api_call\",\n \"description\": \"Fetch order details\",\n \"action_config\": {\n \"parameters\": {\n \"order_id\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n }\n ],\n \"handoffs\": [\n \"KYC Agent\"\n ]\n },\n {\n \"name\": \"KYC Agent\",\n \"description\": \"Verifies user identity\",\n \"actions\": []\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/import")
.header("X-Maitai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"application\": {\n \"ref_name\": \"customer-support\",\n \"name\": \"Customer Support\"\n },\n \"source\": \"openai-agents-sdk\",\n \"on_conflict\": \"error\",\n \"agents\": [\n {\n \"name\": \"Onboarding Agent\",\n \"description\": \"Guides new users through account setup\",\n \"instructions\": \"Always verify identity before proceeding.\",\n \"execution_mode\": \"reasoning\",\n \"actions\": [\n {\n \"action_name\": \"lookup_order\",\n \"action_type\": \"api_call\",\n \"description\": \"Fetch order details\",\n \"action_config\": {\n \"parameters\": {\n \"order_id\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n }\n ],\n \"handoffs\": [\n \"KYC Agent\"\n ]\n },\n {\n \"name\": \"KYC Agent\",\n \"description\": \"Verifies user identity\",\n \"actions\": []\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trymaitai.ai/api/v1/agents/import")
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 \"application\": {\n \"ref_name\": \"customer-support\",\n \"name\": \"Customer Support\"\n },\n \"source\": \"openai-agents-sdk\",\n \"on_conflict\": \"error\",\n \"agents\": [\n {\n \"name\": \"Onboarding Agent\",\n \"description\": \"Guides new users through account setup\",\n \"instructions\": \"Always verify identity before proceeding.\",\n \"execution_mode\": \"reasoning\",\n \"actions\": [\n {\n \"action_name\": \"lookup_order\",\n \"action_type\": \"api_call\",\n \"description\": \"Fetch order details\",\n \"action_config\": {\n \"parameters\": {\n \"order_id\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n }\n ],\n \"handoffs\": [\n \"KYC Agent\"\n ]\n },\n {\n \"name\": \"KYC Agent\",\n \"description\": \"Verifies user identity\",\n \"actions\": []\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"application_id": 42,
"agents": [
{
"name": "Onboarding Agent",
"id": 101,
"status": "created",
"action_ids": [
200
],
"subagent_links": [
"KYC Agent"
],
"warnings": []
},
{
"name": "KYC Agent",
"id": 102,
"status": "created",
"action_ids": [],
"subagent_links": [],
"warnings": []
}
],
"warnings": []
}
}Agents
Import agents
Import one or more code-defined agents into Maitai from a canonical manifest. The manifest describes the agents, their capabilities (actions), and handoffs (sub-agents) in a framework-agnostic shape. The endpoint:
- Resolves or creates the target application. 2. Pre-flights every manifest agent against existing rows, so
on_conflict='error'fails fast without any writes when a conflict is detected. 3. Applies the writes through theagent_servicefunctions, which autocommit per call. These services perform read-backs and cache warming on separate asyncio tasks (asyncio.gather/create_eager_task); those child tasks open their own pooled connections, so the import must NOT run inside one outerconnection.async_cursor()transaction or those read-backs cannot see the uncommitted rows (they raiseResourceNotFound). The pre-flight in step 2 is what guards against partial writes foron_conflict='error'. 4.on_conflict='update'is non-destructive: only fields the adapter actually owns are overwritten (Portal-edited fields likeis_default,invocation_mode, actionmetasurvive), andagent_configis merged rather than replaced so Portal-set keys likerouting_configsurvive. 5. By default the import is additive — actions or sub-agent links removed from the source code are NOT deleted from Maitai. Passprune=True(CLI:--prune) for a destructive reconcile that makes the imported code the source of truth.
POST
/
agents
/
import
Import agents
curl --request POST \
--url https://api.trymaitai.ai/api/v1/agents/import \
--header 'Content-Type: application/json' \
--header 'X-Maitai-Api-Key: <api-key>' \
--data '
{
"application": {
"ref_name": "customer-support",
"name": "Customer Support"
},
"source": "openai-agents-sdk",
"on_conflict": "error",
"agents": [
{
"name": "Onboarding Agent",
"description": "Guides new users through account setup",
"instructions": "Always verify identity before proceeding.",
"execution_mode": "reasoning",
"actions": [
{
"action_name": "lookup_order",
"action_type": "api_call",
"description": "Fetch order details",
"action_config": {
"parameters": {
"order_id": {
"type": "string",
"required": true
}
}
}
}
],
"handoffs": [
"KYC Agent"
]
},
{
"name": "KYC Agent",
"description": "Verifies user identity",
"actions": []
}
]
}
'import requests
url = "https://api.trymaitai.ai/api/v1/agents/import"
payload = {
"application": {
"ref_name": "customer-support",
"name": "Customer Support"
},
"source": "openai-agents-sdk",
"on_conflict": "error",
"agents": [
{
"name": "Onboarding Agent",
"description": "Guides new users through account setup",
"instructions": "Always verify identity before proceeding.",
"execution_mode": "reasoning",
"actions": [
{
"action_name": "lookup_order",
"action_type": "api_call",
"description": "Fetch order details",
"action_config": { "parameters": { "order_id": {
"type": "string",
"required": True
} } }
}
],
"handoffs": ["KYC Agent"]
},
{
"name": "KYC Agent",
"description": "Verifies user identity",
"actions": []
}
]
}
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({
application: {ref_name: 'customer-support', name: 'Customer Support'},
source: 'openai-agents-sdk',
on_conflict: 'error',
agents: [
{
name: 'Onboarding Agent',
description: 'Guides new users through account setup',
instructions: 'Always verify identity before proceeding.',
execution_mode: 'reasoning',
actions: [
{
action_name: 'lookup_order',
action_type: 'api_call',
description: 'Fetch order details',
action_config: {parameters: {order_id: {type: 'string', required: true}}}
}
],
handoffs: ['KYC Agent']
},
{name: 'KYC Agent', description: 'Verifies user identity', actions: []}
]
})
};
fetch('https://api.trymaitai.ai/api/v1/agents/import', 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/import",
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([
'application' => [
'ref_name' => 'customer-support',
'name' => 'Customer Support'
],
'source' => 'openai-agents-sdk',
'on_conflict' => 'error',
'agents' => [
[
'name' => 'Onboarding Agent',
'description' => 'Guides new users through account setup',
'instructions' => 'Always verify identity before proceeding.',
'execution_mode' => 'reasoning',
'actions' => [
[
'action_name' => 'lookup_order',
'action_type' => 'api_call',
'description' => 'Fetch order details',
'action_config' => [
'parameters' => [
'order_id' => [
'type' => 'string',
'required' => true
]
]
]
]
],
'handoffs' => [
'KYC Agent'
]
],
[
'name' => 'KYC Agent',
'description' => 'Verifies user identity',
'actions' => [
]
]
]
]),
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/import"
payload := strings.NewReader("{\n \"application\": {\n \"ref_name\": \"customer-support\",\n \"name\": \"Customer Support\"\n },\n \"source\": \"openai-agents-sdk\",\n \"on_conflict\": \"error\",\n \"agents\": [\n {\n \"name\": \"Onboarding Agent\",\n \"description\": \"Guides new users through account setup\",\n \"instructions\": \"Always verify identity before proceeding.\",\n \"execution_mode\": \"reasoning\",\n \"actions\": [\n {\n \"action_name\": \"lookup_order\",\n \"action_type\": \"api_call\",\n \"description\": \"Fetch order details\",\n \"action_config\": {\n \"parameters\": {\n \"order_id\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n }\n ],\n \"handoffs\": [\n \"KYC Agent\"\n ]\n },\n {\n \"name\": \"KYC Agent\",\n \"description\": \"Verifies user identity\",\n \"actions\": []\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/import")
.header("X-Maitai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"application\": {\n \"ref_name\": \"customer-support\",\n \"name\": \"Customer Support\"\n },\n \"source\": \"openai-agents-sdk\",\n \"on_conflict\": \"error\",\n \"agents\": [\n {\n \"name\": \"Onboarding Agent\",\n \"description\": \"Guides new users through account setup\",\n \"instructions\": \"Always verify identity before proceeding.\",\n \"execution_mode\": \"reasoning\",\n \"actions\": [\n {\n \"action_name\": \"lookup_order\",\n \"action_type\": \"api_call\",\n \"description\": \"Fetch order details\",\n \"action_config\": {\n \"parameters\": {\n \"order_id\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n }\n ],\n \"handoffs\": [\n \"KYC Agent\"\n ]\n },\n {\n \"name\": \"KYC Agent\",\n \"description\": \"Verifies user identity\",\n \"actions\": []\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trymaitai.ai/api/v1/agents/import")
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 \"application\": {\n \"ref_name\": \"customer-support\",\n \"name\": \"Customer Support\"\n },\n \"source\": \"openai-agents-sdk\",\n \"on_conflict\": \"error\",\n \"agents\": [\n {\n \"name\": \"Onboarding Agent\",\n \"description\": \"Guides new users through account setup\",\n \"instructions\": \"Always verify identity before proceeding.\",\n \"execution_mode\": \"reasoning\",\n \"actions\": [\n {\n \"action_name\": \"lookup_order\",\n \"action_type\": \"api_call\",\n \"description\": \"Fetch order details\",\n \"action_config\": {\n \"parameters\": {\n \"order_id\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n }\n ],\n \"handoffs\": [\n \"KYC Agent\"\n ]\n },\n {\n \"name\": \"KYC Agent\",\n \"description\": \"Verifies user identity\",\n \"actions\": []\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"application_id": 42,
"agents": [
{
"name": "Onboarding Agent",
"id": 101,
"status": "created",
"action_ids": [
200
],
"subagent_links": [
"KYC Agent"
],
"warnings": []
},
{
"name": "KYC Agent",
"id": 102,
"status": "created",
"action_ids": [],
"subagent_links": [],
"warnings": []
}
],
"warnings": []
}
}Was this page helpful?
⌘I