How to get a Charles Schwab Trader API API key

Schwab gives you an app key and app secret for a registered app, then you obtain tokens through a one-time OAuth login. Plan for a few days of app review.

About 30 minutes 5 steps Checked October 2026

Before you start

  • A Schwab brokerage account (for trading and market data on your accounts)
  • A separate developer account on developer.schwab.com
  • A callback URL you control, e.g. https://127.0.0.1

Create your Charles Schwab Trader API API key

  1. 1

    Create a developer account

    Sign up on developer.schwab.com. This login is separate from your brokerage login.

  2. 2

    Create an app

    Under Dashboard → Apps, create an app, add the Accounts and Trading Production and Market Data Production products, and set the callback URL.

  3. 3

    Wait for approval

    The app shows Approved – Pending until Schwab reviews it, then Ready For Use. Copy the App Key and Secret.

  4. 4

    Authorize in the browser

    Visit https://api.schwabapi.com/v1/oauth/authorize?client_id=APP_KEY&redirect_uri=CALLBACK, log in with your brokerage credentials and copy the code parameter from the redirect URL.

  5. 5

    Exchange the code

    POST to https://api.schwabapi.com/v1/oauth/token with grant_type=authorization_code, the code and redirect URI, using Basic auth of app key and secret. Save the refresh token as SCHWAB_REFRESH_TOKEN.

Test the key

Before wiring the key into a strategy, make one request by hand. It separates “the key is wrong” from “my code is wrong”.

curl -s -H "Authorization: Bearer $ACCESS_TOKEN" \
  https://api.schwabapi.com/trader/v1/accounts/accountNumbers
A list of account numbers and hashes means the token works. 401 means the access token expired; refresh it.

Keep the credentials safe

  • Store values in a password manager or a git-ignored .env, never in code or notebooks you share.
  • In an AlgoGP project you can still add them under APIs & keys (encrypted at rest) and read them with strategy_runtime.secrets.get("SCHWAB_APP_KEY").
  • Give each bot its own credential so you can revoke one without stopping the others.
SCHWAB_APP_KEY=paste-your-value-here
SCHWAB_APP_SECRET=paste-your-value-here
SCHWAB_REFRESH_TOKEN=paste-your-value-here
.env for local runs

Troubleshooting

Login loop on authorize
Use brokerage credentials, not the developer-portal login.
unsupported_token_type / invalid_client
Basic auth header must be base64 of APP_KEY:APP_SECRET.

Frequently asked questions

How long is a Schwab access token valid?

About 30 minutes. Refresh tokens last about 7 days.

Can I skip the browser login?

No. The authorization-code step needs a browser login at least every time the refresh token expires.

Design and backtest your Charles Schwab Trader API strategy first

AlgoGP turns an idea into Python and tests it on years of history before you connect it to Charles Schwab Trader API. The exported code keeps the broker behind four small adapter methods.

  • AI copilot writes and revises the rules
  • Backtests with realistic costs
  • Exported Python ready to wire to Charles Schwab Trader API

Free plan, no card required.

How the Charles Schwab Trader API works

AlgoGP is not affiliated with Charles Schwab Trader API. Menus get renamed from time to time; if a label differs, the official documentation has the current path.