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

# Create Webhook

> Mixin for organization access validation.

Automatically resolves and validates organization access on every request,
making the organization available as self.organization.

For API key auth:  organization is derived from the key (no org_id param needed).
For user auth:     organization_id must be provided in the request
                   (kwargs / headers / body / query params).

Usage:
    class MyView(BaseOrganizationAccessMixin, APIView):
        def get(self, request):
            # self.organization is automatically available
            return Response({"org": self.organization.name})



## OpenAPI

````yaml POST /webhooks/
openapi: 3.1.0
info:
  title: Roe AI API
  version: 1.0.0
  description: Complete API documentation for Roe AI platform
servers:
  - url: https://api.roe-ai.com
    description: Production API
security: []
paths:
  /webhooks/:
    post:
      tags:
        - webhooks
      description: >-
        Mixin for organization access validation.


        Automatically resolves and validates organization access on every
        request,

        making the organization available as self.organization.


        For API key auth:  organization is derived from the key (no org_id param
        needed).

        For user auth:     organization_id must be provided in the request
                           (kwargs / headers / body / query params).

        Usage:
            class MyView(BaseOrganizationAccessMixin, APIView):
                def get(self, request):
                    # self.organization is automatically available
                    return Response({"org": self.organization.name})
      operationId: webhooks_create
      parameters:
        - name: organization_id
          in: query
          required: false
          schema:
            type: string
            format: uuid
          description: >-
            Organization ID. This is required for access control. It can be
            provided via query or request body depending on the endpoint.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateWebhook'
          description: ''
      security:
        - jwtAuth: []
      x-codeSamples:
        - lang: Python
          source: |
            import requests

            response = requests.post(
                "https://api.roe-ai.com/webhooks/",
                headers={
                    "Authorization": "Bearer YOUR_API_KEY",
                    "Content-Type": "application/json"
                },
                json={
                    "name": "Job Notifications",
                    "url": "https://your-server.com/webhooks/roe",
                    "events": ["job_completed"]
                }
            )
            webhook = response.json()
            print(f"Created webhook: {webhook['id']}")
        - lang: TypeScript
          source: |
            const response = await fetch("https://api.roe-ai.com/webhooks/", {
              method: "POST",
              headers: {
                "Authorization": "Bearer YOUR_API_KEY",
                "Content-Type": "application/json"
              },
              body: JSON.stringify({
                name: "Job Notifications",
                url: "https://your-server.com/webhooks/roe",
                events: ["job_completed"]
              })
            });
            const webhook = await response.json();
            console.log(`Created webhook: ${webhook.id}`);
        - lang: cURL
          source: |
            curl -X POST "https://api.roe-ai.com/webhooks/" \
              -H "Authorization: Bearer YOUR_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "name": "Job Notifications",
                "url": "https://your-server.com/webhooks/roe",
                "events": ["job_completed"]
              }'
components:
  schemas:
    CreateWebhookRequest:
      type: object
      description: Serializer for creating webhooks
      properties:
        name:
          type: string
          minLength: 1
          description: User-friendly name for this webhook
          maxLength: 255
        url:
          type: string
          format: uri
          minLength: 1
          description: Webhook endpoint URL
          maxLength: 500
        secret:
          type: string
          maxLength: 255
        headers:
          type: object
          additionalProperties:
            type: string
            minLength: 1
          description: Custom headers to include in webhook requests (key-value pairs)
        events:
          type: array
          items:
            type: string
            minLength: 1
          description: List of events to trigger this webhook (e.g., ['triggered'])
        is_active:
          type: boolean
        alerts:
          type: array
          items:
            type: string
            format: uuid
      required:
        - name
        - url
    CreateWebhook:
      type: object
      description: Serializer for creating webhooks
      properties:
        name:
          type: string
          description: User-friendly name for this webhook
          maxLength: 255
        url:
          type: string
          format: uri
          description: Webhook endpoint URL
          maxLength: 500
        secret:
          type: string
          maxLength: 255
        headers:
          type: object
          additionalProperties:
            type: string
          description: Custom headers to include in webhook requests (key-value pairs)
        events:
          type: array
          items:
            type: string
          description: List of events to trigger this webhook (e.g., ['triggered'])
        is_active:
          type: boolean
        alerts:
          type: array
          items:
            type: string
            format: uuid
      required:
        - name
        - url
  securitySchemes:
    jwtAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````