Skip to content

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/token

Headers ​

HeaderRequiredDescription
x-api-keyYesProject API Key generated by the platform
Content-TypeYesMust be application/json

Request body ​

FieldTypeRequiredDescription
project_nostringYesPublic project number, up to 64 characters
user_idstringYesStable 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
  }
}
FieldTypeDescription
codeinteger200 means success
access_tokenstringJWT Access Token
token_typestringAlways Bearer
expires_inintegerToken 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 ​

  1. Cache the Access Token on your server and refresh it before expires_in reaches zero.
  2. Do not exchange a new token before every business request.
  3. Do not build business rules from decoded JWT claims; treat platform responses as authoritative.
  4. Keep the same user_id for the same user within a project.
  5. 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.

最近更新

Qijie Open Platform · API Documentation