Create a new subject token.

POST /api/subject-tokens

Create a new subject token for the use of impersonating the user.

application/json

Body Required

  • userId string Required

    The ID of the user to impersonate.

  • context object

    The additional context to be included in the token, this can be used in custom JWT.

Responses

  • 201 application/json

    The subject token has been created successfully.

    Hide response attributes Show response attributes object
  • Bad Request

  • Unauthorized

  • Forbidden

  • The user does not exist.

POST /api/subject-tokens
curl \
 -X POST https://[tenant_id].logto.app/api/subject-tokens \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"userId":"string","context":{}}'
Request examples
{
  "userId": "string",
  "context": {}
}
Response examples (201)
{
  "subjectToken": "string",
  "expiresIn": 42.0
}