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

# Email Blocks

> Test email verification flows — wait for emails, extract OTPs, assert content

# Email Blocks

<Info>
  Email blocks are a **Pro feature**. Free users can see the feature but need to upgrade to use it.
</Info>

Email blocks let you test email-based API flows — like signup verification, OTP login, and password reset. TestBrick catches the email, extracts values from it, and passes them to the next block.

## How it works

1. Your API sends an email (e.g., OTP to verify a signup)
2. The email block **waits** for the email to arrive in your TestBrick inbox
3. You **extract** the OTP or verification link from the email
4. The next block **uses** the extracted value to complete the flow

## Setup

### Your inbox address

Each project folder has a unique email inbox. Click the **Inbox** button in the toolbar to copy the address (e.g., `abc123@inbox.testbrick.com`).

Use this email address in your API requests:

```json theme={null}
{
  "email": "abc123@inbox.testbrick.com",
  "password": "test123"
}
```

### Adding an email block

Click **Email** in the toolbar to add an email block.

## Configuration

Click the email block to open the side panel with three tabs:

### Settings

| Field           | Description                              | Default  |
| --------------- | ---------------------------------------- | -------- |
| **Timeout**     | How long to wait for the email (seconds) | 60       |
| **From filter** | Only match emails from this sender       | Optional |

### Extract

After running the flow, the email HTML appears in the Extract tab:

1. Click **Extract Value**
2. Hover over elements in the email preview — they highlight
3. Click the OTP code or verification link
4. Choose the extraction pattern (6-digit code, alphanumeric, custom regex)
5. Click **Save Extraction**

<img src="https://mintlify.s3.us-west-1.amazonaws.com/testbrick/images/email-click-extract.png" alt="Click to extract OTP" />

<img src="https://mintlify.s3.us-west-1.amazonaws.com/testbrick/images/email-extract-modal.png" alt="Extraction options modal" />

The extracted value becomes available as `{{nodeId.value}}` in subsequent blocks.

### Assert

Toggle **Assert email content** to validate:

| Assertion            | Example                                             |
| -------------------- | --------------------------------------------------- |
| **Subject contains** | "Verification"                                      |
| **From equals**      | "[noreply@example.com](mailto:noreply@example.com)" |
| **Body contains**    | "Your code is"                                      |

## Example: OTP login flow

```
Block 1: POST /auth/login
  Body: {"email": "inbox@inbox.testbrick.com", "password": "demo123"}
  → API sends OTP email

Block 2: Email Block
  → Waits for email
  → Extracts 6-digit OTP
  
Block 3: POST /auth/verify-otp
  Body: {"email": "inbox@inbox.testbrick.com", "otp": "{{Block2.value}}"}
  → Verifies OTP using extracted code

Block 4: GET /profile
  Auth: Bearer {{Block3.body.token}}
  → Fetches profile using auth token
```

<Tip>
  The click-to-extract feature uses the same precise CSS path extraction as UI test email testing — it works reliably across different email templates.
</Tip>
