> ## Documentation Index
> Fetch the complete documentation index at: https://ekacare-durgesh-output-language.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Register Webhook

> Registers a new webhook triggered by specific events. Each webhook is linked to a `business_id`, `client_id`, `endpoint`, and `event_names` defining the events that trigger it. The service sends POST requests to the specified URL for these events. The URL must be reachable and preferably secure (HTTPS). Optionally, a signing key can be provided to verify webhook payload authenticity.




## OpenAPI

````yaml post /notification/v1/connect/webhook/subscriptions
openapi: 3.1.0
info:
  title: Webhook Service for the Clients
  description: >
    The Webhook Service allows clients to register webhooks that are triggered
    based on specific events. Each webhook is associated with a business_id,
    client_id, endpoint, and scopes. The scopes defines the type of events that
    will trigger the webhook.
  version: 1.0.0
servers:
  - url: https://api.eka.care
security: []
paths:
  /notification/v1/connect/webhook/subscriptions:
    post:
      tags:
        - Webhooks
      summary: Register Webhook
      description: >
        Registers a new webhook triggered by specific events. Each webhook is
        linked to a `business_id`, `client_id`, `endpoint`, and `event_names`
        defining the events that trigger it. The service sends POST requests to
        the specified URL for these events. The URL must be reachable and
        preferably secure (HTTPS). Optionally, a signing key can be provided to
        verify webhook payload authenticity.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegisterWebhookRequest'
      responses:
        '201':
          description: Webhook registered successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegisterWebhookResponse'
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        example: requested endpoint is already registered
                      code:
                        type: string
                        example: INVALID_REQUEST
        '401':
          description: Unauthorized request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        example: Unauthorized request
                      code:
                        type: string
                        example: INVALID_REQUEST
        '500':
          description: Server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        example: Internal Server Error
                      code:
                        type: string
                        example: SERVER_ERROR
      security:
        - bearerAuth: []
components:
  schemas:
    RegisterWebhookRequest:
      type: object
      properties:
        event_names:
          type: array
          items:
            type: string
          description: |
            Specifies the type of events that will trigger the webhook.
            - "appointment.created": Trigger on appointment create events.
            - "user.delete": Trigger on user delete events.
          example:
            - appointment.created
            - appointment.updated
            - prescription.created
            - prescription.updated
            - receipt.created
            - receipt.updated
        endpoint:
          type: string
          description: |
            The fully qualified URL where the webhook will send POST requests.
            The URL must be reachable by the webhook service.
          example: https://example.com/webhook
        signing_key:
          type: string
          description: >
            A secret key provided by the client for verifying the authenticity
            of webhook payloads.

            It should be a securely generated, random string.
          example: supersecretkey
        protocol:
          type: string
          description: |
            Specifies the protocol or delivery mechanism used for the webhook.
            - "http": Plain HTTP endpoint.
            - "https": Secure HTTPS endpoint.
            - "SQS endpoint": AWS SQS queue URL for message delivery.
            - "Lambda function": AWS Lambda function ARN for direct invocation.
          example: https
      required:
        - endpoint
    RegisterWebhookResponse:
      type: object
      properties:
        id:
          type: string
          description: The unique identifier for the webhook.
          example: '7'
        status:
          type: string
          description: |
            A message indicating the status of the response.
          example: success
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        The API requires a Bearer token in the Authorization header for
        authentication.

````