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

# HTTP Requests

> Making HTTP requests with Replay — methods, headers, bodies, extraction, and assertions.

# HTTP Requests

The `http` step type executes HTTP requests and captures the response for extraction and assertion.

## Basic Syntax

```yaml theme={null}
- name: get-users
  type: http
  request:
    method: GET
    url: /users
```

The `url` can be a relative path (resolved against `config.http.base_url`) or an absolute URL.

## Request Configuration

### Base URL

Set a shared base URL in workflow config:

```yaml theme={null}
config:
  http:
    base_url: https://api.example.com

steps:
  - name: health
    type: http
    request:
      method: GET
      url: /health          # → https://api.example.com/health

  - name: external
    type: http
    request:
      method: GET
      url: https://other.com/api   # absolute URL, ignores base_url
```

### Methods

Replay supports standard HTTP methods:

```yaml theme={null}
method: GET
method: POST
method: PUT
method: DELETE
method: PATCH
```

### Headers

Set global headers in config (applied to every request):

```yaml theme={null}
config:
  http:
    headers:
      Accept: application/json
      X-Client: replay
```

Override or add per-step:

```yaml theme={null}
- name: auth
  type: http
  request:
    method: POST
    url: /admin
    headers:
      Authorization: Bearer {{ token }}    # per-step header
      X-Idempotency-Key: "{{ nowUnix }}"
```

Step headers take precedence over config headers.

### Body

Send JSON bodies as a map:

```yaml theme={null}
request:
  method: POST
  url: /users
  body:
    name: Alice
    email: alice@example.com
```

Use template variables:

```yaml theme={null}
request:
  method: POST
  url: /users
  body:
    name: "{{ user_name }}"
    email: "{{ email }}"
```

For raw JSON strings:

```yaml theme={null}
request:
  method: POST
  url: /webhook
  body: |
    {"event": "user.created", "userId": {{ user_id }}}
```

## Response Structure

The HTTP runner returns a structured result:

```json theme={null}
{
  "status": 200,
  "data": { ... },
  "header": { ... }
}
```

* `status` — HTTP status code
* `data` — Parsed JSON response body (or raw string if not JSON)
* `header` — Response headers

## Extraction

Use JSONPath expressions to extract values from the response:

```yaml theme={null}
extract:
  token: $.data.token                    # nested field
  user_id: data.user.id                  # shorthand (no $ prefix)
  response_status: res.status            # explicit res. prefix
  first_item: data.items[0]              # array index
  all_names: data.items[*].name          # array wildcard
  server_header: res.header.Server[0]    # response header
```

## Assertions

Assert on the response:

```yaml theme={null}
assert:
  - ["$.status", "eq", 200]
  - ["$.data.email", "not_null"]
  - ["$.data.items", "contains", "expected-value"]
```

## Debug Mode

Enable debug logging to see request/response details:

```yaml theme={null}
config:
  http:
    debug: true
```

Or pass `--debug` on the CLI to enable debug for all workflows.

## Example: Full Auth Flow

```yaml theme={null}
- name: login
  type: http
  request:
    method: POST
    url: /auth/login
    headers:
      Content-Type: application/json
    body:
      email: admin@example.com
      password: "{{ admin_password }}"
  extract:
    token: $.data.accessToken
    refresh: $.data.refreshToken
  assert:
    - ["$.status", "eq", 200]
    - ["$.data.accessToken", "not_null"]
    - ["$.data.expiresIn", "gt", 0]
```

## TLS

Replay accepts self-signed certificates in development environments. For production, ensure your servers use valid certificates.

## What's Next?

* Explore [shell commands](/replay/guides/shell-commands) — no setup required
* Learn about [database operations](/replay/guides/database-operations)
