# Execute Runbook — Airplane

> Execute a runbook and receive a session ID to track the runbook's execution. See the documentation

- Key: `airplane-execute-runbook`
- Type: Action (Write)
- Version: 0.0.3
- App: Airplane (`airplane`) — https://pipedream.com/apps/airplane.md
- This page (HTML): https://pipedream.com/apps/airplane/actions/execute-runbook
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/airplane/actions/execute-runbook/execute-runbook.mjs

## Description

Execute a runbook and receive a session ID to track the runbook's execution. [See the documentation](https://docs.airplane.dev/reference/api#runbooks-execute)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | No | Unique ID of the runbook. You can find your runbook's ID by visiting the runbook's page on Airplane. The runbook ID is located at the end of the url. e.g. the runbook ID for https://app.airplane.dev/runbooks/rbk20220120z15kl79 is rbk20220120z15kl79 |
| `slug` | `string` | No | Unique slug of the runbook. You can find your runbook's slug next to the runbook's name within the runbook editor on Airplane. Either an ID or a slug must be provided.` |
| `paramValues` | `object` | No | Mapping of parameter slug to value. You can find your runbooks's parameter slugs inside the runbook editor on Airplane. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "airplane",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "airplane-execute-runbook",
  arguments: {
    id: "Runbook ID",
    slug: "Slug",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "airplane-execute-runbook",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    airplane: { authProvisionId: "apn_xxxxxxx" },
    id: "Runbook ID",
    slug: "Slug",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "airplane-execute-runbook",
    "configured_props": {
      "airplane": { "authProvisionId": "apn_xxxxxxx" },
      "id": "Runbook ID",
      "slug": "Slug"
    }
  }'
```

---

- App: https://pipedream.com/apps/airplane.md · All apps: https://pipedream.com/apps
