Brokers
Connect brokerage accounts, sync positions, place orders, and configure trade guardrails.
/api/v1/brokers/connectionsReturns a list of all connected broker accounts for the authenticated user.
Response
200 OKcurl -X GET "https://api.gilito.ai/api/v1/brokers/connections" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": [
{
"id": "conn-1a2b3c...",
"provider": "alpaca",
"status": "active",
"accountName": "Main Trading",
"lastSyncAt": "2026-04-03T14:30:00.000Z",
"createdAt": "2026-03-01T10:00:00.000Z"
}
]
}/api/v1/brokers/connectionsInitiate a connection to a brokerage provider. Returns an OAuth redirect URL for the user to authorize.
Query Parameters
providerstringrequiredBroker provider (e.g., alpaca, interactive_brokers, tradier).
redirectUrlstringrequiredURL to redirect the user to after OAuth authorization.
Response
200 OKcurl -X POST "https://api.gilito.ai/api/v1/brokers/connections?provider={provider}&redirectUrl={redirectUrl}" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": {
"id": "conn-1a2b3c...",
"provider": "alpaca",
"status": "pending",
"authorizationUrl": "https://app.alpaca.markets/oauth/authorize?..."
}
}/api/v1/brokers/connections/:idDisconnect a broker account. This revokes the OAuth token and removes the connection.
Path Parameters
idstringrequiredThe broker connection ID.
Response
200 OKcurl -X DELETE "https://api.gilito.ai/api/v1/brokers/connections/{id}" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": {
"id": "conn-1a2b3c...",
"status": "disconnected"
}
}/api/v1/brokers/connections/:id/syncTrigger a manual sync of positions and balances from the connected broker.
Path Parameters
idstringrequiredThe broker connection ID.
Response
200 OKcurl -X POST "https://api.gilito.ai/api/v1/brokers/connections/{id}/sync" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": {
"id": "conn-1a2b3c...",
"syncStatus": "syncing",
"startedAt": "2026-04-03T14:30:00.000Z"
}
}/api/v1/brokers/connections/:id/logsReturns the sync history for a broker connection.
Path Parameters
idstringrequiredThe broker connection ID.
Response
200 OKcurl -X GET "https://api.gilito.ai/api/v1/brokers/connections/{id}/logs" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": [
{
"syncId": "sync-abc123...",
"status": "completed",
"positionsSynced": 12,
"startedAt": "2026-04-03T14:30:00.000Z",
"completedAt": "2026-04-03T14:30:05.000Z"
},
{
"syncId": "sync-def456...",
"status": "failed",
"error": "Rate limit exceeded",
"startedAt": "2026-04-03T12:00:00.000Z",
"completedAt": "2026-04-03T12:00:01.000Z"
}
]
}/api/v1/brokers/ordersReturns a list of orders placed through Gilito.
Query Parameters
statusstringoptionalFilter by status (pending, filled, cancelled, rejected).
sidestringoptionalFilter by side (buy, sell).
pagenumberoptionalPage number for pagination.
limitnumberoptionalResults per page (default 20, max 100).
Response
200 OKcurl -X GET "https://api.gilito.ai/api/v1/brokers/orders?status={status}&side={side}&page={page}&limit={limit}" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": [
{
"id": "ord-xyz789...",
"connectionId": "conn-1a2b3c...",
"assetId": "a1b2c3d4-...",
"symbol": "AAPL",
"side": "buy",
"type": "limit",
"quantity": 10,
"limitPrice": 178.50,
"status": "filled",
"filledAt": "2026-04-03T14:35:00.000Z"
}
],
"meta": { "total": 45, "page": 1, "limit": 20 }
}/api/v1/brokers/ordersPlace an order through a connected broker.
Query Parameters
connectionIdstringrequiredThe broker connection ID to use.
assetIdstring (UUID)requiredThe asset to trade.
sidestringrequiredOrder side: buy or sell.
typestringrequiredOrder type: market or limit.
quantitynumberrequiredNumber of shares/units.
limitPricenumberoptionalLimit price (required for limit orders).
Response
200 OKcurl -X POST "https://api.gilito.ai/api/v1/brokers/orders?connectionId={connectionId}&assetId={assetId}&side={side}&type={type}&quantity={quantity}&limitPrice={limitPrice}" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": {
"id": "ord-xyz789...",
"connectionId": "conn-1a2b3c...",
"assetId": "a1b2c3d4-...",
"symbol": "AAPL",
"side": "buy",
"type": "limit",
"quantity": 10,
"limitPrice": 178.50,
"status": "pending",
"createdAt": "2026-04-03T14:35:00.000Z"
}
}/api/v1/brokers/orders/:idCancel a pending order.
Path Parameters
idstringrequiredThe order ID.
Response
200 OKcurl -X DELETE "https://api.gilito.ai/api/v1/brokers/orders/{id}" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": {
"id": "ord-xyz789...",
"status": "cancelled"
}
}/api/v1/brokers/guardrailsReturns the current trade guardrail settings for the authenticated user.
Response
200 OKcurl -X GET "https://api.gilito.ai/api/v1/brokers/guardrails" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": {
"maxDailyTrades": 20,
"maxPositionSizePct": 25,
"maxPortfolioRiskPct": 5,
"stopLossRequired": true,
"allowedAssetTypes": ["stock", "etf"],
"updatedAt": "2026-04-01T10:00:00.000Z"
}
}/api/v1/brokers/guardrailsUpdate trade guardrail settings. Only provided fields are updated.
Query Parameters
maxDailyTradesnumberoptionalMaximum trades allowed per day.
maxPositionSizePctnumberoptionalMaximum position size as percentage of portfolio.
maxPortfolioRiskPctnumberoptionalMaximum portfolio risk percentage.
stopLossRequiredbooleanoptionalWhether stop-loss is required on all orders.
allowedAssetTypesstring[]optionalAllowed asset types (stock, etf, crypto, etc.).
Response
200 OKcurl -X PATCH "https://api.gilito.ai/api/v1/brokers/guardrails?maxDailyTrades={maxDailyTrades}&maxPositionSizePct={maxPositionSizePct}&maxPortfolioRiskPct={maxPortfolioRiskPct}&stopLossRequired={stopLossRequired}&allowedAssetTypes={allowedAssetTypes}" \
-H "Authorization: Bearer YOUR_API_KEY"{
"data": {
"maxDailyTrades": 30,
"maxPositionSizePct": 20,
"maxPortfolioRiskPct": 5,
"stopLossRequired": true,
"allowedAssetTypes": ["stock", "etf"],
"updatedAt": "2026-04-04T09:00:00.000Z"
}
}