Gilito AIDocs

Brokers

Connect brokerage accounts, sync positions, place orders, and configure trade guardrails.

GET/api/v1/brokers/connections

Returns a list of all connected broker accounts for the authenticated user.

Response

200 OK
GET/api/v1/brokers/connections
curl -X GET "https://api.gilito.ai/api/v1/brokers/connections" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "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"
    }
  ]
}
POST/api/v1/brokers/connections

Initiate a connection to a brokerage provider. Returns an OAuth redirect URL for the user to authorize.

Query Parameters

providerstringrequired

Broker provider (e.g., alpaca, interactive_brokers, tradier).

redirectUrlstringrequired

URL to redirect the user to after OAuth authorization.

Response

200 OK
POST/api/v1/brokers/connections
curl -X POST "https://api.gilito.ai/api/v1/brokers/connections?provider={provider}&redirectUrl={redirectUrl}" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "data": {
    "id": "conn-1a2b3c...",
    "provider": "alpaca",
    "status": "pending",
    "authorizationUrl": "https://app.alpaca.markets/oauth/authorize?..."
  }
}
DELETE/api/v1/brokers/connections/:id

Disconnect a broker account. This revokes the OAuth token and removes the connection.

Path Parameters

idstringrequired

The broker connection ID.

Response

200 OK
DELETE/api/v1/brokers/connections/:id
curl -X DELETE "https://api.gilito.ai/api/v1/brokers/connections/{id}" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "data": {
    "id": "conn-1a2b3c...",
    "status": "disconnected"
  }
}
POST/api/v1/brokers/connections/:id/sync

Trigger a manual sync of positions and balances from the connected broker.

Path Parameters

idstringrequired

The broker connection ID.

Response

200 OK
POST/api/v1/brokers/connections/:id/sync
curl -X POST "https://api.gilito.ai/api/v1/brokers/connections/{id}/sync" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "data": {
    "id": "conn-1a2b3c...",
    "syncStatus": "syncing",
    "startedAt": "2026-04-03T14:30:00.000Z"
  }
}
GET/api/v1/brokers/connections/:id/logs

Returns the sync history for a broker connection.

Path Parameters

idstringrequired

The broker connection ID.

Response

200 OK
GET/api/v1/brokers/connections/:id/logs
curl -X GET "https://api.gilito.ai/api/v1/brokers/connections/{id}/logs" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "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"
    }
  ]
}
GET/api/v1/brokers/orders

Returns a list of orders placed through Gilito.

Query Parameters

statusstringoptional

Filter by status (pending, filled, cancelled, rejected).

sidestringoptional

Filter by side (buy, sell).

pagenumberoptional

Page number for pagination.

limitnumberoptional

Results per page (default 20, max 100).

Response

200 OK
GET/api/v1/brokers/orders
curl -X GET "https://api.gilito.ai/api/v1/brokers/orders?status={status}&side={side}&page={page}&limit={limit}" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "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 }
}
POST/api/v1/brokers/orders

Place an order through a connected broker.

Query Parameters

connectionIdstringrequired

The broker connection ID to use.

assetIdstring (UUID)required

The asset to trade.

sidestringrequired

Order side: buy or sell.

typestringrequired

Order type: market or limit.

quantitynumberrequired

Number of shares/units.

limitPricenumberoptional

Limit price (required for limit orders).

Response

200 OK
POST/api/v1/brokers/orders
curl -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"
Try It
Example Response
{
  "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"
  }
}
DELETE/api/v1/brokers/orders/:id

Cancel a pending order.

Path Parameters

idstringrequired

The order ID.

Response

200 OK
DELETE/api/v1/brokers/orders/:id
curl -X DELETE "https://api.gilito.ai/api/v1/brokers/orders/{id}" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "data": {
    "id": "ord-xyz789...",
    "status": "cancelled"
  }
}
GET/api/v1/brokers/guardrails

Returns the current trade guardrail settings for the authenticated user.

Response

200 OK
GET/api/v1/brokers/guardrails
curl -X GET "https://api.gilito.ai/api/v1/brokers/guardrails" \
  -H "Authorization: Bearer YOUR_API_KEY"
Try It
Example Response
{
  "data": {
    "maxDailyTrades": 20,
    "maxPositionSizePct": 25,
    "maxPortfolioRiskPct": 5,
    "stopLossRequired": true,
    "allowedAssetTypes": ["stock", "etf"],
    "updatedAt": "2026-04-01T10:00:00.000Z"
  }
}
PATCH/api/v1/brokers/guardrails

Update trade guardrail settings. Only provided fields are updated.

Query Parameters

maxDailyTradesnumberoptional

Maximum trades allowed per day.

maxPositionSizePctnumberoptional

Maximum position size as percentage of portfolio.

maxPortfolioRiskPctnumberoptional

Maximum portfolio risk percentage.

stopLossRequiredbooleanoptional

Whether stop-loss is required on all orders.

allowedAssetTypesstring[]optional

Allowed asset types (stock, etf, crypto, etc.).

Response

200 OK
PATCH/api/v1/brokers/guardrails
curl -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"
Try It
Example Response
{
  "data": {
    "maxDailyTrades": 30,
    "maxPositionSizePct": 20,
    "maxPortfolioRiskPct": 5,
    "stopLossRequired": true,
    "allowedAssetTypes": ["stock", "etf"],
    "updatedAt": "2026-04-04T09:00:00.000Z"
  }
}