palbaseDocs

Palbase Auth API · API

POST/auth/devices/attest/android

Enrol an Android device with Key Attestation

Verifies an Android Keystore key's attestation and stores the key as a verified device, so the device can sign its requests to a backend route that requires attestation. The app generates an EC P-256 signing key in the Android Keystore with the challenge from POST /auth/devices/challenge as its attestation challenge and sends the key's certificate chain. The chain must end in one of Google's hardware attestation roots with no certificate on Google's revocation list; the key must be in the TEE or StrongBox and generated there; the device must be locked with a verified boot; and the attesting app's package and signing certificate must be those of an Android app registered with this environment. No session is required: with a valid user token the device is enrolled under that user, otherwise under the installation anchor in X-Palbase-Installation-Anchor (the anchor the challenge was issued for). A caller with neither is refused with 401. The challenge is spent by this call. 400: the request cannot be evaluated (missing_fields, invalid_certificate_chain, invalid_challenge — not issued for this anchor or already spent, invalid_installation_anchor). 403: the chain was evaluated and refused, the reason being the code (untrusted_root, software_key — an emulator or a software keystore, device_not_locked, unverified_boot, package_mismatch, signature_mismatch, certificate_revoked, certificate_expired, challenge_mismatch, key_not_generated, invalid_key). 409 android_app_not_configured: no Android app is registered with this environment. 503: the challenge store (challenge_unavailable) or Google's revocation list (revocation_list_unavailable) cannot be reached; retry after Retry-After. Rate limited per IP address.

Called by your app, with the publishable key.

Headers

X-Palbase-Installation-Anchorstring · optionalThe installation anchor (`ins_…`) this device enrols under when the caller is not signed in: exactly the `installation_anchor` this server issued (`ins_` and a UUID). Anything else answers 400 `invalid_installation_anchor`. Ignored when a valid session is present.

Request body

certificate_chainstring (byte)[] · requiredThe key's attestation certificate chain from `KeyStore.getCertificateChain`, leaf first, each certificate DER in base64.
challengestring (byte) · requiredThe challenge from `POST /auth/devices/challenge`, base64, exactly as received.
device_namestring · optional
curl
curl -X POST "https://<your-ref>.palbase.studio/auth/devices/attest/android" \
  -H "apikey: $PALBASE_PUBLISHABLE_KEY" \
  -H "content-type: application/json" \
  -d '{"certificate_chain":["string"],"challenge":"string"}'

Responses

200Device enrolled and verified

400Validation failed or required field missing

401Missing, invalid, or expired credentials

403Authenticated but not permitted (banned, hook denial, role mismatch)

409Conflict with current resource state (duplicate, race)

429Rate limit exceeded

503Downstream dependency unavailable (typically HIBP / breach service)

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation AttestAndroidDevice of auth's contract.