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

# REST API: Base URL, Auth, and Errors

> The Test Your App Now! (TYAN) REST API lets you run health, visual, and flow tests, list transactions, and manage notifications from any language or CI pipeline.

The Test Your App Now! (TYAN) REST API gives you full programmatic control over your health checks, visual tests, and recorded flows. All requests are made over HTTPS to the base URL below, all bodies are JSON, and every request must include a Bearer token API key in the `Authorization` header. Every successful response includes an `X-Credits-Remaining` header so you can track credit usage in real time.

<Info>
  **Base URL**

  ```text theme={null}
  https://api.testyourappnow.com
  ```
</Info>

## Request Shape

Every endpoint in the API uses `POST` and follows the same envelope: a JSON body with an `action` field that selects the operation, and (for most actions) a `data` object with parameters. This keeps a single URL per resource while exposing multiple operations.

```bash theme={null}
curl -X POST https://api.testyourappnow.com/test/health \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "action": "list" }'
```

## Resources

The API is organized around five resources, grouped into **Tests** and **Admin**:

| Resource                                | Description                                                    |
| --------------------------------------- | -------------------------------------------------------------- |
| [**Health**](/api/health)               | Manage and run HTTP health checks against your routes          |
| [**Visual**](/api/visual)               | Manage and run visual regression tests across devices          |
| [**Flow**](/api/flow)                   | List, run, inspect, delete, or schedule recorded browser flows |
| [**Transactions**](/api/transactions)   | List transactions belonging to the authenticated user          |
| [**Notifications**](/api/notifications) | List, add, or delete in-app notifications                      |

## Credits

Actions that trigger work (running a health check, running a visual test, replaying a flow, scheduling any of the above) consume credits. Every successful response returns:

```http theme={null}
X-Credits-Remaining: 42
```

If your account has run out of credits, the API returns `402 Payment Required`.

## Error Handling

When a request fails, the API returns a consistent JSON error object with `success: false` and machine-readable fields:

```json theme={null}
{
  "success": false,
  "error": "unauthorized",
  "message": "API key is invalid or missing",
  "code": "unauthorized",
  "domain": "auth"
}
```

The following status codes are used across all endpoints:

| HTTP Status | Meaning                                                                    |
| ----------- | -------------------------------------------------------------------------- |
| `400`       | The request payload is invalid — check the schema for the action you sent  |
| `401`       | The API key is missing, invalid, disabled, or expired                      |
| `402`       | Your available credits have been exhausted                                 |
| `403`       | Your key is valid but lacks permission, or the target domain is unverified |
| `404`       | The referenced resource (route, flow, notification) was not found          |
| `409`       | Resource is already scheduled or running                                   |
| `429`       | API key rate limit exceeded — back off and retry                           |
| `500`       | Unexpected server error — contact support if it persists                   |
| `503`       | (Flow only) Replay could not be queued                                     |

## Next Steps

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/api/authentication">
    Generate an API key and authenticate your requests.
  </Card>

  <Card title="Flow" icon="play" href="/api/flow">
    List, run, and schedule recorded flows via the API.
  </Card>
</CardGroup>
