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

# Create a new custom event

> Create a new custom event.



## OpenAPI

````yaml /openapi/admin.json post /events/custom
openapi: 3.1.0
info:
  title: Nudj Admin API
  version: 1.0.0
servers:
  - url: https://{subdomain}.nudj.cx/api/v2/admin
    description: Organization API Server
    variables:
      subdomain:
        description: Your organization's subdomain (required)
        default: your-org
security:
  - ApiToken: []
paths:
  /events/custom:
    post:
      tags:
        - Event
      summary: Create a new custom event
      description: Create a new custom event.
      operationId: createCustomEvent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                eventName:
                  type: string
                  description: The name of the custom event
                communityId:
                  type:
                    - string
                    - 'null'
                  pattern: ^[0-9a-fA-F]{24}$
                  description: The community that the event belongs to
                payload:
                  type: object
                  description: >-
                    The payload of the event. An object made up of any key,
                    value pairs you want to store with the event.
                userId:
                  type: string
                  description: >-
                    The Nudj ID or the external ID of the user to log the event
                    for
                autoCreateUser:
                  type: boolean
                  default: false
                  description: Whether to automatically create a user if they don't exist
                nonce:
                  type: string
                  minLength: 1
              required:
                - eventName
                - payload
                - userId
                - nonce
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/EventCustom'
                type: object
                properties:
                  userId:
                    type: string
                    pattern: ^[0-9a-fA-F]{24}$
                    description: The Nudj ID of the user the event has been logged for
                  externalUserId:
                    type: string
                    description: The external ID of the user the event has been logged for
                required:
                  - userId
                description: >-
                  The payload of the event. An object made up of any key, value
                  pairs you want to store with the event.
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
components:
  schemas:
    EventCustom:
      type: object
      properties:
        name:
          type: string
          description: The name of the custom event
      required:
        - name
      description: A custom event
      title: Custom Event
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Invalid input data
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Internal server error
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
  securitySchemes:
    ApiToken:
      type: apiKey
      in: header
      name: x-api-token

````