Run a custom draft command
Run a terminal command against unsaved custom tool definitions.
/api/v1/custom-integrations/draft/terminalconst response = await fetch("https://api.smallworld.sh/api/v1/custom-integrations/draft/terminal", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify({
"key": "example",
"name": "Example",
"description": "Record lookup",
"endpointUrl": "https://tools.example.com/tools",
"tools": [
{
"name": "lookup",
"description": "Look up a record",
"inputSchema": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
},
"required": [
"id"
]
}
}
],
"draftToken": "draft_token",
"command": "example lookup --json '{\"id\":\"rec_123\"}'"
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();
Use your server-side apiKey. Replace the example IDs.
Request body#
keystringrequiredCommand key: 2–32 lowercase letters, digits, or hyphens, starting with a letter. Reserved commands and existing custom/MCP keys are rejected.
namestringrequiredNon-empty display name, at most 60 characters.
descriptionstringDescription, at most 500 characters. Defaults to an empty string.
endpointUrlstringrequiredPublic HTTPS endpoint. Local development also accepts loopback HTTP; URLs cannot contain credentials or fragments.
timeoutMsintegerCall timeout from 1000 to 60000 milliseconds; defaults to 30000.
headersobjectUp to 10 static headers. Values are write-only. Omit during updates to retain them; use an empty object to clear them. Routing, signing, and other reserved headers are rejected.
toolsarrayrequiredUp to 100 OpenAI, Anthropic, or MCP tool definitions, each at most 64 KiB.
draftTokenstringrequiredCredentials from POST /custom-integrations/draft.
commandstringrequiredNon-empty command, at most 16 KiB. A draft command can send at most four tool calls.
Responses#
Returns stdout, stderr, truncation, exitCode, durationMs, and per-call diagnostics. HTTP 200 may contain a failed command or unknown call outcome.
{
"stdout": "{\"id\":\"rec_123\"}",
"stderr": "",
"truncated": false,
"exitCode": 0,
"durationMs": 12,
"calls": [
{
"outcome": "succeeded",
"durationMs": 12,
"request": {
"url": "https://tools.example.com/tools",
"headers": {
"x-api-key": "[hidden]"
},
"body": "{\"type\":\"tool_call\",\"name\":\"lookup\"}"
},
"response": {
"status": 200,
"contentType": "application/json",
"body": "{\"id\":\"rec_123\"}"
},
"output": {
"id": "rec_123"
},
"error": null
}
]
}
More about this endpoint
This sends real signed requests. Your endpoint can change data. Test requests use the test user's external identifier and null World/session/execution IDs, with no execution context. Tests do not create tool-call or execution history.
World selection is rejected for draft tests. Unknown outcomes may have reached your endpoint; check its result before retrying a write.