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

# Register Webhook

> Register a new webhook endpoint to receive swap lifecycle events

The full lifecycle, payload formats, signature verification, and Discord/Slack auto-detection are documented at [Webhooks](/api-reference/webhooks).

<Note>
  The `secret` is only returned at creation time. Save it immediately — you'll need it to verify HMAC signatures on incoming webhook deliveries.
</Note>


## OpenAPI

````yaml /api-reference/openapi.json POST /webhooks
openapi: 3.0.3
info:
  title: Leokit API
  version: 1.0.0
  description: API reference for Leokit
servers:
  - url: https://api.leokit.dev
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /webhooks:
    post:
      summary: Register a webhook
      description: >-
        Discord and Slack URLs are auto-detected; standard URLs receive
        HMAC-signed JSON.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookCreateRequest'
            example:
              url: https://your-server.com/webhooks/leokit
              events:
                - swap.success
                - swap.failed
                - swap.refunded
              type: standard
      responses:
        '200':
          description: Webhook created. The `secret` is only returned once.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookCreateResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  schemas:
    WebhookCreateRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: HTTPS URL. Discord/Slack URLs are auto-detected.
        events:
          type: array
          description: Defaults to all 6 events.
          items:
            type: string
            enum:
              - quote.created
              - deposit.initiated
              - swap.pending
              - swap.success
              - swap.failed
              - swap.refunded
        type:
          type: string
          enum:
            - standard
            - discord
            - slack
          description: Auto-detected from URL if omitted.
    WebhookCreateResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/WebhookRecord'
    WebhookRecord:
      type: object
      required:
        - id
        - url
        - events
        - type
        - is_active
        - created_at
      properties:
        id:
          type: string
          format: uuid
        url:
          type: string
          format: uri
        events:
          type: array
          items:
            type: string
        type:
          type: string
          enum:
            - standard
            - discord
            - slack
        is_active:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        secret:
          type: string
          description: Only returned on creation. Save it immediately.
    Error:
      type: object
      description: Generic error payload.
      properties:
        message:
          type: string
        code:
          type: string
  responses:
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Api-Key
      description: 'Demo API-Key (Sandbox): 7037d2b3-9c76-4f62-b730-c544f7570fa4'

````