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

# Set your webhook endpoint

> Creates the endpoint (201, with its signing `secret`, shown only this once) or updates its url / events / enabled (200).



## OpenAPI

````yaml /openapi.json post /webhooks
openapi: 3.1.0
info:
  title: Docistra API
  version: 1.0.0
  description: >-
    Connect your software to Docistra in both directions. All times are ISO
    8601; Docistra's clinics run on Cairo time (Africa/Cairo). Every path {id}
    takes Docistra's id or `ext:<your id>`.
servers:
  - url: https://docistra.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Organization
  - name: Patients
  - name: Appointments
  - name: Availability
  - name: Doctors
  - name: Doctor schedule
  - name: Branches
  - name: Reference data
  - name: Webhooks
paths:
  /webhooks:
    post:
      tags:
        - Webhooks
      summary: Set your webhook endpoint
      description: >-
        Creates the endpoint (201, with its signing `secret`, shown only this
        once) or updates its url / events / enabled (200).
      operationId: setWebhook
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  format: uri
                  description: https only
                events:
                  type: array
                  items:
                    $ref: '#/components/schemas/EventType'
                  description: Empty or left out = every event.
                enabled:
                  type: boolean
            example:
              url: https://his.example.com/docistra/webhooks
              events: []
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/WebhookEndpoint'
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    allOf:
                      - $ref: '#/components/schemas/WebhookEndpoint'
                      - type: object
                        properties:
                          secret:
                            type: string
                            example: whsec_...
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      schema:
        type: string
        maxLength: 255
      description: >-
        A unique value (e.g. a UUID) per operation. A retry with the same key
        returns the first response for 24 hours.
  schemas:
    EventType:
      type: string
      enum:
        - patient.created
        - patient.updated
        - patient.deleted
        - appointment.created
        - appointment.rescheduled
        - appointment.cancelled
        - appointment.status_changed
        - doctor.day_off
        - doctor.day_on
    WebhookEndpoint:
      type: object
      properties:
        object:
          const: webhook_endpoint
        id:
          type: string
        url:
          type: string
        events:
          type: array
          items:
            $ref: '#/components/schemas/EventType'
        enabled:
          type: boolean
        created_at:
          type: string
          format: date-time
        last_success_at:
          type:
            - string
            - 'null'
          format: date-time
        last_failure_at:
          type:
            - string
            - 'null'
          format: date-time
        consecutive_failures:
          type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your API key (dk_live_...), from Settings > Integrations > API in
        Docistra.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.