dots.code.execute.post()

Generated on 5 Nov 2026 from DoTs version v1.23.0

Usage

client.code.execute.post(body: Execute_code_request, requestConfiguration?: RequestConfiguration<object>): Promise<undefined | Execute_code_response>

Description

Runs Python code in an ephemeral sandbox and returns its stdout, stderr, and exit_code. This is the REST form of the action_code MCP tool. Use it for computation, parsing, and data processing, or to chain several catalog tools in one request.

The sandbox provides invoke_digitalocean_tool(name, arguments), which calls a catalog tool and returns a tool result. Those calls follow the session’s tool selection and policy. Each request runs in a fresh sandbox, so state is not kept between requests. Execution, including tool calls, is time limited. Code that runs too long fails with a timeout error.

A nonzero exit code is still a succeeded result; check output.exit_code. If the session policy requires approval for action_code, the response is a failed result with _meta.status set to requires_approval.

Parameters

Headers

X-Session-Id string required

Example: 2b3c9f0e-1a4d-4e5f-8a7b-6c5d4e3f2a1b

The session to act in: the UUID at the end of the session's sessionUrn and mcpUrl. The session must belong to the authenticated user and team.

Request Body

code string required

Example: print("hello from Action Gateway")

Python source to run. The sandbox provides invoke_digitalocean_tool(name: str, arguments: dict) -> dict, which calls a catalog tool under the session's policy and returns a tool result.

Request Sample

Show Request Sample
import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
import {
    createDigitalOceanClient,
    DigitalOceanApiKeyAuthenticationProvider,
} from "@digitalocean/dots";

const authProvider = new DigitalOceanApiKeyAuthenticationProvider(process.env.DIGITALOCEAN_TOKEN!);
const adapter = new FetchRequestAdapter(authProvider);
const client = createDigitalOceanClient(adapter);

const response = await client.code.execute.post({
    code: "print(\"hello from Action Gateway\")",
}, {
    headers: {
        "X-Session-Id": "2b3c9f0e-1a4d-4e5f-8a7b-6c5d4e3f2a1b",
    },
});

Response Example

Show Response Example
{
  "status": "succeeded",
  "output": {
    "stdout": "hello from Action Gateway\n",
    "exit_code": 0
  },
  "call_id": "call_8b7c6d5e-4f3a-4b2c-9d1e-0f9a8b7c6d5e"
}

More Information

See /code/execute in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.