> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI1ZGU1NTZkMC00ZGFiLTQ1MGUtYTE1NS04MjVhOGQ5MDBjMzgiLCJleHAiOjE3NzgyNTg3NjUsImlhdCI6MTc3ODI1ODQ2NX0._VUlMyE3kgDmweueNdoHma0WTgBMaXlEnl0APLIz51c
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# JWT from Fern API key

GET https://docs.example.com/api/fern-docs/get-jwt

Get a JWT to access protected documentation endpoints, optionally scoped to specific roles.

Reference: https://buildwithfern.com/learn/docs/fern-api-reference/get-jwt

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: mcp-tools
  version: 1.0.0
paths:
  /api/fern-docs/get-jwt:
    get:
      operationId: get-jwt
      summary: JWT from Fern API key
      description: >-
        Get a JWT to access protected documentation endpoints, optionally scoped
        to specific roles.
      tags:
        - ''
      parameters:
        - name: FERN_API_KEY
          in: header
          description: Fern API key, from `fern token`.
          required: true
          schema:
            type: string
        - name: ROLES
          in: header
          description: >-
            Comma-separated list of roles (e.g., "botanist,seedling"). Sets
            roles for returned JWT if provided, otherwise, roles are empty.
          required: false
          schema:
            type: string
        - name: x-fern-host
          in: header
          description: Domain (required on preview URLs)
          required: false
          schema:
            type: string
      responses:
        '200':
          description: Successfully generated JWT
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getJwt_Response_200'
        '400':
          description: Bad request (local preview, self-hosted, or SSO environment)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetJwtRequestBadRequestError'
        '401':
          description: Unauthorized (missing or invalid API key)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetJwtRequestUnauthorizedError'
        '403':
          description: >-
            Forbidden (API key does not belong to this domain's Fern
            organization)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetJwtRequestForbiddenError'
servers:
  - url: https://docs.example.com
components:
  schemas:
    getJwt_Response_200:
      type: object
      properties:
        fern_token:
          type: string
          description: JWT token for authenticating subsequent requests
        roles:
          type: array
          items:
            type: string
          description: Roles included in the JWT
      required:
        - fern_token
        - roles
      title: getJwt_Response_200
    GetJwtRequestBadRequestError:
      type: object
      properties:
        error:
          type: string
      title: GetJwtRequestBadRequestError
    GetJwtRequestUnauthorizedError:
      type: object
      properties:
        error:
          type: string
      title: GetJwtRequestUnauthorizedError
    GetJwtRequestForbiddenError:
      type: object
      properties:
        error:
          type: string
      title: GetJwtRequestForbiddenError
  securitySchemes:
    FernApiKey:
      type: apiKey
      in: header
      name: FERN_API_KEY
      description: Fern API key, from `fern token`.

```