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

# Open a ticket

> Returns 201 when created and 200 when the externalId already exists (meta.duplicate is true).



## OpenAPI

````yaml /openapi/v2.json post /tickets
openapi: 3.1.0
info:
  title: Oktivo API v2
  version: 2.0.0
  description: >-
    Layered, database-agnostic API. Every success response is `{ success: true,
    requestId, timestamp, data, meta? }`; every error is `{ success: false,
    requestId, error: { code, message, details? } }`. Authenticate with an API
    token or a dashboard JWT as a Bearer token (same credentials as
    /api/v1/crm).
servers:
  - url: https://client-backend.oktivo.com/api/v2
security:
  - bearerAuth: []
tags:
  - name: Calls
  - name: Call queue
  - name: Events
  - name: Webhooks
  - name: Agents
  - name: Leads
  - name: Tickets
  - name: Shopify
  - name: Operations
paths:
  /tickets:
    post:
      tags:
        - Tickets
      summary: Open a ticket
      description: >-
        Returns 201 when created and 200 when the externalId already exists
        (meta.duplicate is true).
      operationId: createTicket
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - $ref: '#/components/parameters/RequestId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                subject:
                  type: string
                  maxLength: 300
                description:
                  type: string
                  maxLength: 20000
                phone:
                  type: string
                  maxLength: 32
                email:
                  type: string
                  format: email
                  maxLength: 254
                name:
                  type: string
                  maxLength: 200
                externalId:
                  type: string
                  maxLength: 200
              additionalProperties: false
      responses:
        '200':
          description: Duplicate of an existing ticket
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
            Idempotent-Replay:
              $ref: '#/components/headers/Idempotent-Replay'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Envelope'
        '201':
          description: Ticket created
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
            Idempotent-Replay:
              $ref: '#/components/headers/Idempotent-Replay'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Envelope'
        '401':
          description: Missing or invalid credentials
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Authenticated but not allowed (feature not enabled for the account)
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            An identical request with this Idempotency-Key is still in progress,
            or the resource conflicts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          headers:
            Retry-After:
              $ref: '#/components/headers/Retry-After'
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        8-128 chars of [A-Za-z0-9_.:-]. Same key and body replays the stored
        response for 24h; same key with another body returns 422.
      schema:
        type: string
        pattern: ^[\w.:-]{8,128}$
    RequestId:
      name: X-Request-ID
      in: header
      required: false
      description: >-
        Correlation id (1-128 chars of [A-Za-z0-9_.-]). Echoed in the response;
        generated when absent or unsafe.
      schema:
        type: string
        pattern: ^[\w.-]{1,128}$
  headers:
    RateLimit-Limit:
      description: Requests allowed in the current window
      schema:
        type: integer
    RateLimit-Remaining:
      description: Requests left in the current window
      schema:
        type: integer
    RateLimit-Reset:
      description: Seconds until the window resets
      schema:
        type: integer
    X-Request-ID:
      description: Correlation id of this request
      schema:
        type: string
    Idempotent-Replay:
      description: >-
        true when the response was replayed from a previous request with the
        same Idempotency-Key
      schema:
        type: string
        enum:
          - 'true'
    Retry-After:
      description: Seconds to wait before retrying
      schema:
        type: integer
  schemas:
    Envelope:
      type: object
      required:
        - success
        - requestId
        - timestamp
        - data
      properties:
        success:
          type: boolean
          const: true
        requestId:
          type: string
        timestamp:
          type: string
          format: date-time
        data: {}
        meta:
          type: object
          additionalProperties: true
          description: 'Pagination: { limit, nextCursor } or { page, limit, total }'
    Error:
      type: object
      required:
        - success
        - requestId
        - error
      properties:
        success:
          type: boolean
          const: false
        requestId:
          type: string
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable machine-readable code, e.g. VALIDATION_ERROR
            message:
              type: string
            details: {}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API token (okt_...) or dashboard JWT

````

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