# Authentication

_Source: https://docs.neurotrading.io/en/api/authentication_

The API authenticates you with a **session token** — the same token the dashboard uses after you sign in. Send it on every request in the `Authorization` header:

```http
Authorization: Bearer <your-session-token>
```

A session token lasts **7 days**. After that every call answers `401` with `{"message":"Unauthorized"}`, and you sign in again to get a new one.

> **Error**
>
> **Your session token is your whole account.** Anyone holding it can trade, withdraw and change settings on every wallet you own, until it expires. Signing out of the dashboard does **not** cancel a token you have already copied — it stays valid for its full 7 days. Never paste it into a chat, a shared notebook, a public repository or a screenshot. Keep it in an environment variable or a secrets manager, and run scripts only on machines you trust.

> **Info**
>
> Dedicated API keys — with read-only and trade-only scopes and the ability to revoke them — are not available yet. Until they are, a session token is the only way to authenticate.

## Getting a token

### Sign in on the dashboard

Open the dashboard at [app.neurotrading.io](https://app.neurotrading.io) and sign in as usual: with Telegram, with email, or with a Solana wallet such as Phantom.

### Copy the session cookie

Open your browser's developer tools (**F12**, or right-click → **Inspect**), go to **Application** (Chrome, Edge) or **Storage** (Firefox) → **Cookies**, and select the dashboard site. Copy the value of the cookie whose name starts with `neuroToken`. That value is your session token.

### Store it outside your code

```bash
```

## Checking the token works

`GET /user` returns the account the token belongs to:

```bash
curl -s "$NEURO_API/user" -H "Authorization: Bearer $NEURO_TOKEN"
```

```json
{
  "code": 200,
  "message": "Success",
  "data": {
    "_id": "6650f0c2...",
    "username": "satoshi",
    "demo": { "enabled": false },
    "config": {
      "trading": { "slippage": 20, "antiMev": true, "jitoTip": 0.001, "priorityLevel": "High" }
    }
  }
}
```

The response has more fields than shown. Two are useful to a script:

* `config.trading` — your default slippage and fee settings. Any trade that leaves those fields out uses these values.
* `demo.enabled` — `true` when the account is in [Paper Trading](/api/paper-trading).

## Finding your wallets

Every trade names one of your wallets by address. List them with `GET /wallets`:

```bash
# Every wallet, on every network
curl -s "$NEURO_API/wallets" -H "Authorization: Bearer $NEURO_TOKEN"

# Solana wallets only, with balances
curl -s "$NEURO_API/wallets?chainId=101&includeBalance=true" -H "Authorization: Bearer $NEURO_TOKEN"
```

| `chainId` | Network |
| --- | --- |
| `101` | Solana |
| `4663` | Robinhood Chain |

`GET /chains` lists every network the deployment you are talking to offers.

Each wallet's address is in `publicKey` — send that value as `walletAddress` when you trade.

The list follows the account's mode: in Paper Trading it returns your **paper wallets**, outside it your real ones. Fetch the list again after switching modes and use the addresses for the mode you are in.

## Signing out

`POST /auth/logout` clears the dashboard's cookie. It does not cancel the token itself; see the warning above.
