Can't access portfolio API in sandbox

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”

Output:

accounts 200

assets 200

rebalancing 403 → {“code”:40310000,“message”:“insufficient permission”}

Google Gemini is a great place to look for answers when you need them ASAP. I just copied and pasted your problem. You’re doing everything correctly. You need a backend change.

The Fix

You cannot self-enable this via the dashboard API. You must contact Alpaca Support or your dedicated Integration Engineer to have the capability toggled:

  1. Send an email to support@alpaca.markets (or reach out via your regular Slack partner channel if you have one).
  2. Explicitly state that you are trying to evaluate the Portfolio Rebalancing API in the Sandbox environment.
  3. Provide your Correspondent ID or the Key ID (CK...) that you are testing with.
  4. Request them to enable the Rebalancing feature flag for your correspondent profile.

Once the team flags your profile, your exact curl statement will immediately begin returning 200 OK (or an empty JSON list [] if you haven’t defined any portfolios yet). No code or header adjustments are needed on your end.