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

# API scenarios vs UI scenarios

> Choose API scenarios for direct HTTP behavior and UI scenarios for browser-visible user flows. Compare execution, evidence, and ideal use cases.

# What's the difference between an API scenario and a UI scenario?

API scenarios test your application through HTTP.

UI scenarios test your application through the browser, the way a user experiences it.

Both are reusable Qodex scenarios. The right choice depends on what kind of behavior you need to prove.

## Quick comparison

| Scenario type | What it runs | Best for | Rerun cost |
| - | - | - | - |
| API | HTTP requests and assertions | Status codes, payloads, auth, IDOR, rate limits | LLM-free after authoring |
| UI | Chromium actions through Playwright | Forms, redirects, visible errors, browser state | LLM-free after the replay cache is warm |
| Mixed | Browser and API steps together | Login in browser, then assert API behavior | Depends on the step type |

## Use API scenarios when

* The behavior can be tested with raw HTTP.
* You care about response shape, status code, headers, or payload values.
* You are testing authorization, mass assignment, rate limits, or API contracts.
* You want the fastest and cheapest replay path.
* You want to inspect and copy the exact request and response each step sent and received.

## Use UI scenarios when

* The visible user experience matters.
* The flow includes redirects, forms, modals, OAuth, or browser-only state.
* The flow includes an emailed one-time code or magic link, a file download, or a file upload.
* You need screenshots or step artifacts.
* The bug cannot be proven from API traffic alone.

## Simple rule

If the bug can be reproduced with `curl`, use an API scenario.

If you need to see what the user sees, use a UI scenario.

## Next steps

> [card] [Scenarios concept](https://qodex.ai/docs/concepts-scenarios.md)
>
> Understand reusable Qodex scenarios.

> [card] [API testing scenarios](https://qodex.ai/docs/api-testing-scenarios.md)
>
> Create direct endpoint tests.

> [card] [Intent-driven UI scenarios](https://qodex.ai/docs/ui-testing-intent-driven-scenarios.md)
>
> Create browser-driven tests.

> [card] [LLM cost on reruns](https://qodex.ai/docs/kb-llm-cost-on-reruns.md)
>
> Understand why saved scenarios rerun cheaply.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.