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

# Create a custom event type

> Registers a custom event type `custom.<name>` for a realm, so notification rules can be set for it before the first event arrives.

Requires a realm operator (or higher) with the `rules.manage.realm` permission on the realm given by `realm_id`.



## OpenAPI

````yaml /openapi/hub-by-tag/hub-events.yaml post /v1/events/custom/create
openapi: 3.0.3
info:
  title: 'CliqHub API: Events'
  version: 1.0.0
  description: >-
    The notification event bus. Events have a type from CliqHub's catalog
    (`run.failed`,

    `phase.input_required`, `hug.review_requested`, `daemon.offline`, …) or a
    custom type

    `custom.<name>` registered for a realm. Notification rules match events and
    deliver them to

    channels. Daemons and integrations submit events; CliqHub raises some
    itself. This is not

    the live run timeline (that is Runs).
servers:
  - url: https://{host}
    variables:
      host:
        default: cliqhub.io
        description: CliqHub host
security: []
tags:
  - name: Events
    description: >-
      The notification event bus. Events have a type from CliqHub's catalog
      (`run.failed`,

      `phase.input_required`, `hug.review_requested`, `daemon.offline`, …) or a
      custom type

      `custom.<name>` registered for a realm. Notification rules match events
      and deliver them to

      channels. Daemons and integrations submit events; CliqHub raises some
      itself. This is not

      the live run timeline (that is Runs).
paths:
  /v1/events/custom/create:
    post:
      tags:
        - Events
      summary: Create a custom event type
      description: >-
        Registers a custom event type `custom.<name>` for a realm, so
        notification rules can be set for it before the first event arrives.


        Requires a realm operator (or higher) with the `rules.manage.realm`
        permission on the realm given by `realm_id`.
      operationId: POST_v1_events_custom_create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                event_type:
                  type: string
                  minLength: 1
                  pattern: ^custom\..+
                  description: Must be custom.<name>
                realm_id:
                  type: string
                  minLength: 1
                  description: Realm that owns this custom type
                label:
                  type: string
                  description: Optional display label
              required:
                - event_type
                - realm_id
            examples:
              default:
                value:
                  event_type: custom.security_finding
                  realm_id: 5b0c3a7e-2f4d-4b8e-9a51-7c1d2e3f4a5b
                  label: Security finding
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                    description: Always `true` on success.
                  event:
                    $ref: '#/components/schemas/CustomEventType'
                required:
                  - ok
              example:
                ok: true
                event:
                  id: 3e4f5a6b-7c8d-4e9f-8a0b-1c2d3e4f5a6b
                  event_type: custom.security_finding
                  source: manual
                  realm_id: 5b0c3a7e-2f4d-4b8e-9a51-7c1d2e3f4a5b
                  team_slug: null
                  label: Security finding
                  created_at: 1759000000000
        '401':
          description: >-
            `unauthorized`: No `Authorization` header, or the token is
            malformed, expired or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                unauthorized:
                  summary: unauthorized
                  value:
                    ok: false
                    error:
                      code: unauthorized
                      message: Authentication required
        '403':
          description: >-
            `forbidden`: You can see the realm but your role there is too low or
            lacks the required permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                forbidden:
                  summary: forbidden
                  value:
                    ok: false
                    error:
                      code: forbidden
                      message: You do not have access to do this
        '404':
          description: >-
            `not_found`: The realm does not exist, was deleted, or you are not a
            member of it (404 rather than 403, so its existence is not
            revealed).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                not_found:
                  summary: not_found
                  value:
                    ok: false
                    error:
                      code: not_found
                      message: Not found
        '409':
          description: '`conflict`: The realm already has this event type.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                conflict:
                  summary: conflict
                  value:
                    ok: false
                    error: >-
                      Event 'custom.security_finding' already exists in this
                      realm.
                    code: conflict
        '422':
          description: >-
            `invalid_params`: The body fails the request schema: a field is
            missing or has the wrong type. `details.issues` lists each problem.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                invalid_params:
                  summary: invalid_params
                  value:
                    ok: false
                    error: Required
                    code: invalid_params
                    details:
                      issues:
                        - field: event_type
                          message: Required
        '500':
          description: >-
            `internal_error`: An unexpected server fault. Retry later; if it
            persists, report it with the time of the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                internal_error:
                  summary: internal_error
                  value:
                    ok: false
                    error: Internal server error
                    code: internal_error
      security:
        - BearerAuth: []
components:
  schemas:
    CustomEventType:
      type: object
      properties:
        id:
          type: string
        event_type:
          type: string
          example: custom.security_finding
        source:
          type: string
          enum:
            - declared
            - manual
            - observed
          description: >-
            Where it came from: a team's manifest, created here, or seen in a
            submitted event.
        realm_id:
          type: string
          nullable: true
        team_slug:
          type: string
          nullable: true
        label:
          type: string
          nullable: true
        created_at:
          type: number
    HubErr:
      type: object
      required:
        - ok
        - error
      description: >-
        Every failure. Route-policy denials (401/403/404, and 400 when neither
        realm_id nor org_id was sent) answer `error` as `{ code, message }`;
        errors raised by the endpoint answer `error` as the message with the
        code beside it in `code`. Every error has a code. See
        [Errors](/hub-api/errors).
      properties:
        ok:
          type: boolean
          description: Always false on error
        error:
          description: The message, or `{ code, message }` for an access denial.
          oneOf:
            - type: string
            - type: object
              required:
                - code
                - message
              properties:
                code:
                  type: string
                message:
                  type: string
        code:
          type: string
          description: Stable error code of an endpoint error.
        details:
          type: object
          additionalProperties: true
          description: Structured detail, when there is some.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: cliq_tok_* | cliq_dt_*
      description: >-
        User PAT (`cliq_tok_…`, including session-scoped) or realm token
        (`cliq_dt_…`).

````

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