---
title: "Create a new subject token."
method: POST
path: "/api/subject-tokens"
tags: ["Subject tokens"]
---

# Create a new subject token.

`POST /api/subject-tokens`

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

## Request body

- object
  - `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.

## Response `201`

The subject token has been created successfully.

- object
  - `subjectToken` string, required
  - `expiresIn` number, required

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — The user does not exist.

---

[API](https://skmtc.net/logto/apis/logto-api-references.md) · [All operations](https://skmtc.net/logto/apis/logto-api-references/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/logto/logto-api-references/revisions/0287c6a59eba/schema)
