Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.
The user-token endpoint lets your backend issue a short-lived JWT on behalf of a provisioned end-user. These tokens carry the user’s identity as their sub and are scoped to a specific capability (e.g. sign:job). Downstream PymtHouse services validate this token before processing any user request.
When to mint user tokens
Mint a user-scoped JWT when:
Your backend needs to authorize an end-user for a PymtHouse service on their behalf.
You are completing a device flow (RFC 8628) and need a subject_token for the RFC 8693 exchange.
You want to pass a short-lived, user-attributable credential to your frontend or CLI rather than a long-lived secret.
Prerequisites
The user must already be provisioned in PymtHouse. See User management.
Your M2M client (m2m_…) must have users:token scope.
The requested scope must be listed in the public client’s allowed_scopes — not the M2M client’s. For example, to request sign:job, the public app_… client must have sign:job in its allowed_scopes.
export BASE_URL="https://pymthouse.com"export CLIENT_ID="app_yourClientId" # public client idexport M2M_ID="m2m_yourClientId"export M2M_SECRET="pmth_cs_yourSecret"
Endpoint
POST /api/v1/apps/{clientId}/users/{externalUserId}/tokenAuthorization: Basic base64(m2m_id:m2m_secret)Content-Type: application/json
{clientId} is the publicapp_… client id. {externalUserId} is your system’s user identifier as stored during provisioning.
Request body
{ "scope": "sign:job" }
Field
Type
Required
Description
scope
string
No
Space-separated list of scopes to include in the issued JWT. Defaults to sign:job if omitted. Must be a subset of the public client’s allowed_scopes.
admin is explicitly rejected regardless of scope configuration. User tokens can never escalate to administrative privilege.
sub is the PymtHouse internal app-user id, not your externalUserId. If you need to correlate the JWT back to your user, use the client_id/azp + your own session context rather than parsing sub.
Passing the token to downstream services
Pass the JWT in a standard Authorization: Bearer header to any PymtHouse service that validates it:
The receiving service verifies the JWT signature against {issuer}/jwks, checks exp, and validates scope includes the required capability before processing.
Scope validation flow
The requested scope is validated against the public client’s allowed_scopes, not the M2M client’s. This means the M2M client cannot grant a user more capability than the public client’s registration allows, regardless of what scopes the M2M client itself holds.
Token lifetime and refresh
User-scoped JWTs are intentionally short-lived (seconds to minutes). There is no refresh token for programmatic user JWTs — your backend simply mints a new one when needed. This design:
Limits the blast radius of a leaked user token.
Keeps revocation implicit (expiry) rather than requiring an explicit revocation endpoint.
Ensures the scope remains correct even if the public client’s allowed_scopes changes.
Device flow integration
When completing an RFC 8628 device grant via RFC 8693 token exchange, the user JWT you mint here becomes the subject_token:
Requested scope includes admin, or scope is not a subset of the public client’s allowed_scopes.
401 Unauthorized
Invalid M2M credentials or expired Bearer token.
403 Forbidden
M2M client lacks users:token.
404 Not Found
clientId path does not match the M2M client’s app, or externalUserId has not been provisioned.
Key design decisions
Scope validation against the public client, not the M2M client. The public app_… client represents the app’s registration contract with the platform — what capabilities it is permitted to grant users. The M2M client is an operational credential. Validating the requested scope against the public client ensures users cannot receive capabilities that exceed the app’s registration, even if the M2M client holds broader scopes.
No admin scope in user tokens. The user-token path is explicitly designed for end-user contexts. Administrative privilege cannot be embedded in a token that is intended to be passed to the user session or a client SDK. This is enforced at the route level, not as a policy check.
sub is the app-user row id. Using the PymtHouse internal app_users.id as sub makes the token’s subject stable under email or externalUserId changes, and avoids leaking the integrator’s internal user identifier in a standard JWT claim that may be logged or decoded by third-party services.
Short lifetime, no refresh. User JWTs are issued on demand by a backend that already holds the M2M credential. Making them short-lived with no refresh means the blast radius of a leaked token is bounded to its TTL. Re-minting is a single backend API call rather than a stateful refresh flow.
Implementation tasks
Provision the user with the Builder API before calling this endpoint. A 404 on the user-token path most commonly means the externalUserId was never provisioned, not that the credentials are wrong.
Verify the requested scope is listed in the public client’s allowed_scopes before calling — you will get a 400 otherwise, and surfacing that at call time makes debugging easier.
Do not store user JWTs beyond the scope of a single request chain. Mint fresh tokens for each user session or device flow.
In your JWT verification logic for downstream services, check client_id or azp against the known public app_… client id to confirm the token was issued for your app before trusting the scope claim.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"PymtHouse","colors":{"primary":"#16A34A","light":"#07C983","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/elitecodesolutions/AkUSp5f5h68RxGdy/logo/light.svg?fit=max\u0026auto=format\u0026n=AkUSp5f5h68RxGdy\u0026q=85\u0026s=100343a4103de541688743f00b166337","dark":"https://mintcdn.com/elitecodesolutions/AkUSp5f5h68RxGdy/logo/dark.svg?fit=max\u0026auto=format\u0026n=AkUSp5f5h68RxGdy\u0026q=85\u0026s=8ce9b3cb4ad5a512418e813a1b40688f"},"favicon":"https://mintcdn.com/elitecodesolutions/AkUSp5f5h68RxGdy/favicon.svg?fit=max\u0026auto=format\u0026n=AkUSp5f5h68RxGdy\u0026q=85\u0026s=44acdc771df5ccc001980cb959e86073","contextual":{"options":["copy","view","chatgpt","claude","cursor","vscode"],"display":"header"},"styling":{"latex":true},"navigation":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/eliteprox/pymthouse"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"elitecodesolutions","hasAudioNarration":false,"actualSubdomain":"elitecodesolutions","customDomains":["docs.pymthouse.com"],"gitSource":{"type":"github","owner":"pymthouse","repo":"pymthouse-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6ae95584bb9827c4f4fc677d:success","clientVersion":"0.0.4143","searchFilterCounts":[{"language":"default","tag":"Builder guides","count":21},{"language":"default","tag":"Billing","count":4},{"language":"default","tag":"Authentication","count":4},{"language":"default","tag":"Getting started","count":3},{"language":"default","tag":"Users","count":3},{"language":"default","tag":"Core concepts","count":3},{"language":"default","tag":"Help","count":2},{"language":"default","tag":"Infrastructure","count":2},{"language":"default","tag":"API reference","count":1},{"language":"default","tag":"Overview","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"integration/user-tokens","slug":"/integration/user-tokens","pageMetadata":{"title":"User-scoped JWTs","description":"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.","href":"/integration/user-tokens"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Mermaid,Note,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Mermaid)_missingMdxReference(`Mermaid`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`The user-token endpoint lets your backend issue a short-lived JWT on behalf of a provisioned end-user. These tokens carry the user’s identity as their `,_jsx(_components.code,{children:`sub`}),` and are scoped to a specific capability (e.g. `,_jsx(_components.code,{children:`sign:job`}),`). Downstream PymtHouse services validate this token before processing any user request.`]}),`\n`,_jsx(Heading,{level:`2`,id:`when-to-mint-user-tokens`,children:`When to mint user tokens`}),`\n`,_jsx(_components.p,{children:`Mint a user-scoped JWT when:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Your backend needs to authorize an end-user for a PymtHouse service on their behalf.`}),`\n`,_jsxs(_components.li,{children:[`You are completing a device flow (RFC 8628) and need a `,_jsx(_components.code,{children:`subject_token`}),` for the RFC 8693 exchange.`]}),`\n`,_jsx(_components.li,{children:`You want to pass a short-lived, user-attributable credential to your frontend or CLI rather than a long-lived secret.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`The user must already be provisioned in PymtHouse. See `,_jsx(_components.a,{href:`/integration/user-management`,children:`User management`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Your M2M client (`,_jsx(_components.code,{children:`m2m_…`}),`) must have `,_jsx(_components.code,{children:`users:token`}),` scope.`]}),`\n`,_jsxs(_components.li,{children:[`The requested scope must be listed in the `,_jsx(_components.strong,{children:`public`}),` client’s `,_jsx(_components.code,{children:`allowed_scopes`}),` — not the M2M client’s. For example, to request `,_jsx(_components.code,{children:`sign:job`}),`, the public `,_jsx(_components.code,{children:`app_…`}),` client must have `,_jsx(_components.code,{children:`sign:job`}),` in its `,_jsx(_components.code,{children:`allowed_scopes`}),`.`]}),`\n`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` BASE_URL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://pymthouse.com\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` CLIENT_ID`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"app_yourClientId\"`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # public client id`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` M2M_ID`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"m2m_yourClientId\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` M2M_SECRET`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"pmth_cs_yourSecret\"`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`endpoint`,children:`Endpoint`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/apps/{clientId}/users/{externalUserId}/token`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Authorization`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Basic base64(m2m_id:m2m_secret)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Content-Type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` application/json`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`{clientId}`}),` is the `,_jsx(_components.strong,{children:`public`}),` `,_jsx(_components.code,{children:`app_…`}),` client id. `,_jsx(_components.code,{children:`{externalUserId}`}),` is your system’s user identifier as stored during provisioning.`]}),`\n`,_jsx(Heading,{level:`2`,id:`request-body`,children:`Request body`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{ `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"scope\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"sign:job\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`]})})}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Field`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Required`}),_jsx(_components.th,{children:`Description`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`scope`})}),_jsx(_components.td,{children:`string`}),_jsx(_components.td,{children:`No`}),_jsxs(_components.td,{children:[`Space-separated list of scopes to include in the issued JWT. Defaults to `,_jsx(_components.code,{children:`sign:job`}),` if omitted. Must be a subset of the public client’s `,_jsx(_components.code,{children:`allowed_scopes`}),`.`]})]})})]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`admin`}),` is explicitly rejected regardless of scope configuration. User tokens can never escalate to administrative privilege.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`example`,children:`Example`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`USER_JWT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -sS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`M2M_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"}:${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`M2M_SECRET`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{ \"scope\": \"sign:job\" }'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BASE_URL`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"}/api/v1/apps/${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`CLIENT_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}/users/user-123/token\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '.access_token'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`echo`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"User JWT: ${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`USER_JWT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`0`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`60`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}...\"`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Response:`})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"access_token\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"token_type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Bearer\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"expires_in\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`300`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`jwt-claims`,children:`JWT claims`}),`\n`,_jsx(_components.p,{children:`The issued JWT contains:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Claim`}),_jsx(_components.th,{children:`Value`}),_jsx(_components.th,{children:`Notes`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`iss`})}),_jsx(_components.td,{children:`PymtHouse issuer URL`}),_jsx(_components.td,{children:`Verify against discovery.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`sub`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`app_users.id`}),` (PymtHouse app-user row id)`]}),_jsxs(_components.td,{children:[`Not the same as `,_jsx(_components.code,{children:`externalUserId`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`client_id`}),` / `,_jsx(_components.code,{children:`azp`})]}),_jsxs(_components.td,{children:[`Public `,_jsx(_components.code,{children:`app_…`}),` client id`]}),_jsx(_components.td,{children:`Used for tenant matching in RFC 8693 exchanges.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`scope`})}),_jsx(_components.td,{children:`Granted scopes`}),_jsxs(_components.td,{children:[`Subset of the public client’s `,_jsx(_components.code,{children:`allowed_scopes`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`exp`})}),_jsx(_components.td,{children:`Expiry timestamp`}),_jsx(_components.td,{children:`Tokens are short-lived by design.`})]})]})]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`sub`}),` is the PymtHouse internal app-user id, `,_jsx(_components.strong,{children:`not`}),` your `,_jsx(_components.code,{children:`externalUserId`}),`. If you need to correlate the JWT back to your user, use the `,_jsx(_components.code,{children:`client_id`}),`/`,_jsx(_components.code,{children:`azp`}),` + your own session context rather than parsing `,_jsx(_components.code,{children:`sub`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`passing-the-token-to-downstream-services`,children:`Passing the token to downstream services`}),`\n`,_jsxs(_components.p,{children:[`Pass the JWT in a standard `,_jsx(_components.code,{children:`Authorization: Bearer`}),` header to any PymtHouse service that validates it:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -sS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"Authorization: Bearer ${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`USER_JWT`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://your-signer.example/sign\"`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The receiving service verifies the JWT signature against `,_jsx(_components.code,{children:`{issuer}/jwks`}),`, checks `,_jsx(_components.code,{children:`exp`}),`, and validates `,_jsx(_components.code,{children:`scope`}),` includes the required capability before processing.`]}),`\n`,_jsx(Heading,{level:`2`,id:`scope-validation-flow`,children:`Scope validation flow`}),`\n`,_jsx(Mermaid,{chart:`flowchart LR\n A[M2M client calls /users/id/token] --> B{M2M has users:token?}\n B -- No --> C[403 Forbidden]\n B -- Yes --> D{Requested scope ⊆ public client allowed_scopes?}\n D -- No --> E[400 invalid_scope]\n D -- Yes --> F[Issue JWT with requested scope]`}),`\n`,_jsxs(_components.p,{children:[`The requested scope is validated against the `,_jsx(_components.strong,{children:`public`}),` client’s `,_jsx(_components.code,{children:`allowed_scopes`}),`, not the M2M client’s. This means the M2M client cannot grant a user more capability than the public client’s registration allows, regardless of what scopes the M2M client itself holds.`]}),`\n`,_jsx(Heading,{level:`2`,id:`token-lifetime-and-refresh`,children:`Token lifetime and refresh`}),`\n`,_jsx(_components.p,{children:`User-scoped JWTs are intentionally short-lived (seconds to minutes). There is no refresh token for programmatic user JWTs — your backend simply mints a new one when needed. This design:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Limits the blast radius of a leaked user token.`}),`\n`,_jsx(_components.li,{children:`Keeps revocation implicit (expiry) rather than requiring an explicit revocation endpoint.`}),`\n`,_jsxs(_components.li,{children:[`Ensures the scope remains correct even if the public client’s `,_jsx(_components.code,{children:`allowed_scopes`}),` changes.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`device-flow-integration`,children:`Device flow integration`}),`\n`,_jsxs(_components.p,{children:[`When completing an RFC 8628 device grant via RFC 8693 token exchange, the user JWT you mint here becomes the `,_jsx(_components.code,{children:`subject_token`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`17`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# 1. Mint user JWT`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`USER_JWT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -sS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`M2M_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"}:${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`M2M_SECRET`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{ \"scope\": \"sign:job\" }'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BASE_URL`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"}/api/v1/apps/${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`CLIENT_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}/users/user-123/token\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '.access_token'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# 2. Bind device grant`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -sS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -u`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`M2M_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"}:${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`M2M_SECRET`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/x-www-form-urlencoded\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"grant_type=urn:ietf:params:oauth:grant-type:token-exchange\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"subject_token=${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`USER_JWT`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"subject_token_type=urn:ietf:params:oauth:token-type:access_token\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"resource=urn:pmth:device_code:ABCD-EFGH\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BASE_URL`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}/api/v1/oidc/token\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`For the full end-to-end flow, see `,_jsx(_components.a,{href:`/integration/token-exchange#device-completion`,children:`Token exchange — device completion`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`error-responses`,children:`Error responses`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Status`}),_jsx(_components.th,{children:`Condition`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`400 Bad Request`})}),_jsxs(_components.td,{children:[`Requested scope includes `,_jsx(_components.code,{children:`admin`}),`, or scope is not a subset of the public client’s `,_jsx(_components.code,{children:`allowed_scopes`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`401 Unauthorized`})}),_jsx(_components.td,{children:`Invalid M2M credentials or expired Bearer token.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`403 Forbidden`})}),_jsxs(_components.td,{children:[`M2M client lacks `,_jsx(_components.code,{children:`users:token`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`404 Not Found`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`clientId`}),` path does not match the M2M client’s app, or `,_jsx(_components.code,{children:`externalUserId`}),` has not been provisioned.`]})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`key-design-decisions`,children:`Key design decisions`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Scope validation against the public client, not the M2M client.`}),` The public `,_jsx(_components.code,{children:`app_…`}),` client represents the app’s registration contract with the platform — what capabilities it is permitted to grant users. The M2M client is an operational credential. Validating the requested scope against the public client ensures users cannot receive capabilities that exceed the app’s registration, even if the M2M client holds broader scopes.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[`No `,_jsx(_components.code,{children:`admin`}),` scope in user tokens.`]}),` The user-token path is explicitly designed for end-user contexts. Administrative privilege cannot be embedded in a token that is intended to be passed to the user session or a client SDK. This is enforced at the route level, not as a policy check.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`sub`}),` is the app-user row id.`]}),` Using the PymtHouse internal `,_jsx(_components.code,{children:`app_users.id`}),` as `,_jsx(_components.code,{children:`sub`}),` makes the token’s subject stable under email or `,_jsx(_components.code,{children:`externalUserId`}),` changes, and avoids leaking the integrator’s internal user identifier in a standard JWT claim that may be logged or decoded by third-party services.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Short lifetime, no refresh.`}),` User JWTs are issued on demand by a backend that already holds the M2M credential. Making them short-lived with no refresh means the blast radius of a leaked token is bounded to its TTL. Re-minting is a single backend API call rather than a stateful refresh flow.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`implementation-tasks`,children:`Implementation tasks`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Provision the user with the Builder API before calling this endpoint. A `,_jsx(_components.code,{children:`404`}),` on the user-token path most commonly means the `,_jsx(_components.code,{children:`externalUserId`}),` was never provisioned, not that the credentials are wrong.`]}),`\n`,_jsxs(_components.li,{children:[`Verify the requested scope is listed in the public client’s `,_jsx(_components.code,{children:`allowed_scopes`}),` before calling — you will get a `,_jsx(_components.code,{children:`400`}),` otherwise, and surfacing that at call time makes debugging easier.`]}),`\n`,_jsx(_components.li,{children:`Do not store user JWTs beyond the scope of a single request chain. Mint fresh tokens for each user session or device flow.`}),`\n`,_jsxs(_components.li,{children:[`In your JWT verification logic for downstream services, check `,_jsx(_components.code,{children:`client_id`}),` or `,_jsx(_components.code,{children:`azp`}),` against the known public `,_jsx(_components.code,{children:`app_…`}),` client id to confirm the token was issued for your app before trusting the `,_jsx(_components.code,{children:`scope`}),` claim.`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"User-scoped JWTs","description":"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.","href":"/integration/user-tokens"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"When to mint user tokens","slug":"when-to-mint-user-tokens","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Endpoint","slug":"endpoint","depth":2,"children":[]},{"title":"Request body","slug":"request-body","depth":2,"children":[]},{"title":"Example","slug":"example","depth":2,"children":[]},{"title":"JWT claims","slug":"jwt-claims","depth":2,"children":[]},{"title":"Passing the token to downstream services","slug":"passing-the-token-to-downstream-services","depth":2,"children":[]},{"title":"Scope validation flow","slug":"scope-validation-flow","depth":2,"children":[]},{"title":"Token lifetime and refresh","slug":"token-lifetime-and-refresh","depth":2,"children":[]},{"title":"Device flow integration","slug":"device-flow-integration","depth":2,"children":[]},{"title":"Error responses","slug":"error-responses","depth":2,"children":[]},{"title":"Key design decisions","slug":"key-design-decisions","depth":2,"children":[]},{"title":"Implementation tasks","slug":"implementation-tasks","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"elitecodesolutions","siteName":"PymtHouse","title":"User-scoped JWTs - PymtHouse","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-08-13T01:58:06.384Z","originalFileLocation":"integration/user-tokens.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.\">\u003cmeta data-mint-head name=\"application-name\" content=\"PymtHouse\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"User-scoped JWTs - PymtHouse\">\u003cmeta data-mint-head property=\"og:description\" content=\"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"PymtHouse\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.pymthouse.com/integration/user-tokens\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://elitecodesolutions.mintlify.site/_mintlify/api/og/v2?division=Users\u0026amp;title=User-scoped+JWTs\u0026amp;description=Mint+short-lived+access+tokens+scoped+to+a+specific+end-user+and+capability+via+the+Builder+API.\u0026amp;theme=564edb3c141d7a1d3a685d7b\u0026amp;signature=f93f9ac6006240d5fffc307d4975aca9d08354caf7844d97e6a1951f0c46d554\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"User-scoped JWTs - PymtHouse\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://elitecodesolutions.mintlify.site/_mintlify/api/og/v2?division=Users\u0026amp;title=User-scoped+JWTs\u0026amp;description=Mint+short-lived+access+tokens+scoped+to+a+specific+end-user+and+capability+via+the+Builder+API.\u0026amp;theme=564edb3c141d7a1d3a685d7b\u0026amp;signature=f93f9ac6006240d5fffc307d4975aca9d08354caf7844d97e6a1951f0c46d554\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/elitecodesolutions/DStq26iN35-qfk-b/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"PymtHouse\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#16A34A\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.pymthouse.com/integration/user-tokens\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/integration/user-tokens.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.pymthouse.com/#organization\",\"name\":\"PymtHouse\",\"url\":\"https://docs.pymthouse.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/elitecodesolutions/AkUSp5f5h68RxGdy/logo/light.svg?fit=max\u0026auto=format\u0026n=AkUSp5f5h68RxGdy\u0026q=85\u0026s=100343a4103de541688743f00b166337\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.pymthouse.com#website\",\"name\":\"PymtHouse\",\"url\":\"https://docs.pymthouse.com\",\"publisher\":{\"@id\":\"https://docs.pymthouse.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.pymthouse.com/integration/user-tokens#webpage\",\"url\":\"https://docs.pymthouse.com/integration/user-tokens\",\"name\":\"User-scoped JWTs\",\"description\":\"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.\",\"dateModified\":\"2026-08-13T01:58:06.384Z\",\"isPartOf\":{\"@id\":\"https://docs.pymthouse.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.pymthouse.com/integration/user-tokens#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.pymthouse.com/integration/user-tokens#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Users\",\"item\":\"https://docs.pymthouse.com/integration/user-management\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"User-scoped JWTs\",\"item\":\"https://docs.pymthouse.com/integration/user-tokens\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.pymthouse.com/integration/user-tokens#article\",\"headline\":\"User-scoped JWTs\",\"name\":\"User-scoped JWTs\",\"description\":\"Mint short-lived access tokens scoped to a specific end-user and capability via the Builder API.\",\"url\":\"https://docs.pymthouse.com/integration/user-tokens\",\"mainEntityOfPage\":{\"@id\":\"https://docs.pymthouse.com/integration/user-tokens#webpage\"},\"dateModified\":\"2026-08-13T01:58:06.384Z\",\"publisher\":{\"@id\":\"https://docs.pymthouse.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.pymthouse.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"PymtHouse\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"PymtHouse\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/integration/user-tokens.md","siteName":"PymtHouse","nav":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/eliteprox/pymthouse"}]},"tabs":[{"tab":"Builder guides","groups":[{"group":"Getting started","pages":[{"title":"PymtHouse Docs","href":""},{"title":"Quickstart","href":"/quickstart"},{"title":"Integration patterns","href":"/integration/integration-patterns"}]},{"group":"Core concepts","pages":[{"title":"Client model","href":"/integration/client-model"},{"title":"API keys","href":"/integration/api-keys"},{"title":"Builder SDK","href":"/integration/sdk"}]},{"group":"Authentication","pages":[{"title":"Machine access","href":"/integration/machine-access"},{"title":"Interactive login","href":"/integration/interactive-login"},{"title":"Device flow","href":"/integration/device-flow"},{"title":"Token exchange","href":"/integration/token-exchange"}]},{"group":"Users","pages":[{"title":"User management","description":"Create, upsert, update, and deactivate users in your PymtHouse app tenant via the Builder API. Manage per-user API keys, allowances, and subscription state.","href":"/integration/user-management"},{"title":"User-scoped JWTs","href":"/integration/user-tokens"},{"title":"Allowances","description":"Manage per-user USD micro entitlement balances. Read allowance detail, grant manual top-ups, and check real-time access via the OpenMeter-backed allowances and balance APIs.","href":"/integration/allowances"}]},{"group":"Billing","pages":[{"title":"Billing summary","href":"/integration/billing"},{"title":"Plans","href":"/integration/plans"},{"title":"Usage API","href":"/integration/usage-api"},{"title":"Builder M2M Payments API","href":"/integration/payments"}]},{"group":"Infrastructure","pages":[{"title":"Signer routing","href":"/integration/signer-routing"},{"title":"App manifest","href":"/integration/manifest"}]},{"group":"Help","pages":[{"title":"Troubleshooting","href":"/integration/troubleshooting"},{"title":"Deprecated routes and migrations","href":"/integration/deprecated"}]}]},{"tab":"API reference","pages":[{"title":"API reference","href":"/api-reference/introduction"}]}]},"basePath":"","title":"User-scoped JWTs - PymtHouse","buildId":"dpl_Fyv1NbzwP68g2bEH2Roy98uY1zmE","deploymentId":"dpl_Fyv1NbzwP68g2bEH2Roy98uY1zmE","dynamics":[],"chunks":[]}