# Run Actor — Apify (OAuth)

> Performs an execution of a selected Actor in Apify. See the documentation

- Key: `apify_oauth-run-actor`
- Type: Action (Write)
- Version: 0.0.3
- App: Apify (OAuth) (`apify_oauth`) — https://pipedream.com/apps/apify-oauth.md
- This page (HTML): https://pipedream.com/apps/apify-oauth/actions/run-actor
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/apify_oauth/actions/run-actor/run-actor.mjs

## Description

Performs an execution of a selected Actor in Apify. [See the documentation](https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `actorSource` | `string` | Yes | Where to search for Actors. Valid options are Store and Recently used Actors. |
| `actorId` | `string` | Yes | Select the Actor, enter the Actor ID, or use a tilde-separated combination of the owner's username and the Actor name. Options are loaded from the connected account. |
| `buildTag` | `string` | No | Specifies the Actor build to run. The accepted value is the build tag. If not provided, the default build will be used. Options are loaded from the connected account. |
| `runAsynchronously` | `boolean` | Yes | Set to true to run the Actor asynchronously |
| `timeout` | `string` | No | Optional timeout for the run, in seconds. By default, the run uses a timeout specified in the default run configuration for the Actor. |
| `memory` | `string` | No | Memory limit for the run, in megabytes. The amount of memory can be set to a power of 2 with a minimum of 128. By default, the run uses a memory limit specified in the default run configuration for the Actor. |
| `maxItems` | `string` | No | The maximum number of items that the Actor run should return. This is useful for pay-per-result Actors, as it allows you to limit the number of results that will be charged to your subscription. You can access the maximum number of items in your Actor by using the ACTOR_MAX_PAID_DATASET_ITEMS environment variable. |
| `maxTotalChargeUsd` | `string` | No | Specifies the maximum cost of the Actor run. This parameter is useful for pay-per-event Actors, as it allows you to limit the amount charged to your subscription. You can access the maximum cost in your Actor by using the ACTOR_MAX_TOTAL_CHARGE_USD environment variable. |
| `webhook` | `string` | No | Specifies optional webhook associated with the Actor run, which can be used to receive a notification e.g. when the Actor finished or failed. |

## 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": "apify_oauth",
      },
    },
  },
)

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: "apify_oauth-run-actor",
  arguments: {
    actorSource: "Search Actors from",
    actorId: "Actor",
  },
})
```

**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: "apify_oauth-run-actor",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    apify_oauth: { authProvisionId: "apn_xxxxxxx" },
    actorSource: "Search Actors from",
    actorId: "Actor",
  },
})

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": "apify_oauth-run-actor",
    "configured_props": {
      "apify_oauth": { "authProvisionId": "apn_xxxxxxx" },
      "actorSource": "Search Actors from",
      "actorId": "Actor"
    }
  }'
```

---

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