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

# Create a webhook

> Register an HTTPS URL. Generic receivers get signed JSON; Discord and Slack incoming webhook URLs are detected automatically and receive rich alerts without NinjaChat signing-secret setup. Platform URL credentials are redacted in responses. New events require explicit subscription; omitted events retain the six original defaults. Console: https://www.ninjachat.ai/developers/webhooks



## OpenAPI

````yaml /openapi.json post /webhooks
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Clean-break NinjaChat v1. Chat and Responses bill actual token usage; images
    and videos use catalog unit pricing.
servers:
  - url: https://www.ninjachat.ai/api/v1
security: []
paths:
  /webhooks:
    post:
      summary: Create a webhook
      description: >-
        Register an HTTPS URL. Generic receivers get signed JSON; Discord and
        Slack incoming webhook URLs are detected automatically and receive rich
        alerts without NinjaChat signing-secret setup. Platform URL credentials
        are redacted in responses. New events require explicit subscription;
        omitted events retain the six original defaults. Console:
        https://www.ninjachat.ai/developers/webhooks
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookCreateRequest'
      responses:
        '201':
          description: >-
            Webhook created. The signing secret is returned once (used only by
            generic receivers).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookCreateResponse'
        '400':
          description: Invalid or unsupported request parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient balance or project spend limit reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Gateway error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: javascript
          label: TypeScript SDK
          source: >-
            import { NinjaChat } from "@ninjachat/sdk";


            const client = new NinjaChat({ apiKey:
            process.env.NINJACHAT_API_KEY! });

            const endpoint = await client.webhooks.create({
              url: "https://example.com/webhooks/ninjachat",
              events: ["video.completed", "video.failed"],
            });


            console.log(endpoint.secret); // Store once, then redact it from
            logs.
        - lang: python
          label: Python SDK
          source: |-
            import os
            from ninjachat import NinjaChat

            client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
            endpoint = client.webhooks.create(
                url="https://example.com/webhooks/ninjachat",
                events=["video.completed", "video.failed"],
            )

            print(endpoint["secret"])  # Store once, then redact it from logs.
components:
  schemas:
    WebhookCreateRequest:
      type: object
      properties:
        url:
          type: string
          maxLength: 2000
          format: uri
        events:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEvent'
          minItems: 1
          default:
            - video.completed
            - video.failed
            - pipeline.completed
            - pipeline.failed
            - budget.alert
            - balance.low
      required:
        - url
      additionalProperties: false
    WebhookCreateResponse:
      type: object
      properties:
        id:
          type: string
        url:
          type: string
          format: uri
        destination:
          type: string
          enum:
            - webhook
            - discord
            - slack
        events:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEvent'
        secret:
          type: string
        message:
          type: string
      required:
        - id
        - url
        - events
        - secret
        - message
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
            param:
              type:
                - string
                - 'null'
          required:
            - message
            - type
            - code
          additionalProperties: false
      required:
        - error
      additionalProperties: false
    WebhookEvent:
      type: string
      enum:
        - video.completed
        - video.failed
        - pipeline.completed
        - pipeline.failed
        - request.failed
        - budget.alert
        - balance.low
        - balance.exhausted
        - credits.added
        - auto_recharge.failed
        - key.created
        - key.revoked
        - budget.updated
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.

````