Skip to main content
All API access is authenticated using OAuth 2.0. Your app receives access tokens that are scoped to the specific permissions each merchant granted during installation. Base URL:

Authorization Code Flow

This is the primary flow for apps installed by merchants. When a merchant installs your app from the marketplace, OrderProtection delivers an authorization code to your redirect URI. You exchange this code for access and refresh tokens.

1. Merchant installs your app

When a merchant clicks Install on your app, they review and approve the requested scopes. OrderProtection then delivers an authorization code to your first registered redirect URI as a server-to-server GET (your endpoint must respond 2xx within 10 seconds or the install rolls back):
Consent happens inside the OrderProtection dashboard (or via the install API, where the code comes back in the response body instead) — there is no hosted /oauth/authorize web page to redirect merchants to. Don’t construct an authorize URL by convention from other OAuth providers; the code is delivered from the install/approve step. Full install reference: Installing Your App.

2. Exchange code for tokens

Exchange the authorization code for an access token and refresh token:

Token response

PKCE support

The authorization code flow supports PKCE (Proof Key for Code Exchange) with the S256 method for enhanced security. If a code_challenge was provided during authorization, you must include the code_verifier when exchanging the code:

Client Credentials Flow

Use this flow for server-to-server access when no user interaction is needed. This is useful for background jobs, data sync, or admin operations.
The client credentials flow requires an existing installation on the target store. A merchant must have already installed your app (granting scopes) before you can use this flow. The store_id parameter tells OrderProtection which installation to use for determining your granted scopes.
The scopes parameter is optional and acts as a filter. If omitted, the token will include all scopes granted by the merchant during installation.

Refreshing tokens

Access tokens expire after 1 hour. Use the refresh token to obtain a new access token without requiring the merchant to re-authorize:
The response includes a new access token and a new refresh token. Always store and use the latest refresh token — previous ones are rotated.

Revoking tokens

When a merchant disconnects your app or you need to invalidate tokens, revoke them explicitly:

Using access tokens

Include the access token in the Authorization header of every API request:
Access tokens are scoped to the permissions the merchant granted. If you attempt to access an endpoint that requires a scope the merchant did not grant, you will receive a 403 Forbidden response.

Token prefixes

OrderProtection tokens use prefixes for easy identification: