Skip to content
Run a custom draft command

Run a custom draft command

Run a terminal command against unsaved custom tool definitions.

POST/api/v1/custom-integrations/draft/terminal

Request#

TypeScript
const 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#

keystringrequired

Command key: 2–32 lowercase letters, digits, or hyphens, starting with a letter. Reserved commands and existing custom/MCP keys are rejected.

namestringrequired

Non-empty display name, at most 60 characters.

descriptionstring

Description, at most 500 characters. Defaults to an empty string.

endpointUrlstringrequired

Public HTTPS endpoint. Local development also accepts loopback HTTP; URLs cannot contain credentials or fragments.

timeoutMsinteger

Call timeout from 1000 to 60000 milliseconds; defaults to 30000.

headersobject

Up 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.

toolsarrayrequired

Up to 100 OpenAI, Anthropic, or MCP tool definitions, each at most 64 KiB.

draftTokenstringrequired

Credentials from POST /custom-integrations/draft.

commandstringrequired

Non-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.

200 response
{
  "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.