Investbrain has a JSON REST API for reading and managing your portfolios, transactions, and holdings, looking up market data, and exporting a backup of your account. Use it to build scripts, sync data from a brokerage, feed a spreadsheet, or integrate with other tools.
Creating an API token
The API authenticates with personal access tokens.
- Sign in to Investbrain and open API Tokens from the user menu (or go to
/user/api-tokens). On Investbrain Cloud, you need to verify your email address before this page is available. - Under Create API Token, enter a Token Name that reminds you what it's for, such as "Home spreadsheet" or "Brokerage sync script".
- Click Create.
- Copy the token from the dialog. It's only shown once. If you lose it, delete it and create a new one.

The token acts as you: it can see and change everything your account can, across every portfolio you have access to. Keep it secret and don't commit it to source control.
Managing tokens
The Manage API Tokens section on the same page lists your active tokens and when each was created. Click Delete next to a token to revoke it immediately. Any script using it will start receiving 401 Unauthorized responses.
API tokens work only with the REST API. They can't be used with the MCP server, which uses OAuth instead.
Making requests
Base URL
| Where you use Investbrain | Base URL |
|---|---|
| Investbrain Cloud | https://investbra.in/api |
| Self-hosted | https://<your-investbrain-host>/api (for a default local install, http://localhost:8000/api) |
The examples on this page use Investbrain Cloud. If you self-host, replace https://investbra.in with your own address.
Headers
Send your token as a bearer token, and ask for JSON so errors are returned as JSON too:
Authorization: Bearer <your-token>
Accept: application/json
Send request bodies as JSON with Content-Type: application/json.
Example: check that your token works
Request:
curl https://investbra.in/api/me \
-H "Authorization: Bearer $INVESTBRAIN_TOKEN" \
-H "Accept: application/json"
Response:
{
"id": "3f8e2b4c-...",
"name": "Jane Doe",
"email": "jane@example.com",
"profile_photo_url": "https://...",
"options": {
"display_currency": "USD",
"locale": "en_US"
},
"created_at": "2025-01-04T18:22:10.000000Z",
"updated_at": "2026-10-30T09:12:45.000000Z"
}
Single records are returned as a plain JSON object. Lists are wrapped in data with pagination details (see below).
Pagination, sorting, filtering, and search
The three list endpoints (GET /portfolio, GET /transaction, and GET /holding) share the same query parameters.
| Parameter | Example | Description |
|---|---|---|
page |
page=2 |
Page number, starting at 1. |
itemsPerPage |
itemsPerPage=50 |
Results per page. Default 15, maximum 100. |
sort |
sort=-date,symbol |
Comma-separated columns. Prefix with - for descending. |
filter[<name>] |
filter[symbol]=AAPL,MSFT |
Exact match. Separate values with commas to match any of them. For true/false filters, use true/false or 1/0. |
search |
search=apple |
Case-insensitive partial match on the endpoint's search columns. |
Using a sort or filter that isn't supported for that endpoint returns a 422 validation error listing the allowed values.
Without sort, results come back in no particular order. If you page through results, pass sort so the order stays the same from page to page.
List responses look like this (links and meta are shortened here):
{
"data": [ { "...": "..." } ],
"links": {
"first": "https://investbra.in/api/transaction?page=1",
"last": "https://investbra.in/api/transaction?page=4",
"prev": null,
"next": "https://investbra.in/api/transaction?page=2"
},
"meta": {
"current_page": 1,
"last_page": 4,
"per_page": 15,
"total": 52
}
}
The links keep your other query parameters, so you can follow next until it's null to read every page.
Exporting a backup
The API can export the same backup workbook as the Import / Export page. The workbook is built in the background, so exporting takes three steps:
- Start an export with
POST /export. The response is202 Acceptedwith the export'sidand astatusofpending. - Check on it with
GET /export/{id}every few seconds untilstatusissuccess(orfailed). - Download the workbook from the
download_urlin that response (GET /export/{id}/download).
Request:
curl -X POST https://investbra.in/api/export \
-H "Authorization: Bearer $INVESTBRAIN_TOKEN" \
-H "Accept: application/json"
Response:
{
"id": "9d2f6c1e-...",
"status": "pending",
"download_url": null,
"created_at": "2026-11-25T14:03:11.000000Z",
"completed_at": null,
"expires_at": "2026-11-26T14:03:11.000000Z"
}
Once status is success, save the workbook:
curl https://investbra.in/api/export/9d2f6c1e-.../download \
-H "Authorization: Bearer $INVESTBRAIN_TOKEN" \
-o investbrain_backup.xlsx
A few things to know:
- Exports are shared with the Import / Export page. If an export is already being prepared,
POST /exportreturns that one instead of starting another. - Only your latest export is kept. Starting a new one deletes the previous workbook.
- An export can be downloaded for 24 hours after it's started (see
expires_at). - You can start up to 3 exports per minute. Past that,
POST /exportreturns429 Too Many Requests. - If
statusisfailed, start a new export to try again.
Permissions
The API follows the same permissions as the web app: you can read any portfolio you have access to, but creating, changing, or deleting anything requires full access to the portfolio.
Errors
| Status | Meaning |
|---|---|
200 OK, 201 Created, 202 Accepted, 204 No Content |
Success. 201 is returned when a portfolio or transaction is created, 202 when an export is started, and 204 after a delete. |
401 Unauthorized |
Missing, invalid, expired, or revoked token. |
403 Forbidden |
You don't have access to that portfolio, or you only have read-only access and tried to change something. |
404 Not Found |
The record doesn't exist, the symbol isn't recognized, or the export isn't ready to download. |
422 Unprocessable Content |
Validation failed. See the errors object for details. |
429 Too Many Requests |
You've hit a rate limit. Wait the number of seconds in the Retry-After header, then try again. |
Validation errors look like this:
{
"message": "The quantity must not be greater than the available quantity.",
"errors": {
"quantity": ["The quantity must not be greater than the available quantity."]
}
}
If you get an HTML login page instead of a JSON error, add the Accept: application/json header.
Rate limits
Each user can make 60 requests per minute across the whole API; all endpoints share that budget. Over the limit, the API returns 429 Too Many Requests with a Retry-After header saying how many seconds to wait. Every response includes X-RateLimit-Limit and X-RateLimit-Remaining headers so you can slow down before you hit it.
OpenAPI specification
A machine-readable OpenAPI specification of the API is kept in this repository at docs/openapi.json. You can import into Postman, Insomnia, or Bruno to browse endpoints and try requests.
If the spec and this page ever disagree, please open an issue.