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

# Introduction

> Overview of the Wealthyhood API reference sections

<Info>
  This API reference is powered by OpenAPI specs. Use the sections below to explore endpoints and interactive examples.
</Info>

## API Sections

<CardGroup cols={2}>
  <Card title="Authentication API" icon="key" href="/api-reference/auth/get-token">
    Obtain OAuth 2.0 access tokens using client credentials flow.
  </Card>

  <Card title="Users API" icon="user" href="/api-reference/users/create-user">
    Create and manage user accounts with personal information, address, tax residency, nationality, and employment details.
  </Card>

  <Card title="Cash API" icon="money-bill" href="/api-reference/cash/get-cash">
    Access user cash balances across multiple currencies.
  </Card>

  <Card title="Savings Vault API" icon="vault" href="/api-reference/savings-vault/get-savings-vault">
    Access user savings vault balances across all savings products.
  </Card>

  <Card title="Portfolios API" icon="folder-open" href="/api-reference/portfolio/get-holdings">
    Portfolio holdings, target allocation, prices, and returns by tenor.
  </Card>

  <Card title="Daily Summaries API" icon="chart-line" href="/api-reference/daily-summaries/get-daily-summaries">
    Historical daily portfolio snapshots with performance metrics and market insights.
  </Card>

  <Card title="Investment products API" icon="magnifying-glass" href="/api-reference/investment-products/investment-products">
    Listed instruments, fundamentals, tickers, and asset-specific data.
  </Card>

  <Card title="Investment Orders API" icon="arrow-right-arrow-left" href="/api-reference/order-execution/submit-order">
    Submit single-instrument trades and receive enriched transaction responses.
  </Card>

  <Card title="Savings Orders API" icon="piggy-bank" href="/api-reference/savings-orders/submit-savings-order">
    Create and manage top up and withdrawal orders for user savings plans.
  </Card>

  <Card title="Learn API" icon="graduation-cap" href="/api-reference/learn/analyst-insights">
    Editorial content, learning guides, news articles, and glossary endpoints.
  </Card>

  <Card title="Test API" icon="flask" href="/api-reference/test/create-user">
    Test endpoints for sandbox environments. Create test users, simulate deposits, and manage test data.
  </Card>
</CardGroup>

## Authentication

All API endpoints require authentication using OAuth 2.0 bearer tokens. To make authenticated requests:

### Step 1: Obtain an access token

Use the [Authentication API](/api-reference/auth/get-token) to obtain a bearer token via the OAuth 2.0 client credentials flow:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "<auth-endpoint-url>" \
    -H "Content-Type: application/json" \
    -d '{
      "grant_type": "client_credentials",
      "audience": "<audience>",
      "client_id": "<your-client-id>",
      "client_secret": "<your-client-secret>"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("<auth-endpoint-url>", {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      grant_type: "client_credentials",
      audience: "<audience>",
      client_id: "<your-client-id>",
      client_secret: "<your-client-secret>"
    })
  });

  const { access_token } = await response.json();
  ```
</CodeGroup>

<Info>
  Contact [hello@wealthyhood.com](mailto:hello@wealthyhood.com) to receive your `client_id` and `client_secret`.
</Info>

### Step 2: Include the bearer token in requests

Add the access token to the `Authorization` header of all API requests:

```bash theme={null}
Authorization: Bearer <access_token>
```

### Step 3: Include user identification header

Most endpoints require an additional header to identify the user whose data you're accessing. The header name varies by API:

<Tabs>
  <Tab title="x-user-id">
    The following APIs use the `x-user-id` header:

    * **Investment Orders API** - Submit and manage investment orders
    * **Portfolios API** - Access portfolio holdings and returns
    * **Cash API** - Retrieve user cash balances
    * **Investment Products API** (some endpoints) - Asset-specific data with user context

    ```bash theme={null}
    x-user-id: <user-identifier>
    ```
  </Tab>
</Tabs>

<Note>
  The user identifier must match a valid user in the Wealthyhood platform. See the [Users API](/api-reference/users/create-user) for user creation. Always check the specific endpoint documentation for the exact header requirement.
</Note>

### Complete request example

<CodeGroup>
  ```bash cURL (Cash API) theme={null}
  curl -X GET "https://api.sandbox.wealthyhood.com/cash" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
    -H "x-user-id: user-12345"
  ```

  ```javascript JavaScript (Portfolios API) theme={null}
  const response = await fetch("https://api.sandbox.wealthyhood.com/portfolios", {
    headers: {
      "Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
      "x-user-id": "user-12345"
    }
  });
  ```

  ```bash cURL (Learn API) theme={null}
  curl -X GET "https://api.sandbox.wealthyhood.com/learn/analyst-insights" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
    -H "x-user-id: user-12345"
  ```
</CodeGroup>
