> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute Action

> Run an action on an API integration using a connection and input values

Executes an action on an API integration using a connection and input values. You can run actions on private API integrations in your workspace and on public catalog API integrations enabled for your workspace.

> [!WARNING]
>
> Use this endpoint when developing and testing actions to verify that they behave as expected. It does not replace running actions normally through agents, workflows, or chat once your integration is shipped.

## Base URL

```
https://api.langdock.com/integrations/v1/{integrationId}/actions/{actionId}/execute
```

> [!WARNING]
>
> **Dedicated deployments**
>
> Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.

## Required Scopes

This endpoint requires the `INTEGRATION_API` scope.

## Access Requirements

To execute an action, your API key must have access to the integration, the action, and the connection:

* **Integration**: Only `API` integrations are supported. You can run actions on private `API` integrations in your workspace that your API key can access, or on public catalog `API` integrations enabled for your workspace. `MCP` and `A2A` integrations return `422`.
* **Action**: The action must belong to the integration. If the action is restricted in your workspace, the API key identity must be allowed to use it. Personal API keys owned by workspace admins can run restricted actions automatically, while workspace API keys need explicit access to the restricted action.
* **Connection**: The `connectionId` must belong to the same integration and workspace, and must be owned by the API key identity or shared with that user, one of their groups, or the workspace.

## Parameters

### Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `integrationId` | string | Yes | UUID of the integration |
| `actionId` | string | Yes | UUID of the action to execute |

### Request Body

| Parameter | Type | Required | Description |
| - | - | - | - |
| `connectionId` | string | Yes | UUID of the connection used to authenticate the action |
| `inputs` | object | Yes | Input values keyed by each input field `slug` (for example, `userId`). Pass `{}` when the action takes no inputs. |

> [!NOTE]
>
> Langdock validates `inputs` against the action's declared `inputFields` before running the action code. You can inspect an action's `inputFields` and their `slug` identifiers with [Get Integration](https://docs.langdock.com/en/developer/integrations-api/get-integration.md). For `VECTOR` fields, pass a text string and Langdock embeds it automatically using the embedding model configured on the connection. For `FILE` fields, pass a file object or an array of file objects matching the action's file schema.

## Example

```javascript theme={null}
const axios = require("axios");

async function executeAction(integrationId, actionId, connectionId) {
  const response = await axios.post(
    `https://api.langdock.com/integrations/v1/${integrationId}/actions/${actionId}/execute`,
    {
      connectionId,
      inputs: {
        userId: "user_123",
        includeDetails: true
      }
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  if (!response.data.success) {
    console.error("Action failed:", response.data.error);
    return;
  }

  console.log("Action result:", response.data.result);
}

executeAction(
  "550e8400-e29b-41d4-a716-446655440000",
  "660e8400-e29b-41d4-a716-446655440001",
  "770e8400-e29b-41d4-a716-446655440002"
);
```

## Response Format

### Success Response (200 OK)

```typescript theme={null}
{
  success: boolean;          // True when the action code completed without throwing an error
  authError: boolean;        // True when OAuth authentication or token refresh failed
  error?: string;            // Error message when success is false
  result?: any;              // Value returned by the action code
  logs: string[];            // Messages logged via ld.log during execution
  httpCalls: Array<{
    url: string;             // Request URL
    method?: string;         // HTTP method
    status?: number;         // Response HTTP status code
    statusText?: string;     // Response status text
    responseBody?: any;      // Parsed or raw response body
    error?: {
      name: string;
      message: string;
    };
  }>;
  durationMs: number;        // Execution duration in milliseconds
}
```

### Example Response

```json theme={null}
{
  "success": true,
  "authError": false,
  "result": {
    "id": "user_123",
    "name": "Jane Doe",
    "status": "active"
  },
  "logs": [
    "Fetched user user_123"
  ],
  "httpCalls": [
    {
      "url": "https://api.example.com/users/user_123",
      "method": "GET",
      "status": 200,
      "statusText": "OK",
      "responseBody": {
        "id": "user_123",
        "name": "Jane Doe",
        "status": "active"
      }
    }
  ],
  "durationMs": 184
}
```

### Action Failures and Authentication Errors

Once the request passes validation and access checks, the endpoint returns HTTP `200` even if the action code itself fails:

* When the action code throws an error, `success` is `false` and `error` contains the error message.
* When OAuth authentication or token refresh fails, `authError` is `true` and the connection must be reauthorized in Langdock.
* Authentication tokens in `result`, `logs`, and `httpCalls` are redacted automatically before the response is returned.

## Error Handling

| Status Code | Description |
| - | - |
| 400 | Invalid `integrationId` or `actionId` UUID, invalid request body, or invalid action `inputs` |
| 401 | Invalid or missing API key |
| 403 | No access to this integration |
| 404 | Integration, action, or connection not found |
| 422 | Unsupported integration type. Only `API` integrations are supported. |
| 429 | Rate limit exceeded |
| 504 | Action code execution timed out or was cancelled |

> [!NOTE]
>
> Langdock intentionally blocks requests from a browser to protect your API key and ensure your applications remain secure. For more information, please see our guide on [API Key Best Practices](https://docs.langdock.com/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.