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

# POST - Webhook

>  This API allows authenticated users to create a new webhook for automatic processing of uploaded documents. The webhook will be triggered when documents are processed using the specified API template.


 **Key Notes:** 
 - Requires authentication and a valid API template ID from the webhook templates endpoint. 
 - The `secret_hash` field is encrypted using encryption for security. 
 - Each user can only create one webhook per API template (duplicate prevention). 
 - Returns the created webhook details including the generated UUID.


 **Required Fields:** 
 - **api_template**: UUID of the webhook template (from webhook templates endpoint) 
 - **endpoint_url**: The URL where webhook notifications will be sent 
 - **secret_hash**: Optional secret key for webhook authentication (will be encrypted)


 **Scenario: Setting Up Document Processing Webhook** 
 - A developer wants to receive automatic notifications when assignment answer sheets are processed. 
 - They first call the webhook templates endpoint to get the template ID for 'assignment_answer_sheet_extraction'. 
 - They then call this endpoint with the template ID, their webhook URL, and optional secret hash. 
 - The system creates the webhook and returns the webhook details for future reference. 



## OpenAPI

````yaml POST /webhooks/v1/webhook/
openapi: 3.0.1
info:
  title: Webhook Management API
  description: >-
    An API for managing webhooks for automatic document processing and
    notifications.
  version: 1.0.0
servers:
  - url: https://api-staging.crazygoldfish.com
    description: SandBox endpoint
  - url: https://api.crazygoldfish.com
    description: Prod End Point
security: []
paths:
  /webhooks/v1/webhook/:
    post:
      tags:
        - Webhooks
      summary: Create Webhook
      description: >-
        Creates a new webhook for automatic processing of uploaded documents.
        The webhook will be triggered when documents are processed using the
        specified API template.
      operationId: createWebhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookCreateRequest'
            example:
              api_template: 488f4644-057d-41e7-9a74-72c040602647
              endpoint_url: https://example.com/webhook/assignment-processing
              secret_hash: my-secret-key-123
      responses:
        '201':
          description: Webhook created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookResponse'
              example:
                id: 428f1ea8-7efc-4ec8-a449-85b010b26472
                api_template:
                  id: 488f4644-057d-41e7-9a74-72c040602647
                  name: assignment_evaluation_student_answer_sheet_extraction
                  display_name: Assignment Answer Sheet Extraction
                  description: null
                endpoint_url: https://example.com/webhook/assignment-processing
        '400':
          description: Bad Request - Validation error or webhook already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
              example:
                error:
                  code: 400
                  message:
                    non_field_errors:
                      - Webhook already exists
        '401':
          description: Unauthorized - Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message:
                    non_field_errors:
                      - Authentication credentials were not provided.
        '500':
          description: Internal Server Error - Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 500
                  message:
                    non_field_errors:
                      - Internal Server Error
      security:
        - bearerAuth: []
components:
  schemas:
    WebhookCreateRequest:
      type: object
      properties:
        api_template:
          type: string
          format: uuid
          description: UUID of the webhook template to use for processing
          example: 488f4644-057d-41e7-9a74-72c040602647
        endpoint_url:
          type: string
          format: uri
          description: The URL where webhook notifications will be sent
          example: https://example.com/webhook/assignment-processing
        secret_hash:
          type: string
          description: Optional secret key for webhook authentication (will be encrypted)
          example: my-secret-key-123
      required:
        - api_template
        - endpoint_url
    WebhookResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier of the webhook
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        api_template:
          type: object
          description: Webhook template details
          properties:
            id:
              type: string
              format: uuid
              description: UUID of the webhook template
              example: 488f4644-057d-41e7-9a74-72c040602647
            name:
              type: string
              description: Internal name of the webhook template
              example: assignment_evaluation_student_answer_sheet_extraction
            display_name:
              type: string
              description: Display name of the webhook template
              example: Assignment Answer Sheet Extraction
            description:
              type: string
              nullable: true
              description: Description of the webhook template
              example: null
          required:
            - id
            - name
            - display_name
        endpoint_url:
          type: string
          format: uri
          description: The URL where webhook notifications are sent
          example: https://example.com/webhook/assignment-processing
      required:
        - id
        - api_template
        - endpoint_url
    ValidationErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP status code
              example: 400
            message:
              type: object
              description: Validation error details
              additionalProperties:
                type: array
                items:
                  type: string
          required:
            - code
            - message
      required:
        - error
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP status code
              example: 404
            message:
              type: object
              properties:
                non_field_errors:
                  type: array
                  items:
                    type: string
                  description: List of error messages
                  example:
                    - Webhook not found
              required:
                - non_field_errors
          required:
            - code
            - message
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````