> For the complete documentation index, see [llms.txt](https://statalpha.gitbook.io/statalpha-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://statalpha.gitbook.io/statalpha-docs/using-the-api/authentication.md).

# Authentication

StatAlpha can be used through the web console or through the API.

## Web Console

Open the web console in your browser:

```
https://web.statalpha.market
```

Sign in with your StatAlpha account. After login, you can open analytics modules from the dashboard and manage your account from **My account**.

Your account page shows:

* current plan
* web access status
* API access status
* history access
* request limits and remaining usage
* password reset action

## API Access

Direct API access requires an API-enabled StatAlpha account. If API access is enabled for your account, sign in through Auth0 from your API client and send the returned access token as a Bearer token:

```bash
Authorization: Bearer <ACCESS_TOKEN>
```

The standard login flow for direct API access is Auth0 Device Authorization Flow. Your tool requests a device code, you confirm the login in your browser, and the client then uses the returned access token as a Bearer token.

1. Request a device code:

```bash
curl -X POST "https://dev-8zz2p5wv.eu.auth0.com/oauth/device/code" \
  -H "content-type: application/x-www-form-urlencoded" \
  -d "client_id=Jm5AYCp9AiVY3rXcgpdTI4fS1MvvvucF" \
  -d "audience=https://api.statalpha.market"
```

Auth0 returns a `device_code`, `user_code`, `verification_uri`, and `verification_uri_complete`. Open the verification URL in your browser, sign in, and approve the request.

2. Poll for the access token:

```bash
curl -X POST "https://dev-8zz2p5wv.eu.auth0.com/oauth/token" \
  -H "content-type: application/x-www-form-urlencoded" \
  -d "grant_type=urn:ietf:params:oauth:grant-type:device_code" \
  -d "device_code=<DEVICE_CODE_FROM_STEP_1>" \
  -d "client_id=Jm5AYCp9AiVY3rXcgpdTI4fS1MvvvucF"
```

While approval is still pending, Auth0 returns `authorization_pending`. After approval, the response includes `access_token`.

3. Call the StatAlpha API with the Bearer token:

```bash
curl -s \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://api.statalpha.market/stats/fvg/summary?symbol=AAPL&timeframe=15m&time_window=12M"
```

Keep access tokens private. Do not commit them to source code repositories, publish them in frontend code, or share them in support screenshots. Access tokens expire; request a new token through your OAuth client when needed.

## Check Your Account

Use `/me` to check the access and limits attached to your authenticated account:

```bash
curl -s \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://api.statalpha.market/me"
```

Use `/me/usage` to see current request-limit usage:

```bash
curl -s \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://api.statalpha.market/me/usage"
```

## Common Errors

| Status | Meaning                                                                                       |
| ------ | --------------------------------------------------------------------------------------------- |
| `401`  | Missing or invalid authentication                                                             |
| `403`  | Your account does not have access to this feature, API route, history range, or billing state |
| `429`  | Request limit exceeded                                                                        |

If you receive `403` for direct API calls, your account may not have API access enabled. Check **My account** or contact StatAlpha support.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://statalpha.gitbook.io/statalpha-docs/using-the-api/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
