App installation
Flow overview
The diagram below shows every call involved in the installation, including the server-to-server call that Appmax makes to your validation URL during the health check.
INFO
Step 4 combines two actions: you call POST /app/client/generate with the hash and, during that call, Appmax makes a server-to-server POST to your validation URL. The merchant credentials only come back after it responds. See the health check.
Installation flow
Before making any request, obtain the access token using the app credentials.
Endpoint: POST https://auth.appmax.com.br/oauth2/token
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=CLIENT_ID' \
--data-urlencode 'client_secret=CLIENT_SECRET'Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...",
"token_type": "Bearer",
"expires_in": 3600
}With the app access token, generate an authorization hash to redirect the merchant.
Endpoint: POST https://api.appmax.com.br/app/authorize
curl --location 'https://api.appmax.com.br/app/authorize' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
"app_id": "APP_ID",
"external_key": "EXTERNAL_KEY",
"url_callback": "URL_CALLBACK",
"domain_name": "subdomain.yourdomain.com"
}'Response:
{
"data": {
"token": "12083w36219d223f33ecf48f2a7f5ccf143b0bc554"
}
}The token is an opaque single-use hash, valid for 1 hour: pass it through as received, in the redirect and in POST /app/client/generate.
Request parameters:
app_idstringrequiredApp UUID of the application. Use the UUID, not the Numerical ID (see warning below).
external_keystringrequiredKey provided by the partner platform to identify the origin of the installation (e.g., store_id, merchant_id). It comes back in the health check payload.
url_callbackstringrequiredAbsolute URL (with https://) where the merchant is redirected after authorization. Appmax appends the hash as ?token= — see Installation callback.
domain_namestringoptionalThe store's domain (subdomain + domain, e.g. mystore.myintegration.com). To send more than one domain in the same installation, use domain_names (array); domain_name is kept for compatibility.
domain_name is essential if you're going to use Apple Pay
Not required for the installation itself, but it's essential if the store will process Apple Pay payments: it's from this domain, informed here, that Appmax registers the domain with Apple — part of enabling Apple Pay on the customer's device. Without it, the Apple Pay button won't work for that store, even if the rest of the integration is correct. You still need to publish the .well-known file on the domain — see Domain configuration for Apple Pay and Apple Pay payment.
Use the App UUID
In app_id, send the App UUID (e.g. 8f2c1d3e-5a4b-4c7d-9e1f-2a3b4c5d6e7f), not the App Numerical ID (e.g. 699). With the Numerical ID, the response is 422. See App identifiers.
Redirect the user to the authorization URL, replacing HASH with the generated token.
| Environment | Redirect URL |
|---|---|
| Sandbox | https://breakingcode.sandboxappmax.com.br/appstore/integration/HASH |
| Production | https://admin.appmax.com.br/appstore/integration/HASH |
WARNING
The redirect is essential for the merchant to authorize the installation. Without this step, the merchant credentials will not be generated.
The merchant can pick a store that already exists
On this screen the merchant can select an existing store from their account instead of creating a new one. The API contract does not change, but the store bound to the installation may be one that already existed — including one where your app was installed before. See Reusing an existing store on installation.
After the merchant authorizes the installation, use the hash to generate the credentials.
Endpoint: POST https://api.appmax.com.br/app/client/generate
curl --location 'https://api.appmax.com.br/app/client/generate' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--data '{
"token": "12083w36219d223f33ecf48f2a7f5ccf143b0bc554"
}'Response:
{
"data": {
"client": {
"client_id": "MERCHANT_CLIENT_ID",
"client_secret": "MERCHANT_CLIENT_SECRET"
}
}
}WARNING
The hash can only be used once: it is consumed when generate succeeds. The generated credentials are valid indefinitely until the app is uninstalled.
Health check
During this request, Appmax makes a POST to the validation URL registered on the application, with the app_id (Numerical ID) and, when available, the generated credentials and the external_key. Your URL must respond HTTP 200 with a UUID external_id generated by you, unique per installation:
{
"external_id": "37bb0791-ee0b-457d-860c-186e32978bcd",
"alias": "My Store"
}If the URL does not respond or responds with an error, /app/client/generate returns 400 and no credentials are issued; the hash remains valid for another attempt. An invalid external_id raises no error, but breaks the checkout later — see external-id.
The full contract, with Go, Node.js and PHP examples, is in Implement the validation URL. Test the URL before installing at Test the validation URL and see where the external_id is used later in external-id.
With the merchant's client_id and client_secret, call the same POST /oauth2/token as in step 1 — only the credentials change. The returned token authorizes transactional operations (/v1/customers, /v1/orders, /v1/payments/*) and is valid for 1 hour, with no refresh token. Details in Authentication.
WARNING
Sending the app credentials in this step results in 401 on the /v1/* routes.
Troubleshooting
The most common errors during installation and how to fix them.
422 Unprocessable Entity on POST /app/authorize
Most likely cause: you're sending the App Numerical ID instead of the App UUID in the app_id field.
Fix: copy the App UUID from the panel (format 8f2c1d3e-5a4b-...) and send it in that field. The Numerical ID (integer) is never sent by you — it only shows up as the app_id of the payload Appmax posts to your validation URL, in the health check.
Errors on POST /app/client/generate
The error body is always the same, whatever the cause:
{
"errors": {
"message": "An error occurred while integrating the app. Please try again.",
"reason": "Before sending a new email, please re-check your validation URL. ..."
}
}The reason always mentions the validation URL, but the HTTP status is what tells you the cause.
400 — the health check failed
Appmax called your validation URL and:
- the URL did not respond (DNS, firewall, certificate, or wrong URL in the panel);
- the URL responded with an error (
4xx/5xx) or with a body that is not JSON; - the app is in the Payments and Security category and the response had no
external_id.
Fix:
- Check that the validation URL is correct in the app panel.
- Test it manually with
curl— it must respond to POST with HTTP 200 and JSON containing{"external_id": "<valid UUID>"}. - Check your server logs for the POST Appmax sent.
- Make sure you are not using
localhostor a private URL — Appmax must reach the URL publicly.
The hash is not consumed when the health check fails: after fixing the URL, repeat /app/client/generate with the same hash, within 1 hour.
500 — a problem with the hash
- Invalid or already used hash — the hash is consumed when
/app/client/generatecompletes successfully. - The merchant did not finish the authorization — you skipped the redirect in step 3, or the merchant did not confirm the installation in the panel.
- Expired hash — the hash is valid for 1 hour from the authorization.
Fix: generate a new hash with POST /app/authorize and follow the flow in order: authorize → redirect → authorization in the panel → client/generate.
The installation completed, but the checkout responds 404 Merchant not found
Likely cause: the external_id your validation URL returned was empty, not in UUID format, or already existed in another installation. In those cases Appmax returns no error: it discards the value and uses the installation's client_id instead. The UUID you stored in your database does not exist on Appmax's side.
Fix: your validation URL handler must:
- Return HTTP 200 explicitly.
- Include a JSON body with
{"external_id": "<UUID v1-v5>"}. - Generate a unique
external_idper installation (e.g.,uuid.v4()).
After fixing it, reinstall the app on the store to record a valid external_id.
The validation URL is on localhost (development)
Appmax cannot reach private URLs. During development:
- Use a tunnel service like ngrok, beeceptor, or similar.
- Configure the public URL in the app panel.
- When publishing to production, update to the final URL.
App credentials (client_id/client_secret) don't work on /v1/* routes
Cause: app credentials only work on POST /app/authorize and POST /app/client/generate. For transactional routes (/v1/customers, /v1/orders, etc.), use the merchant credentials generated in step 4.
See Authentication to understand both credential types.
Errors using external_id on the front-end (CDN)
The errors on this page cover the generation of the external_id during the health check. If the installation completed successfully but the front-end (tokenization, Apple Pay) is returning 401 Missing Authorization token, 404 Merchant not found, 404 Client id not found, or External ID is required, those are usage errors of the external-id header — the full diagnosis table is at Common errors and diagnosis.
More help
If your error is not listed above:
- Check the FAQ.
- Review Rate Limit if you're getting
429on the order lookup. - Use the
appmax-docsMCP server (diagnose_errortool) passing the status code and the endpoint for an automated diagnosis.