> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withampersand.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a new JWT key

> Creates a new JWT key for the specified project with RSA public key for token verification



## OpenAPI

````yaml platform post /projects/{projectIdOrName}/jwt-keys
openapi: 3.0.1
info:
  title: Ampersand public API
  version: 1.0.0
servers:
  - url: https://api.withampersand.com/v1
security:
  - APIKeyHeader: []
  - Bearer: []
paths:
  /projects/{projectIdOrName}/jwt-keys:
    post:
      tags:
        - JWT Key
      summary: Create a new JWT key
      description: >-
        Creates a new JWT key for the specified project with RSA public key for
        token verification
      operationId: createJWTKey
      parameters:
        - name: projectIdOrName
          in: path
          required: true
          schema:
            type: string
          description: Ampersand Project ID or name.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - label
                - algorithm
                - publicKeyPem
              properties:
                label:
                  type: string
                  description: Human-readable label for the JWT key
                  minLength: 1
                  maxLength: 255
                  example: production-key-1
                algorithm:
                  type: string
                  description: >-
                    The cryptographic JWT signing algorithm (currently only
                    RS256 is supported)
                  enum:
                    - RS256
                  example: RS256
                publicKeyPem:
                  type: string
                  description: RSA public key in PEM format for JWT signature verification
                  format: pem
                  example: >
                    -----BEGIN PUBLIC KEY-----

                    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4f5wg5l2hKsTeNem/V41

                    fGnJm6gOdrj8ym3rFkEjWT2btf2QisEgQG5WQwTfEUvUNR8JW5FQ0mKJ5I4LhXq6

                    V5gN6kSKs2cUdD8Ky7Lj7kqn6I3l3r3F2fK9MFjZ8tU5z4z4yHdF6W2C3k5vf3f

                    -----END PUBLIC KEY-----
            examples:
              example1:
                summary: Valid RSA JWT key creation
                value:
                  name: production-key-1
                  algorithm: RSA
                  publicKeyPem: >
                    -----BEGIN PUBLIC KEY-----

                    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4f5wg5l2hKsTeNem/V41

                    fGnJm6gOdrj8ym3rFkEjWT2btf2QisEgQG5WQwTfEUvUNR8JW5FQ0mKJ5I4LhXq6

                    V5gN6kSKs2cUdD8Ky7Lj7kqn6I3l3r3F2fK9MFjZ8tU5z4z4yHdF6W2C3k5vf3f

                    -----END PUBLIC KEY-----
      responses:
        '201':
          description: JWT key created successfully
          content:
            application/json:
              schema:
                type: object
                required:
                  - kid
                properties:
                  kid:
                    type: string
                    format: uuid
                    description: The unique key identifier (key ID) for the created JWT key
                    example: 550e8400-e29b-41d4-a716-446655440000
              examples:
                example1:
                  summary: Successful key creation
                  value:
                    kid: 550e8400-e29b-41d4-a716-446655440000
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                title: API Problem
                type: object
                allOf:
                  - title: Problem
                    description: >
                      A Problem Details object (RFC 9457).


                      Additional properties specific to the problem type may be
                      present.
                    type: object
                    properties:
                      type:
                        type: string
                        format: uri
                        description: An absolute URI that identifies the problem type
                        default: about:blank
                      href:
                        type: string
                        format: uri
                        description: >-
                          An absolute URI that, when dereferenced, provides
                          human-readable documentation for the problem type
                          (e.g. using HTML).
                      title:
                        type: string
                        description: >-
                          A short summary of the problem type. Written in
                          English and readable for engineers (usually not suited
                          for non technical stakeholders and not localized).
                        example: Service Unavailable
                      status:
                        type: integer
                        format: int32
                        description: >-
                          The HTTP status code generated by the origin server
                          for this occurrence of the problem.
                        minimum: 400
                        maximum: 600
                        exclusiveMaximum: true
                        example: 503
                      detail:
                        type: string
                        description: >-
                          A human-readable explanation specific to this
                          occurrence of the problem
                      instance:
                        type: string
                        format: uri
                        description: >-
                          An absolute URI that identifies the specific
                          occurrence of the problem. It may or may not yield
                          further information if dereferenced.
                    example:
                      type: urn:problem-type:exampleOrganization:exampleProblem
                      href: >-
                        https://www.belgif.be/specification/rest/api-guide/#standardized-problem-types
                      title: Description of the type of problem that occurred
                      status: 400
                      detail: Description of specific occurrence of the problem
                      instance: urn:uuid:123e4567-e89b-12d3-a456-426614174000
                properties:
                  subsystem:
                    type: string
                    description: The subsystem that generated the problem
                    example: api
                  time:
                    type: string
                    format: date-time
                    description: The time the problem occurred, formatted as RFC-3339
                    example: '2024-04-22T18:55:28.456076Z'
                  requestId:
                    type: string
                    description: A unique identifier for the request, useful for debugging
                    example: 89eb1ffb-2a54-4105-aaae-7bf990f1aa69#87715
                  causes:
                    type: array
                    items:
                      type: string
                      description: >-
                        A brief description of something which caused the
                        problem
                      example: database connection failed
                    example:
                      - database connection failed
                      - database query failed
                      - unable to fetch user
                    description: >
                      A list of problems that caused this problem. This can be
                      used to represent multiple

                      root causes. There is no guaranteed ordering of the
                      causes.
                  remedy:
                    type: string
                    description: A brief description of how to resolve the problem
                    example: Shorten your input to be under 100 characters
                  supportEmail:
                    type: string
                    format: email
                    description: An email address to contact for support
                    example: support@withampersand.com
                  supportPhone:
                    type: string
                    description: A phone number to contact for support
                    example: +1-555-555-5555
                  supportUrl:
                    type: string
                    format: uri
                    description: A URL to contact for support
                    example: https://withampersand.com/support
                  retryable:
                    type: boolean
                    description: Whether the request can be retried
                    example: false
                  retryAfter:
                    type: string
                    format: date-time
                    description: >-
                      A timestamp after which the request can be retried,
                      formatted as RFC-3339
                    example: '2024-04-22T18:55:28.456076Z'
                  context:
                    type: object
                    description: Additional context for the problem
                    additionalProperties: true
                    example:
                      name: Rick Sanchez
              examples:
                invalidAlgorithm:
                  summary: Unsupported algorithm
                  value:
                    type: https://httpstatuses.com/400
                    title: Bad Request
                    status: 400
                    detail: unsupported algorithm
                    validationIssues:
                      - field: algorithm
                        value: ECDSA
                        detail: only RSA algorithm is supported
                        remedy: use 'RSA' as the algorithm
                invalidPublicKey:
                  summary: Invalid public key format
                  value:
                    type: https://httpstatuses.com/400
                    title: Bad Request
                    status: 400
                    detail: invalid public key
                    validationIssues:
                      - field: publicKeyPem
                        detail: invalid RSA public key in PEM format
                        remedy: provide a valid RSA public key in PEM format
        '404':
          description: Project not found
          content:
            application/json:
              schema:
                title: API Problem
                type: object
                allOf:
                  - title: Problem
                    description: >
                      A Problem Details object (RFC 9457).


                      Additional properties specific to the problem type may be
                      present.
                    type: object
                    properties:
                      type:
                        type: string
                        format: uri
                        description: An absolute URI that identifies the problem type
                        default: about:blank
                      href:
                        type: string
                        format: uri
                        description: >-
                          An absolute URI that, when dereferenced, provides
                          human-readable documentation for the problem type
                          (e.g. using HTML).
                      title:
                        type: string
                        description: >-
                          A short summary of the problem type. Written in
                          English and readable for engineers (usually not suited
                          for non technical stakeholders and not localized).
                        example: Service Unavailable
                      status:
                        type: integer
                        format: int32
                        description: >-
                          The HTTP status code generated by the origin server
                          for this occurrence of the problem.
                        minimum: 400
                        maximum: 600
                        exclusiveMaximum: true
                        example: 503
                      detail:
                        type: string
                        description: >-
                          A human-readable explanation specific to this
                          occurrence of the problem
                      instance:
                        type: string
                        format: uri
                        description: >-
                          An absolute URI that identifies the specific
                          occurrence of the problem. It may or may not yield
                          further information if dereferenced.
                    example:
                      type: urn:problem-type:exampleOrganization:exampleProblem
                      href: >-
                        https://www.belgif.be/specification/rest/api-guide/#standardized-problem-types
                      title: Description of the type of problem that occurred
                      status: 400
                      detail: Description of specific occurrence of the problem
                      instance: urn:uuid:123e4567-e89b-12d3-a456-426614174000
                properties:
                  subsystem:
                    type: string
                    description: The subsystem that generated the problem
                    example: api
                  time:
                    type: string
                    format: date-time
                    description: The time the problem occurred, formatted as RFC-3339
                    example: '2024-04-22T18:55:28.456076Z'
                  requestId:
                    type: string
                    description: A unique identifier for the request, useful for debugging
                    example: 89eb1ffb-2a54-4105-aaae-7bf990f1aa69#87715
                  causes:
                    type: array
                    items:
                      type: string
                      description: >-
                        A brief description of something which caused the
                        problem
                      example: database connection failed
                    example:
                      - database connection failed
                      - database query failed
                      - unable to fetch user
                    description: >
                      A list of problems that caused this problem. This can be
                      used to represent multiple

                      root causes. There is no guaranteed ordering of the
                      causes.
                  remedy:
                    type: string
                    description: A brief description of how to resolve the problem
                    example: Shorten your input to be under 100 characters
                  supportEmail:
                    type: string
                    format: email
                    description: An email address to contact for support
                    example: support@withampersand.com
                  supportPhone:
                    type: string
                    description: A phone number to contact for support
                    example: +1-555-555-5555
                  supportUrl:
                    type: string
                    format: uri
                    description: A URL to contact for support
                    example: https://withampersand.com/support
                  retryable:
                    type: boolean
                    description: Whether the request can be retried
                    example: false
                  retryAfter:
                    type: string
                    format: date-time
                    description: >-
                      A timestamp after which the request can be retried,
                      formatted as RFC-3339
                    example: '2024-04-22T18:55:28.456076Z'
                  context:
                    type: object
                    description: Additional context for the problem
                    additionalProperties: true
                    example:
                      name: Rick Sanchez
              examples:
                projectNotFound:
                  summary: Project does not exist
                  value:
                    type: https://httpstatuses.com/404
                    title: Not Found
                    status: 404
                    detail: project not found
                    validationIssues:
                      - field: projectId
                        detail: project not found
                        remedy: check the project ID and try again
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                title: API Problem
                type: object
                allOf:
                  - title: Problem
                    description: >
                      A Problem Details object (RFC 9457).


                      Additional properties specific to the problem type may be
                      present.
                    type: object
                    properties:
                      type:
                        type: string
                        format: uri
                        description: An absolute URI that identifies the problem type
                        default: about:blank
                      href:
                        type: string
                        format: uri
                        description: >-
                          An absolute URI that, when dereferenced, provides
                          human-readable documentation for the problem type
                          (e.g. using HTML).
                      title:
                        type: string
                        description: >-
                          A short summary of the problem type. Written in
                          English and readable for engineers (usually not suited
                          for non technical stakeholders and not localized).
                        example: Service Unavailable
                      status:
                        type: integer
                        format: int32
                        description: >-
                          The HTTP status code generated by the origin server
                          for this occurrence of the problem.
                        minimum: 400
                        maximum: 600
                        exclusiveMaximum: true
                        example: 503
                      detail:
                        type: string
                        description: >-
                          A human-readable explanation specific to this
                          occurrence of the problem
                      instance:
                        type: string
                        format: uri
                        description: >-
                          An absolute URI that identifies the specific
                          occurrence of the problem. It may or may not yield
                          further information if dereferenced.
                    example:
                      type: urn:problem-type:exampleOrganization:exampleProblem
                      href: >-
                        https://www.belgif.be/specification/rest/api-guide/#standardized-problem-types
                      title: Description of the type of problem that occurred
                      status: 400
                      detail: Description of specific occurrence of the problem
                      instance: urn:uuid:123e4567-e89b-12d3-a456-426614174000
                properties:
                  subsystem:
                    type: string
                    description: The subsystem that generated the problem
                    example: api
                  time:
                    type: string
                    format: date-time
                    description: The time the problem occurred, formatted as RFC-3339
                    example: '2024-04-22T18:55:28.456076Z'
                  requestId:
                    type: string
                    description: A unique identifier for the request, useful for debugging
                    example: 89eb1ffb-2a54-4105-aaae-7bf990f1aa69#87715
                  causes:
                    type: array
                    items:
                      type: string
                      description: >-
                        A brief description of something which caused the
                        problem
                      example: database connection failed
                    example:
                      - database connection failed
                      - database query failed
                      - unable to fetch user
                    description: >
                      A list of problems that caused this problem. This can be
                      used to represent multiple

                      root causes. There is no guaranteed ordering of the
                      causes.
                  remedy:
                    type: string
                    description: A brief description of how to resolve the problem
                    example: Shorten your input to be under 100 characters
                  supportEmail:
                    type: string
                    format: email
                    description: An email address to contact for support
                    example: support@withampersand.com
                  supportPhone:
                    type: string
                    description: A phone number to contact for support
                    example: +1-555-555-5555
                  supportUrl:
                    type: string
                    format: uri
                    description: A URL to contact for support
                    example: https://withampersand.com/support
                  retryable:
                    type: boolean
                    description: Whether the request can be retried
                    example: false
                  retryAfter:
                    type: string
                    format: date-time
                    description: >-
                      A timestamp after which the request can be retried,
                      formatted as RFC-3339
                    example: '2024-04-22T18:55:28.456076Z'
                  context:
                    type: object
                    description: Additional context for the problem
                    additionalProperties: true
                    example:
                      name: Rick Sanchez
components:
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      name: X-Api-Key
      in: header
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````