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

# Create a webhook encryption key

> Register a new encryption key (JWK) for a webhook endpoint. The key will be used for encrypting webhook payloads.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/webhooks/endpoints/{endpoint_id}/keys
openapi: 3.1.0
info:
  title: Kayle ID
  version: 1.5.0
  description: Privacy-first identity verification.
  license:
    name: Apache License 2.0
    url: https://github.com/kayleai/kayle-id/blob/main/LICENSE
  contact:
    name: Kayle ID
    url: https://kayle.id
    email: help@kayle.id
  termsOfService: https://kayle.id/terms
servers:
  - url: http://127.0.0.1:8787
    description: ''
security:
  - bearerAuth: []
paths:
  /v1/webhooks/endpoints/{endpoint_id}/keys:
    post:
      tags:
        - Webhooks
      summary: Create a webhook encryption key
      description: >-
        Register a new encryption key (JWK) for a webhook endpoint. The key will
        be used for encrypting webhook payloads.
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 128
            pattern: ^[A-Za-z0-9_-]+$
            description: >-
              The ID of the webhook endpoint to create the encryption key for
              (e.g. whe_...).
          required: true
          description: >-
            The ID of the webhook endpoint to create the encryption key for
            (e.g. whe_...).
          name: endpoint_id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookEncryptionKeyRequest'
      responses:
        '200':
          description: Successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Webhook Encryption Key'
                  error:
                    type: 'null'
                required:
                  - data
                  - error
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: 'null'
                    description: Empty data object.
                  error:
                    type:
                      - object
                      - 'null'
                    properties:
                      code:
                        type: string
                        description: The error code
                      message:
                        type: string
                        description: The error message
                      hint:
                        type: string
                        description: A hint to help the user fix the error
                      docs:
                        type: string
                        description: A link to the documentation for the error
                    required:
                      - code
                      - message
                      - hint
                      - docs
                required:
                  - data
                  - error
                example:
                  data: null
                  error:
                    code: BAD_REQUEST
                    message: Bad request.
                    hint: The request payload is invalid.
                    docs: https://kayle.id/docs/api/webhooks/keys#create
        '404':
          description: Webhook endpoint not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: 'null'
                    description: Empty data object.
                  error:
                    type:
                      - object
                      - 'null'
                    properties:
                      code:
                        type: string
                        description: The error code
                      message:
                        type: string
                        description: The error message
                      hint:
                        type: string
                        description: A hint to help the user fix the error
                      docs:
                        type: string
                        description: A link to the documentation for the error
                    required:
                      - code
                      - message
                      - hint
                      - docs
                required:
                  - data
                  - error
                example:
                  data: null
                  error:
                    code: NOT_FOUND
                    message: Webhook endpoint not found.
                    hint: The webhook endpoint with the given ID was not found.
                    docs: https://kayle.id/docs/api/webhooks/keys#create
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: 'null'
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - INTERNAL_SERVER_ERROR
                      message:
                        type: string
                        enum:
                          - Internal server error.
                      hint:
                        type: string
                        enum:
                          - The server encountered an error.
                      docs:
                        type: string
                        enum:
                          - https://kayle.id/docs/api/errors
                    required:
                      - code
                      - message
                      - hint
                      - docs
                required:
                  - data
                  - error
      security:
        - bearerAuth: []
components:
  schemas:
    CreateWebhookEncryptionKeyRequest:
      type: object
      properties:
        key_id:
          type: string
          minLength: 1
          maxLength: 128
          description: The key identifier to use as `kid` in the JWE header.
        jwk:
          type: object
          properties:
            kty:
              type: string
              enum:
                - RSA
            'n':
              type: string
              minLength: 1
              maxLength: 8192
            e:
              type: string
              minLength: 1
              maxLength: 64
            alg:
              type: string
              maxLength: 64
            use:
              type: string
              maxLength: 32
            key_ops:
              type: array
              items:
                type: string
                maxLength: 64
              maxItems: 8
          additionalProperties:
            anyOf:
              - type: string
                maxLength: 8192
              - type: boolean
              - type: number
              - type: array
                items:
                  type: string
                  maxLength: 64
                maxItems: 8
          description: The public JWK for encrypting webhook payloads.
        algorithm:
          type: string
          enum:
            - RSA-OAEP-256
          description: The JWE algorithm to use for webhook delivery.
        key_type:
          type: string
          enum:
            - RSA
          description: The JWK key type for webhook delivery.
      required:
        - key_id
        - jwk
        - algorithm
        - key_type
    Webhook Encryption Key:
      type: object
      properties:
        id:
          type: string
          description: The ID of the webhook encryption key
        webhook_endpoint_id:
          type: string
          description: The ID of the webhook endpoint this key belongs to
        key_id:
          type: string
          description: The key identifier, used as `kid` in the JWE header
        algorithm:
          type: string
          description: The JWE algorithm (e.g. ECDH-ES)
        key_type:
          type: string
          description: The JWK key type (e.g. EC)
        jwk:
          type: object
          additionalProperties: {}
          description: The public JWK used to encrypt webhook payloads
        is_active:
          type: boolean
          description: Whether this key is active for new webhook deliveries
        created_at:
          type: string
          description: The time the key was created
        updated_at:
          type: string
          description: The time the key was last updated
        disabled_at:
          type:
            - string
            - 'null'
          description: The time the key was disabled, null if still active
      required:
        - id
        - webhook_endpoint_id
        - key_id
        - algorithm
        - key_type
        - jwk
        - is_active
        - created_at
        - updated_at
        - disabled_at
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````