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

# Create a webhook endpoint

> Events are delivered only for scopes the caller holds. The signing secret is returned once.

Requires the `webhooks:write` scope.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/webhook_endpoints
openapi: 3.1.0
info:
  title: BrandGate API
  version: 1.0.0
  description: >-
    Read orders, products, stock, customers and invoices, acknowledge orders and
    set stock from your ERP. Authenticate with an organization API key or an
    OAuth access token as `Authorization: Bearer <token>`.
servers:
  - url: https://api.brandgate.dev
security:
  - apiKey: []
  - oauth2: []
tags:
  - name: orders
    description: Orders placed by resellers.
  - name: products
    description: The product catalogue.
  - name: inventory
    description: Stock levels per SKU.
  - name: customers
    description: Resellers buying from the organization.
  - name: invoices
    description: Invoices sent to resellers.
  - name: webhook_endpoints
    description: Where BrandGate sends events.
paths:
  /v1/webhook_endpoints:
    post:
      tags:
        - webhook_endpoints
      summary: Create a webhook endpoint
      description: >-
        Events are delivered only for scopes the caller holds. The signing
        secret is returned once.


        Requires the `webhooks:write` scope.
      operationId: webhooksCreate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  maxLength: 2000
                  format: uri
                events:
                  type: array
                  items:
                    type: string
                    enum:
                      - order.created
                      - order.updated
                      - invoice.created
                      - invoice.updated
                      - product.stock_low
                  minItems: 1
                  maxItems: 5
                description:
                  type: string
                  maxLength: 200
              required:
                - url
                - events
              additionalProperties: false
      responses:
        '201':
          description: Success.
          headers:
            Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  object:
                    const: webhook_endpoint
                  url:
                    type: string
                    format: uri
                  events:
                    type: array
                    items:
                      type: string
                      enum:
                        - order.created
                        - order.updated
                        - invoice.created
                        - invoice.updated
                        - product.stock_low
                  description:
                    type:
                      - string
                      - 'null'
                    maxLength: 200
                  status:
                    type: string
                    enum:
                      - enabled
                      - disabled
                  disabled_reason:
                    type:
                      - string
                      - 'null'
                    maxLength: 200
                  created_at:
                    type: string
                    format: date-time
                  secret:
                    type: string
                    pattern: ^whsec_[A-Za-z0-9_-]{43}$
                required:
                  - id
                  - object
                  - url
                  - events
                  - description
                  - status
                  - disabled_reason
                  - created_at
                  - secret
                additionalProperties: false
        '400':
          description: The request is invalid. `error.message` says which field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing, unknown, expired or revoked credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The credentials lack the scope this operation needs.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Rate limited. Wait until `X-RateLimit-Reset` (or `Retry-After`
            seconds).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
        - oauth2:
            - webhooks:write
components:
  headers:
    RequestId:
      description: Quote this when contacting support.
      schema:
        type: string
        format: uuid
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            request_id:
              type: string
          required:
            - code
            - message
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        An organization API key (`bg_live_…`), created in BrandGate under
        Settings → Developers.
    oauth2:
      type: oauth2
      description: >-
        For partner apps acting for many organizations. Authorization code with
        PKCE (S256).
      flows:
        authorizationCode:
          authorizationUrl: https://api.brandgate.dev/oauth/authorize
          tokenUrl: https://api.brandgate.dev/oauth/token
          refreshUrl: https://api.brandgate.dev/oauth/token
          scopes:
            orders:read: Read orders and their lines
            orders:write: Acknowledge orders with the ERP's own order number
            products:read: Read products and prices
            inventory:read: Read stock levels
            inventory:write: Update stock levels by SKU
            customers:read: Read customers (resellers), including contact details
            invoices:read: Read invoices
            webhooks:read: List webhook endpoints
            webhooks:write: Create and delete webhook endpoints

````

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