> For the complete documentation index, see [llms.txt](https://docs.investhub.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.investhub.org/overview.md).

# API Reference

Investhub’s backend is built on **Supabase Edge Functions**. The frontend calls them via the Supabase client:

```ts
const { data, error } = await supabase.functions.invoke('function-name', {
  body: { ... }
});
```

## Try the API (interactive docs)

Use the **API Reference** in this documentation to browse all endpoints and **try them out** (send requests, see responses). That experience is powered by the same standard as [Swagger / OpenAPI](https://swagger.io/why-swagger/) — an OpenAPI spec is imported into GitBook so you get interactive “Test it” for each endpoint. You do **not** need to open the raw spec file on GitHub; everything is available here in the API Reference section.

If the API Reference is not yet visible in the sidebar, an admin needs to add the OpenAPI specification once in GitBook (Integrations → Add OpenAPI specification → URL or File). After that, readers can try endpoints directly from the docs.

## Base URL

Edge Functions are served under your project’s Supabase URL:

* **Production**: `https://<project-ref>.supabase.co/functions/v1/<function-name>`
* Requests use **POST** with `Content-Type: application/json` when sending a body.

## Authentication

Most endpoints require a **Privy JWT**. Send it in the `Authorization` header:

```http
Authorization: Bearer <privy_access_token>
```

The backend verifies the token and derives the user ID from the JWT `sub` claim. Some endpoints are **public** (e.g. `get-opportunities`, `get-opportunity`, `get-token-price`, `create-commitment`). The API Reference indicates which require auth.

## What’s documented

The OpenAPI spec used by this space covers a large part of the app:

| Area                                           | Examples                                                                                                                                                              |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Auth**                                       | `get-profile`, `update-profile`, `sync-privy-profile`, `wallet-auth`, `verify-wallet-signature`                                                                       |
| **Opportunities**                              | `get-opportunities`, `get-opportunity`, `create-opportunity`                                                                                                          |
| **Investments**                                | `create-investment`, `pay-investment`, `process-crypto-payment`, `get-user-investments`, `sponsored-transaction`                                                      |
| **KYC**                                        | `get-kyc-status`, `get-kyc-info`, `submit-kyc`, `get-sumsub-token`                                                                                                    |
| **Company**                                    | `get-company`, `update-company`, `create-tenant`, `manage-shareholders`                                                                                               |
| **Incorporate**                                | `save-incorporation-draft`, `get-incorporation-draft`, `create-incorporation-checkout`, `create-tokenized-ag`, `generate-lvc-documents`, `calculate-lvc-risk-factors` |
| **Manage – Expenses**                          | `get-expenses`, `create-expense`, `approve-expense`, `reject-expense`, `manage-expense-report-templates`                                                              |
| **Manage – Accounts / Branches / Cards**       | `get-accounts`, `create-account`, `get-branches`, `create-branch`, `get-cards`, `create-card`                                                                         |
| **Manage – Categories / Groups / Tax / Users** | `get-categories`, `manage-groups`, `get-tax-rates`, `get-users`, `invite-user-with-role`                                                                              |
| **Manage – Xero**                              | `get-xero-settings`, `sync-xero-data`, `create-xero-invoice`, `create-xero-payment`                                                                                   |
| **Wallets**                                    | `get-wallets`, `add-wallet`, `manage-wallet-tokens`, `get-wallet-assets-v2`, `get-token-price`, `get-swap-quote`                                                      |
| **Portfolio**                                  | `get-portfolio-cached`, `get-portfolio-snapshots`, `save-portfolio-snapshot`                                                                                          |
| **Payments**                                   | `assign-volt-viban`, `create-stripe-checkout-session`, Monerium endpoints, Coinbase onramp, subscriptions                                                             |
| **Security**                                   | IP whitelist, MFA status                                                                                                                                              |
| **Documents**                                  | `upload-document-v2`, `extract-document-data-v2`, `parse-invoice`                                                                                                     |

For the full list and to try any endpoint, use the **API Reference** in the sidebar (OpenAPI-powered).

## Regenerating the spec (maintainers)

The OpenAPI YAML is generated from `scripts/openapi-config.json`. To add or change endpoints:

```bash
npm run docs:generate
```

Then commit and push `docs/gitbook/api/openapi.yaml`. If GitBook is configured to use the spec via URL, it will pick up updates automatically; otherwise update the spec in GitBook (Integrations → OpenAPI → Update).


---

# 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:

```
GET https://docs.investhub.org/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
