> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nativeport.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nativeport.ai/_mcp/server.

# Apify

Fronts **run-sync** execution for [Apify](https://apify.com) actors and tasks on `https://api.apify.com`: trigger a saved task or an actor and receive its output — or its dataset items — in the same response. Whatever follows `/apify/` is relayed to Apify, provided it names one of the run-sync actions:

```
POST /apify/<api path>   → https://api.apify.com/<api path>
```

Admission is default-deny against a fixed allowlist: only the run-sync actions listed below get through, and every other path draws a `404` until the endpoint concerned is added to the allowlist. Mounted methods: `POST`.

## Common paths

| Path                                                                  | Purpose                                           |
| --------------------------------------------------------------------- | ------------------------------------------------- |
| `POST /apify/v2/acts/{actorId}/run-sync-get-dataset-items`            | Run an actor and get its dataset items inline     |
| `POST /apify/v2/acts/{actorId}/run-sync`                              | Run an actor and get the run output inline        |
| `POST /apify/v2/actor-tasks/{actorTaskId}/run-sync-get-dataset-items` | Run a saved task and get its dataset items inline |
| `POST /apify/v2/actor-tasks/{actorTaskId}/run-sync`                   | Run a saved task and get the run output inline    |

Give `{actorId}` / `{actorTaskId}` in tilde form as one path segment (e.g. `apify~web-scraper`); the slash-separated `username/name` form is not accepted.

## Credential handling

Apify will take its token through two channels — a `token` query parameter or an `Authorization: Bearer` header — and the gateway closes off both:

* **`Authorization` is overwritten with Apify's secret token** (Apify reads the very header that carries your gateway token). The gateway consumes your token itself; Apify never receives it.
* **A `token` supplied by the client in the query is discarded** (any encoding), so nothing can displace the injected token.

## Examples

#### Run an actor (sync)

```bash
curl -X POST "$GATEWAY/apify/v2/acts/apify~website-content-crawler/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": [{"url": "https://example.com"}]}'
```

#### Run a saved task (sync)

```bash
curl -X POST "$GATEWAY/apify/v2/actor-tasks/{actorTaskId}/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Responses arrive as Apify's JSON, untouched. Field-level request and response detail lives in [Apify's API reference](https://docs.apify.com/api/v2); the gateway modifies neither.