Skip to content

Authentication and authorization ​

Which credentials should I use? ​

I need to install the app on a store → use APP credentials (from the developer dashboard). Endpoints: /app/authorize, /app/client/generate.

I need to create a customer, order or payment → use MERCHANT credentials (returned at the end of the installation). Endpoints: /v1/customers, /v1/orders, /v1/payments/*.

I'm not sure → do you have a merchant who installed your app? If yes, use merchant credentials. If not, follow the installation flow first to obtain them.

Understanding the credentials ​

The Appmax API uses two pairs of credentials (client_id and client_secret). Both have the same format but serve completely different purposes. Confusing the two is the most common cause of integration errors.

AspectApp credentialsMerchant credentials
Obtained fromDeveloper dashboard, when creating the applicationResponse of /app/client/generate, at the end of the installation
How many exist1 pair per app1 pair per merchant that installed the app
Used forInstallation flow (/app/authorize, /app/client/generate)Transactional operations: customers, orders, payments, refunds
ExpireNo, as long as the app existsNo (see below for when they change)
Generated token is valid for1 hour1 hour

DANGER

App credentials do not allow creating customers, orders, or payments. If you receive a 401 on the transactional API, you are likely using the wrong credentials.

WARNING

Both use the same endpoint (https://auth.appmax.com.br/oauth2/token) with the same request format. Only the client_id/client_secret you send changes, and with it the token's permissions. Keep each merchant's pair associated with that merchant, in a secure location.

Both phases (installation with the app credentials, operation with the merchant credentials) appear in the diagram in App installation.

Common credential errors ​

ErrorLikely causeSolution
401 when creating customer/orderUsing app credentials instead of merchant credentialsUse the credentials returned by /app/client/generate
401 when calling /app/authorizeUsing merchant credentials instead of app credentialsUse the credentials from the developer dashboard
500 when calling /app/client/generateIncomplete installation flow (missing redirect)Follow all 4 steps of the installation flow in order
401 expired tokenJWT token older than 1 hourGenerate a new token with the same credentials
403 on /oauth2/tokenWrong endpoint (using the API URL instead of auth)Use https://auth.appmax.com.br/oauth2/token

Why don't we use refresh tokens? ​

The API adopts an authentication model without refresh tokens. This decision is based on the server-to-server communication architecture.

Detailed reasons
  1. Server-to-server nature: communication occurs directly between servers in controlled, secure environments. This reduces the need for additional token renewal mechanisms.

  2. Security and simplicity: short-lived tokens (1 hour) limit the usage window. In server-to-server environments where credentials are stored securely, this approach simplifies management.

  3. Reduced complexity: eliminates secure refresh token storage, token rotation, and renewal logic.

  4. Compliance with best practices: in server-to-server integrations, it is common to use short-lived access tokens with key-based authentication.

Obtaining the token ​

The token is valid for 1 hour. When it expires, repeat the same request.

Example with merchant credentials ​

bash
curl --location 'https://auth.appmax.com.br/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=MERCHANT_CLIENT_ID' \
--data-urlencode 'client_secret=MERCHANT_CLIENT_SECRET'
json
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...",
  "token_type": "Bearer",
  "expires_in": 3600
}

Example with app credentials ​

bash
curl --location 'https://auth.appmax.com.br/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=APP_CLIENT_ID' \
--data-urlencode 'client_secret=APP_CLIENT_SECRET'

WARNING

Merchant credentials do not expire. They change in three situations: a reinstall of the app, which issues a new pair; uninstalling, which deactivates them; and the panel's API screen, which lets you generate a new client_secret or revoke the pair.