PayPal REST API credentials are a client ID and client secret per app, found in the PayPal Developer Dashboard under Apps & Credentials. You exchange the PayPal client ID and secret at /v1/oauth2/token for a bearer access token that expires after the expires_in seconds in the response, and sandbox and live apps have separate credentials.
PayPal key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| REST app client ID | — | No | Identifies your REST app | — |
| REST app client secret Sandbox and live apps have separate credentials. Never put the client secret in client-side code. | — | Yes | Authenticates your REST app when requesting access tokens | — |
| OAuth access token | — | Yes | Bearer token for REST API calls, obtained with the client credentials grant | Returned in `expires_in` seconds; request a new one when it expires |
How to create a PayPal key
- Log in to the PayPal Developer Dashboard and select Apps & Credentials.
- Under REST API apps, use the Default Application or click Create App.
- Copy the client ID and client secret for the app and store the secret in a secrets vault.
- POST them to
/v1/oauth2/tokenwith HTTP Basic auth andgrant_type=client_credentialsto get an access token.
Limiting what the key can do
PayPal does not offer narrower keys within one REST app. Use a separate app, and so separate credentials, for each environment and role, as PayPal's security guidelines recommend. A 403 NOT_AUTHORIZED response means the app lacks the OAuth scope or permission for that call.
How to rotate a PayPal key
- Open Apps & Credentials in the PayPal Developer Dashboard and select the app.
- Generate new credentials for the app using the dashboard's credential management tools.
- Deploy the new client secret to every service, then revoke or remove the old credentials.
PayPal's security guidelines say the Developer Dashboard lets you generate, rotate and revoke credentials, and recommend rotating regularly and removing credentials that are no longer used. PayPal's REST docs do not document the exact button labels.
How to revoke a PayPal key
- Open Apps & Credentials in the PayPal Developer Dashboard, select the app and revoke the credentials you no longer use.
If your PayPal key leaked
- Revoke the exposed credentials in Apps & Credentials and generate replacements.
- Update every deployment with the new client secret and request new access tokens.
- Review recent transactions and API activity on the account for anything you did not initiate.
- Use separate credentials per environment so a sandbox leak never reaches live funds.
Environment variables and CLI
PayPal's SDKs and docs read the key from PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PAYPAL_ACCESS_TOKEN or PAYPAL_ENVIRONMENT.
Things that catch people out
- The sandbox token endpoint is
https://api-m.sandbox.paypal.com/v1/oauth2/token; sandbox and live use separate credentials. - Client ID and secret are sent with HTTP Basic auth (Base64 of
CLIENT_ID:CLIENT_SECRET) and bodygrant_type=client_credentials. - The PayPal MCP server (
@paypal/mcp) takes an access token inPAYPAL_ACCESS_TOKEN, not the client secret, plusPAYPAL_ENVIRONMENTset toSANDBOXorPRODUCTION. - A PayPal Business account is needed to go live.
Common PayPal authentication errors
Client Authentication failed
HTTP 401 invalid_client: the Authorization header is missing, or the Base64-encoded client ID and secret in it are invalid.
Token signature verification failed.
HTTP 401 INVALID_TOKEN: the access token is missing, invalid or expired.
Authorization failed due to insufficient permissions.
HTTP 403 NOT_AUTHORIZED: the app's credentials are valid but lack the scope or permission for this call.
Using your PayPal key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a PayPal key, these intents fit:
| Intent | What BotPassword does |
|---|---|
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
http_request | Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused. |
store_secret | Saves a value the agent already holds as a new vault item. |
PayPal also publishes its own MCP server. Whatever server the agent uses, keep the credential it authenticates with out of the agent's context.
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
Where do I find my PayPal client ID and secret?
In the PayPal Developer Dashboard under Apps & Credentials, in the REST API apps section.
How do I get a PayPal access token?
POST to /v1/oauth2/token with Basic auth (client ID and secret) and grant_type=client_credentials; the response includes access_token and expires_in.
Do PayPal sandbox and live use the same credentials?
No. Sandbox apps and live apps have separate client IDs and secrets, and going live requires a PayPal Business account.
Why does PayPal return invalid_client?
The Authorization header is missing or the Base64-encoded client ID and secret are wrong, often because sandbox credentials were sent to the live endpoint.
Does a PayPal client secret expire?
PayPal's REST docs give no expiry for the client secret, but PayPal recommends rotating credentials regularly. Access tokens expire after expires_in seconds.
Can an AI agent use my PayPal key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, store_secret, so the agent gets the result and never the value.