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

# Create Webhook

> Create a new webhook

<ResponseExample>
  ```json 200 theme={null}
  {
    "status": "success",
    "webhook": {
      "id": 123,
      "url": "https://api.example.com/webhook",
      "events": [
        "transaction"
      ],
      "disabled": true,
      "disabled_at": "2024-01-23 01:23:45.55338+00",
      "created_at": "2024-01-23 01:23:45.55338+00"
    }
  }
  ```

  ```json 400 - HTTPS theme={null}
  {
    "status": "failed",
    "error": "Only HTTPS urls allowed"
  }
  ```

  ```json 400 - URL theme={null}
  {
    "status": "failed",
    "error": "Invalid url"
  }
  ```

  ```JSON 404 - Events theme={null}
  {
    "status": "failed",
    "error": "Webhook events not found"
  }
  ```

  ```JSON 500 theme={null}
  {
    "status": "failed",
    "error": "Database operation failed"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml post /webhook
openapi: 3.0.0
info:
  version: 0.1.0
  title: Openformat API
servers:
  - url: https://api.openformat.tech/v1
    description: Live server
security:
  - ApiKeyAuth: []
paths:
  /webhook:
    post:
      tags:
        - webhook
        - create
      description: Create a new webhook
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  minLength: 1
                  description: Webhook URL to send the payload, only HTTPS supported
                  example: https://api.example.com/webhook
                events:
                  type: array
                  items:
                    type: string
                  description: >-
                    List of events that will trigger the webhook call, if empty
                    all events will be used
                  example:
                    - transaction
              required:
                - url
      responses:
        '201':
          description: Created webhook
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                    description: Successful reponse status
                    example: success
                  webhook:
                    type: object
                    properties:
                      id:
                        type: number
                        description: Webhook id
                        example: 123
                      url:
                        type: string
                        description: Webhook URL
                        example: https://api.example.com/webhook
                      events:
                        type: array
                        items:
                          type: string
                          description: Event name
                          example: transaction
                        description: List of events that will trigger this webhook
                        example:
                          - transaction
                      disabled:
                        type: boolean
                        description: Whether this webhook is disabled
                        example: true
                      disabled_at:
                        type: string
                        description: Datetime this webhook was disabled
                        example: '2024-01-23 01:23:45.55338+00'
                      created_at:
                        type: string
                        description: Datetime this webhook was created
                        example: '2024-01-23 01:23:45.55338+00'
                    required:
                      - id
                      - url
                      - events
                      - disabled
                      - disabled_at
                      - created_at
                    description: The webhook data
                required:
                  - status
                  - webhook
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      issues:
                        type: array
                        items:
                          type: object
                          properties:
                            code:
                              type: string
                              description: Error code for the field
                              example: invalid_type
                            path:
                              type: array
                              items:
                                type: string
                              description: Field with error
                              example:
                                - some_field
                            message:
                              type: string
                              description: Error message
                              example: Required
                          required:
                            - code
                            - path
                            - message
                        description: Error object with all validation issues
                    required:
                      - issues
                required:
                  - error
        '500':
          description: An error ocurred
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - failed
                    description: Failed reponse status
                    example: failed
                  error:
                    type: string
                    description: Error message
                    example: Database operation failed
                required:
                  - status
                  - error
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````