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

# Authentication

Open an account, bind an API key, and sign requests.

## Authentication overview

> **v1.3.3** · 2026-08-19 · Base: `https://api-trade.rwaperp.xyz`\
> **X Layer only** (`chainId = 196`). No other chain is supported.\
> Follow Account onboarding to open an account and bind a key. Then use the sample trading script to exercise the primary trading operations.

REST uses **`RWA-*` headers**; the private WebSocket uses **`rwa_*` query parameters**.

***

### Authentication layers

| Layer           | Algorithm   | Purpose                           | Stored by                       |
| --------------- | ----------- | --------------------------------- | ------------------------------- |
| Account binding | EVM EIP-712 | Open account, bind API public key | Wallet private key (one-time)   |
| API requests    | Ed25519     | REST / private WebSocket          | Client application (long-lived) |

`/v1/public/*` requires no API key. **The wallet private key is not the API secret.** Generate a separate Ed25519 key pair, then bind its public key with an EIP-712 signature from your wallet.

***

### Credentials and endpoints

| Name            | Sent as                    | Notes                                                              |
| --------------- | -------------------------- | ------------------------------------------------------------------ |
| `account_id`    | `RWA-Account-Id` / WS path | `0x`-prefixed value containing 64 hexadecimal characters           |
| API public key  | `RWA-Api-Key`              | `ed25519:` + base58                                                |
| API private key | Never transmitted          | base58 seed, signs locally                                         |
| Timestamp       | `RWA-Timestamp`            | Milliseconds                                                       |
| Signature       | `RWA-Signature`            | Ed25519 signature encoded as URL-safe Base64, without trailing `=` |

| Type       | URL                                                                        |
| ---------- | -------------------------------------------------------------------------- |
| REST       | `https://api-trade.rwaperp.xyz`                                            |
| Public WS  | `wss://api-trade.rwaperp.xyz/ws/public/ws/stream/{account_id}`             |
| Private WS | `wss://api-trade.rwaperp.xyz/ws/private/v2/ws/private/stream/{account_id}` |

**Supported chain: X Layer only.** The EIP-712 domain `chainId` used for opening an account or binding a key must be `196`. Arbitrum, Base, Avalanche, Ethereum and every other chain are unsupported; passing any other `chainId` will fail signature verification.

| Chain       | chainId | Supported      |
| ----------- | ------- | -------------- |
| **X Layer** | `196`   | **Yes (only)** |

***

### Authentication by endpoint

| Authentication       | Typical endpoints                                                                         |
| -------------------- | ----------------------------------------------------------------------------------------- |
| None                 | `/v1/public/*`, `/v1/get_account`                                                         |
| RWA signature        | `/v1/order`, `/v1/positions`, `/v1/client/holding`                                        |
| Wallet EIP-712       | Account opening and key binding: `register_dex_account`, `dex_api_key` (off-chain domain) |
| Wallet EIP-712 + RWA | Withdrawals: `withdraw_request` (on-chain domain)                                         |


---

# 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://rwaperp-1.gitbook.io/rwaperp-docs/rwa-perp-b2b-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.
