---
title: "Finish Alpaca OAuth"
method: GET
path: "/v1/brokers/alpaca/callback"
tags: ["Brokers"]
---

# Finish Alpaca OAuth

`GET /v1/brokers/alpaca/callback`

## Request

- Base URL: `https://api.marketintell.ai`
- URL: `https://api.marketintell.ai/v1/brokers/alpaca/callback`
- Auth: none required

OAuth redirect target hit by Alpaca (not called directly by clients). Exchanges the code for tokens, verifies via /v2/account, stores AES-256-GCM-encrypted creds, auto-grants the `trade` scope, and returns a small HTML page that closes the popup. The signed `state` authenticates the user — no API key is sent.

## Query parameters

- `code` string
- `state` string
- `error` string

## Response `200`

HTML popup-close page (success or failure rendered inline)

## Other responses

- `400`: Missing code/state or invalid signed state

---

[API](https://skmtc.dev/marketintell/apis/marketintell-api.md) · [All operations](https://skmtc.dev/marketintell/apis/marketintell-api/llms.txt) · [OpenAPI document](https://skmtc.dev/marketintell/apis/marketintell-api/revisions/f3ef87afc41f?raw)
