Authentication

Set up an OAuth 2.0 client in Zoey and authenticate with an access token or an API key.

The Zoey REST API uses OAuth 2.0. You create an OAuth 2.0 client in your store's admin, choose which grant types it may use, and then send either a bearer access token or the client's API key with each request.

🚧

SOAP and OAuth 1.0 are deprecated

Integrations still on OAuth 1.0 (consumer key and token) keep working, but new integrations should use OAuth 2.0.

1. Create an OAuth 2.0 client

  1. In the Zoey Admin, go to Settings > APIs and click Manage on Zoey REST API - oAuth 2.
  2. Click Add New.
  3. Enter a Name and set Enabled to Yes.
  4. Choose the Allowed Grant Types (see the table below).
  5. For Authorization Code: add your app's callback under Allowed Redirect URLs and decide on With PKCE.
  6. Click Save. The client now shows its Client ID, Client Secret / API Key, Auth URL and Token URL.
❗️

Keep the Client ID and Client Secret private. Anyone with the secret can call your store's API.

2. Pick a grant type

Grant typeUse it whenWhat you send
Authorization CodeAn admin user signs in and approves your app (apps, Postman, AI assistants). The token acts with that admin user's permissions.Send the user to the Auth URL, then exchange the returned code at the Token URL.
Refresh TokenTogether with Authorization Code, to get new access tokens without asking the user again.grant_type=refresh_token at the Token URL.
Client CredentialsServer-to-server integrations with no user.grant_type=client_credentials with the client ID and secret at the Token URL.
API KEYThe simplest server-to-server option: no token exchange.The client secret in an Api-Key header on every request.

A client only accepts the grant types you selected on it.

3. Get an access token

The Token URL is https://{your-store-domain}/oauth/token. Send the client ID and secret either as HTTP Basic auth (recommended) or as client_id and client_secret form fields.

Client credentials:

curl -X POST https://yourstore.zoeysite.com/oauth/token \
  -u "CLIENT_ID:CLIENT_SECRET" \
  -d grant_type=client_credentials

Authorization code: send the user's browser to the client's Auth URL (https://{your-store-domain}/admin/oauth_authorize) with response_type=code, client_id and redirect_uri. After they approve, exchange the code within one minute:

curl -X POST https://yourstore.zoeysite.com/oauth/token \
  -u "CLIENT_ID:CLIENT_SECRET" \
  -d grant_type=authorization_code \
  -d code=THE_CODE \
  -d redirect_uri=https://yourapp.example.com/callback

With PKCE, also send code_challenge (S256 only) on the authorize request and code_verifier on the token request.

Response:

{
  "token_type": "bearer",
  "expires_in": 3600,
  "access_token": "…",
  "refresh_token": "…"
}
TokenLifetime
Access token1 hour
Refresh token2 weeks
Authorization code1 minute

4. Call the API

With an access token:

curl https://yourstore.zoeysite.com/api/rest/sales2/orders?limit=5 \
  -H "Accept: application/json" \
  -H "Authorization: Bearer ACCESS_TOKEN"

With an API key (the client must allow the API KEY grant type):

curl https://yourstore.zoeysite.com/api/rest/sales2/orders?limit=5 \
  -H "Accept: application/json" \
  -H "Api-Key: CLIENT_SECRET"

A missing, expired or rejected credential returns 401. A disabled client is refused. See Errors.

Testing with Postman

Connecting to the Zoey API with Postman walks through an Authorization Code setup in Postman step by step.