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

# Create a new event

> Endpoint to create a new event using public API.



## OpenAPI

````yaml https://app-api.costory.io/docs/openapi.json post /public/events
openapi: 3.0.0
info:
  title: Costory
  version: '1.0'
  description: API Documentation
servers:
  - url: ''
    description: Production server
security: []
paths:
  /public/events:
    post:
      tags:
        - Events
      summary: Create a new event
      description: Endpoint to create a new event using public API.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExternalEventRequest'
      responses:
        '201':
          description: Event created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateEventSuccess'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateEventBadRequest'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
      security:
        - apiKeyAuth: []
components:
  schemas:
    ExternalEventRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 5
          description: Name of the event (minimum 5 characters)
        date:
          type: string
          nullable: true
          format: date-time
          description: Date of the event (ISO 8601 format or parseable date string)
        description:
          type: string
          description: Detailed description of the event
        tags:
          type: array
          items:
            type: string
          maxItems: 5
          description: Tags for the event (maximum 5)
        labels:
          type: array
          items:
            type: string
          maxItems: 5
          description: Deprecated alias for tags. Ignored when tags is sent.
        category:
          type: string
          description: Deprecated. If sent, merged into tags then discarded.
        metadata:
          type: object
          additionalProperties: {}
          default:
            event: 'Merged PR #123'
            owner: John Doe
            link: https://gitlab.com/your_org/repo/merge_requests/123
          description: >-
            Additional metadata about the event (key-value pairs). Example:
            event, owner, link
      required:
        - name
        - date
        - description
    CreateEventSuccess:
      type: object
      properties:
        id:
          type: string
          description: The unique identifier of the created event
      required:
        - id
    CreateEventBadRequest:
      type: object
      properties:
        error:
          type: string
          description: Error message
        reason:
          type: string
          description: Reason for the error
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                description: Field name that caused the error
              message:
                type: string
                description: Error message for the field
              code:
                type: string
                description: Error code
            required:
              - field
              - message
              - code
          description: Detailed validation errors
        summary:
          type: string
          description: Summary of the error
      required:
        - error
    Unauthorized:
      type: object
      properties:
        error:
          type: string
          description: Unauthorized error message
      required:
        - error
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-token
      description: >-
        API token for authentication (or Admin API key). The token is scoped per
        organization and can be retrieved in the Organization Switcher.

````

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