# API (/workflows/blocks/api)





The **API block** calls an HTTP endpoint. Use it to fetch data, create a record, or invoke an external service.

<BlockPreview type="api" />

## Fetch and summarize data [#fetch-and-summarize-data]

<WorkflowPreview workflow="API_FETCH_WORKFLOW" />

Set **URL** to `https://api.example.com/users/<start.input>` and **Method** to **GET**. The next Agent reads `<api.data>`. Replace the example endpoint and supply its required authentication.

## Configuration [#configuration]

| Field | Behavior |
| - | - |
| **URL** | Static URL or a URL containing [references](/workflows/connections), such as `https://api.example.com/users/<start.userId>`. |
| **Method** | **GET** (default), **POST**, **PUT**, **DELETE**, or **PATCH**. |
| **Query Params** | Key-value pairs appended as URL query parameters. |
| **Headers** | Request headers, such as `Authorization: Bearer {{API_KEY}}`. Your values override automatic User-Agent, Accept, Cache-Control, and other defaults. |
| **Body** | Request payload. JSON is the default for POST, PUT, and PATCH; other supported Content-Type values can change body encoding. |

Keep keys and proxy credentials in [secrets](/platform/credentials), referenced with `{{NAME}}`.

### Advanced settings [#advanced-settings]

| Field | Default and limit |
| - | - |
| **Timeout (ms)** | 300,000 ms (5 minutes); maximum 600,000 ms (10 minutes). |
| **Retries** | `0`. When enabled, retry network failures, timeouts, `429`, and `5xx` responses; not ordinary `400` or `404` errors. |
| **Retry delay (ms)** | `500`; exponential backoff starts here. |
| **Max retry delay (ms)** | `30,000`; caps the backoff delay. |
| **Retry non-idempotent methods** | Off. Enable POST/PATCH retries only when repeated requests are safe. |
| **Send credentials on cross-origin redirects** | On by default for compatibility. Disable it when a redirect to a different scheme, host, or port should not receive the same credential-bearing headers. |
| **Proxy URL** | Optional publicly reachable `http://` proxy, such as `{{PROXY_URL}}`. An HTTPS target still uses a secure tunnel through the HTTP proxy. |

<Callout type="warn">
  Retries can repeat an external write. Use idempotency support from the destination API before enabling retries for POST or PATCH.
</Callout>

## Outputs [#outputs]

| Reference | Value |
| - | - |
| `<api.data>` | Response body: parsed JSON, or text for other content types |
| `<api.status>` | HTTP status code on a successful response |
| `<api.headers>` | Response headers |

Use narrow references such as `<api.data.id>` when a later step needs only one field. The HTTP response itself is limited to 10 MiB; selecting a narrow field does not bypass that fetch-time limit.

## Handle failures [#handle-failures]

Non-2xx responses, network failures, and timeouts fail the API block. Connect its error port to handle them. Without an error path, an unhandled failure stops the run.

A normal downstream Condition on `<api.status>` can distinguish successful responses, such as `200` and `201`; it does not receive a failed `404` response on the normal path.

## Related docs [#related-docs]

* [Connections and error paths](/workflows/connections)
* [Webhook](/workflows/blocks/webhook)
* [Condition](/workflows/blocks/condition)
