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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Fetch HTTP

> Make a durable request to an HTTP or HTTPS endpoint.

The built-in `fetchHttp` action calls an HTTP or HTTPS endpoint without requiring a custom action. Use it for public APIs, webhooks, and other requests that don't need a platform-managed integration account.

## Example

```ts automations/look-up-pokemon.automation.ts theme={null}
import {
  automation,
  fetchHttp,
  onHttpRequest,
  respondToHttpRequest,
} from "automate.ax"

export default automation("Look up Pokémon", () => {
  const request = onHttpRequest({ waitForResponse: true })
  const pokemon = fetchHttp({
    query: {
      limit: 1,
      offset: request.query.transform((query) => query.offset ?? 0),
    },
    responseType: "json",
    url: "https://pokeapi.co/api/v2/pokemon",
  })

  respondToHttpRequest({
    body: pokemon.body,
    status: pokemon.status,
  })
})
```

## Inputs

| Input          | Type                                                                                     | Required | Default    | Description                                                                                                                                                                                            |
| -------------- | ---------------------------------------------------------------------------------------- | -------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `url`          | `string`                                                                                 | Yes      | —          | Absolute HTTP or HTTPS URL without embedded credentials or a port blocked by Fetch.                                                                                                                    |
| `method`       | `string`                                                                                 | No       | `"GET"`    | Valid HTTP method token, normalized to uppercase. The Fetch API rejects `CONNECT`, `TRACE`, and `TRACK`.                                                                                               |
| `headers`      | `Record<string, string>`                                                                 | No       | `{}`       | Request headers. Names and values must be valid Fetch API headers. Fetch manages `connection`, `content-length`, `expect`, `host`, `keep-alive`, `sec-fetch-mode`, `transfer-encoding`, and `upgrade`. |
| `query`        | `Record<string, string \| number \| boolean \| (string \| number \| boolean)[] \| null>` | No       | `{}`       | Query parameters merged into `url`. Arrays produce repeated parameters. The action skips `null` and `undefined`.                                                                                       |
| `body`         | `JSON value \| string \| Blob`                                                           | No       | No body    | Request body. The action serializes JSON values and defaults to `content-type: application/json`. It sends strings and Blobs unchanged. `GET` and `HEAD` requests can't include a body.                |
| `redirect`     | `"follow" \| "error" \| "manual"`                                                        | No       | `"follow"` | Fetch API redirect behavior.                                                                                                                                                                           |
| `responseType` | `"auto" \| "json" \| "text" \| "blob"`                                                   | No       | `"auto"`   | How to read a non-empty response body.                                                                                                                                                                 |

Every input accepts a compatible signal. `query` replaces an existing parameter with the same name. An array writes that name once per value.

With `responseType: "auto"`, JSON media types produce a JSON body. Text and XML media types produce text, and other media types produce a Blob. An empty response always produces `bodyType: "empty"` and `body: null`. Use an explicit response type when an endpoint sends an incorrect or missing `content-type` header.

## Output

Returns a signal containing these response fields:

| Field        | Type                                    | Description                                                                                                       |
| ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `ok`         | `boolean`                               | Whether `status` is from 200 through 299.                                                                         |
| `status`     | `number`                                | HTTP response status.                                                                                             |
| `statusText` | `string`                                | HTTP response status text.                                                                                        |
| `headers`    | `Record<string, string \| string[]>`    | Response headers normalized by the Fetch API. `set-cookie` is an array so multiple cookie values remain distinct. |
| `url`        | `string`                                | Final response URL after redirects.                                                                               |
| `redirected` | `boolean`                               | Whether the request followed a redirect.                                                                          |
| `bodyType`   | `"json" \| "text" \| "blob" \| "empty"` | Discriminator for the parsed body.                                                                                |
| `body`       | `JSON value \| string \| Blob \| null`  | Parsed response body corresponding to `bodyType`.                                                                 |

HTTP error statuses are successful action outputs with `ok: false`, so your automation can inspect their bodies and decide what to do. Network failures and response parsing failures throw and follow the normal action retry lifecycle.

Don't put API keys, bearer tokens, or other secrets in `headers`, `query`, or `body`. Action inputs are durable run data. Use a packaged integration action for supported providers, or keep credentials inside a [custom action](/concepts/custom-integrations) for unsupported services.

Requests that create or change data may run again after a network failure. Use a provider-supported idempotency key when the endpoint supports one.
