Authentication
The platform uses two-stage authentication: an API Key exchanges an Access Token, and the Access Token authorizes business API calls.
Get an Access Token
POST
/v1/auth/tokenHeaders
| Header | Required | Description |
|---|---|---|
x-api-key | Yes | Project API Key generated by the platform |
Content-Type | Yes | Must be application/json |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
project_no | string | Yes | Public project number, up to 64 characters |
user_id | string | Yes | Stable user identifier from your system, up to 256 characters |
json
{
"project_no": "prj_your_project_no",
"user_id": "your_user_001"
}Response
json
{
"code": 200,
"message": "success",
"data": {
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 86400
}
}| Field | Type | Description |
|---|---|---|
code | integer | 200 means success |
access_token | string | JWT Access Token |
token_type | string | Always Bearer |
expires_in | integer | Token lifetime in seconds (measured: 86400) |
Send the Access Token
All Pet AI requests use standard Bearer authentication; the open-platform gateway validates Authorization and injects the user-context header x-qj-user:
http
Authorization: Bearer <ACCESS_TOKEN>bash
curl 'https://open-api.habitaxx.com/v1/ms-ai-fast/locales' \
--header "Authorization: Bearer ${ACCESS_TOKEN}"Recommendations
- Cache the Access Token on your server and refresh it before
expires_inreaches zero. - Do not exchange a new token before every business request.
- Do not build business rules from decoded JWT claims; treat platform responses as authoritative.
- Keep the same
user_idfor the same user within a project. - Disable and rotate an API Key immediately if it is exposed.
Credential safety
qj_live_your_api_key, prj_your_project_no, and eyJ... in this documentation are placeholders. Never commit a real API Key or Access Token.