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

# Create Hook

> Create a new hook for the current account.

Supports schedule, event, and manual trigger types. Returns 422 for invalid
cron expressions or unrecognised event names. Returns 409 when the account
has reached the maximum hook limit.



## OpenAPI

````yaml post /api/v1/hooks
openapi: 3.1.0
info:
  title: SnackBase
  description: Open-source Backend-as-a-Service (BaaS)
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/hooks:
    post:
      tags:
        - hooks
        - Hooks
      summary: Create Hook
      description: >-
        Create a new hook for the current account.


        Supports schedule, event, and manual trigger types. Returns 422 for
        invalid

        cron expressions or unrecognised event names. Returns 409 when the
        account

        has reached the maximum hook limit.
      operationId: create_hook_api_v1_hooks_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HookCreateRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HookResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    HookCreateRequest:
      properties:
        name:
          type: string
          maxLength: 200
          minLength: 1
          title: Name
          description: Human-readable name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional description
        trigger:
          oneOf:
            - $ref: >-
                #/components/schemas/snackbase__infrastructure__api__schemas__hook_schemas__ScheduleTriggerConfig
            - $ref: >-
                #/components/schemas/snackbase__infrastructure__api__schemas__hook_schemas__EventTriggerConfig
            - $ref: >-
                #/components/schemas/snackbase__infrastructure__api__schemas__hook_schemas__ManualTriggerConfig
          title: Trigger
          description: When this hook fires
          discriminator:
            propertyName: type
            mapping:
              event:
                $ref: >-
                  #/components/schemas/snackbase__infrastructure__api__schemas__hook_schemas__EventTriggerConfig
              manual:
                $ref: >-
                  #/components/schemas/snackbase__infrastructure__api__schemas__hook_schemas__ManualTriggerConfig
              schedule:
                $ref: >-
                  #/components/schemas/snackbase__infrastructure__api__schemas__hook_schemas__ScheduleTriggerConfig
        condition:
          anyOf:
            - type: string
            - type: 'null'
          title: Condition
          description: >-
            Optional rule expression — hook only fires when this evaluates to
            True
        actions:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Actions
          description: Ordered list of actions to execute
        enabled:
          type: boolean
          title: Enabled
          description: Whether the hook is active on creation
          default: true
      type: object
      required:
        - name
        - trigger
      title: HookCreateRequest
      description: Request body for creating a hook (any trigger type).
    HookResponse:
      properties:
        id:
          type: string
          title: Id
        account_id:
          type: string
          title: Account Id
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        trigger:
          additionalProperties: true
          type: object
          title: Trigger
        condition:
          anyOf:
            - type: string
            - type: 'null'
          title: Condition
        actions:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Actions
        enabled:
          type: boolean
          title: Enabled
        last_run_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Run At
        next_run_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Next Run At
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        created_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By
        cron:
          anyOf:
            - type: string
            - type: 'null'
          title: Cron
          description: Cron expression (schedule triggers only)
        cron_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Cron Description
          description: Human-readable cron schedule
      type: object
      required:
        - id
        - account_id
        - name
        - description
        - trigger
        - condition
        - actions
        - enabled
        - last_run_at
        - next_run_at
        - created_at
        - updated_at
        - created_by
      title: HookResponse
      description: Response schema for a single hook.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    snackbase__infrastructure__api__schemas__hook_schemas__ScheduleTriggerConfig:
      properties:
        type:
          type: string
          const: schedule
          title: Type
        cron:
          type: string
          title: Cron
          description: 5-field cron expression (e.g. '0 9 * * MON')
      type: object
      required:
        - type
        - cron
      title: ScheduleTriggerConfig
      description: Trigger that fires on a cron schedule.
    snackbase__infrastructure__api__schemas__hook_schemas__EventTriggerConfig:
      properties:
        type:
          type: string
          const: event
          title: Type
        event:
          type: string
          title: Event
          description: >-
            Event to listen for. Supported: records.create, records.update,
            records.delete, auth.login, auth.register
        collection:
          anyOf:
            - type: string
            - type: 'null'
          title: Collection
          description: >-
            Restrict to a specific collection (record events only). Omit to
            listen on all collections.
      type: object
      required:
        - type
        - event
      title: EventTriggerConfig
      description: Trigger that fires when a platform event occurs.
    snackbase__infrastructure__api__schemas__hook_schemas__ManualTriggerConfig:
      properties:
        type:
          type: string
          const: manual
          title: Type
      type: object
      required:
        - type
      title: ManualTriggerConfig
      description: Trigger that only fires when called explicitly via the API.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````