Environment
Language
Kotlin 2.2.0, running on the JVM (Temurin JDK 21). Gateway service built with Ktor.
Alpaca SDK Version
markets.alpaca:alpaca-java 0.1.3
Other Environment Details
macOS (Darwin). Server-side backend service. The issue also reproduces with plain curl (below), so it’s independent
of the SDK.
Problem
Summary
GET /v1/rebalancing/portfolios returns 403 “insufficient permission” (code 40310000) with
Broker API sandbox keys that work on every other endpoint. The same keys return 200 on
/v1/accounts and /v1/assets, so they are valid Broker API keys (key id starts with “CK”),
not Trading keys. Only the Rebalancing API is denied.
I’ve confirmed:
- Key id prefix is “CK” (Broker API key, not a PK/AK Trading key).
- /v1/accounts and /v1/assets → 200 with the same key/secret.
- /v1/rebalancing/portfolios → 403 (code 40310000, “insufficient permission”).
- /v1/beta/rebalancing/portfolios → 404 (so the non-beta path is the correct one).
What do I need to do to get access to the Rebalancing API on this sandbox account? Is it an
entitlement that has to be enabled for the account, or am I missing something in the request?
Paper or Live Trading?
Broker API — Sandbox environment (https://broker-api.sandbox.alpaca.markets).
Example Code
Same credentials for all three calls. Only rebalancing is denied.
B=https://broker-api.sandbox.alpaca.markets
KEY=<BROKER_API_KEY_ID> # starts with CK
SEC=<BROKER_API_SECRET_KEY>
curl -s -o /dev/null -w “accounts %{http_code}\n” -u “$KEY:$SEC” “$B/v1/accounts?status=ACTIVE”
curl -s -o /dev/null -w “assets %{http_code}\n” -u “$KEY:$SEC” “$B/v1/assets”
curl -s -o /dev/null -w “rebalancing %{http_code}\n” -u “$KEY:$SEC” “$B/v1/rebalancing/portfolios”