HumaboamHumaboam

For agents — get this content

Use the command below to fetch this page as raw markdown.

curl -s "/api/doc/raw/token-management-user-jwt"

Token management (user JWT)

All endpoints in this section require a user JWT. Agent tokens cannot be used here.

Base path: /api/agent-tokens


GET /api/agent-tokens/me

Check whether the current user has an active agent token. Returns the token prefix only; the full token is never returned.

Request

WhereNameTypeRequiredDescription
HeaderAuthorizationstringYesBearer <user JWT>

Response (200)

FieldTypeDescription
has_tokenbooleanWhether the user has an agent token.
token_prefixstring | nullIf has_token is true, first visible part (e.g. sk_agt_1a2b3c4d...). Null when no token.

Example

{ "has_token": true, "token_prefix": "sk_agt_1a2b3c4d..." }
curl -X GET "https://api.jobhuntr.com/api/agent-tokens/me" \
  -H "Authorization: Bearer <user_jwt>"

Error responses

StatusCause
401Missing or invalid JWT.
500Failed to fetch token status.

POST /api/agent-tokens/me

Generate or rotate the agent API token. If a token already exists, it is replaced. The raw token is returned once; store it securely.

Request

WhereNameTypeRequiredDescription
HeaderAuthorizationstringYesBearer <user JWT>

No body.

Response (200)

FieldTypeDescription
tokenstringFull agent token (e.g. sk_agt_<64 hex>). Shown only on this response.
token_prefixstringPrefix for display (e.g. sk_agt_1a2b3c4d...).
messagestringHuman-readable message (e.g. "Store this token securely — it will not be shown again.").

Example

{
  "token": "sk_agt_a1b2c3d4e5f6...",
  "token_prefix": "sk_agt_a1b2c3d4...",
  "message": "Store this token securely — it will not be shown again."
}
curl -X POST "https://api.jobhuntr.com/api/agent-tokens/me" \
  -H "Authorization: Bearer <user_jwt>"

Error responses

StatusCause
401Missing or invalid JWT.
500Failed to store agent token.

POST /api/agent-tokens/me/get-or-create

Return the existing agent token prefix, or create a new token if none exists. Idempotent for "obtain token in one call" flows.

Request

WhereNameTypeRequiredDescription
HeaderAuthorizationstringYesBearer <user JWT>

No body.

Response (200)

FieldTypeDescription
is_newbooleantrue if a new token was created; false if one already existed.
tokenstring | nullFull agent token only when is_new is true. Otherwise null.
token_prefixstringDisplay prefix in all cases.
messagestringHuman-readable message.

Example (new token)

{
  "is_new": true,
  "token": "sk_agt_...",
  "token_prefix": "sk_agt_1a2b3c4d...",
  "message": "Token created. Store it securely — it will not be shown again."
}

Example (existing token)

{
  "is_new": false,
  "token": null,
  "token_prefix": "sk_agt_1a2b3c4d...",
  "message": "Token already exists. Rotate it from Settings if you need a new one."
}
curl -X POST "https://api.jobhuntr.com/api/agent-tokens/me/get-or-create" \
  -H "Authorization: Bearer <user_jwt>"

Error responses

StatusCause
401Missing or invalid JWT.
500Failed to check or store token.

DELETE /api/agent-tokens/me

Revoke the current user's agent token. All agents using it lose access immediately.

Request

WhereNameTypeRequiredDescription
HeaderAuthorizationstringYesBearer <user JWT>

Response

StatusBody
204No body.
curl -X DELETE "https://api.jobhuntr.com/api/agent-tokens/me" \
  -H "Authorization: Bearer <user_jwt>"

Error responses

StatusCause
401Missing or invalid JWT.
500Failed to revoke token.