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

# Bulk Create ITSM Tickets (Async)

> Create multiple ITSM tickets asynchronously.

Creates an async job to process the bulk ticket creation and returns immediately
with a job_id. Use GET /jobs/{job_id} to poll for job completion and results.

Request:
- tickets: List of 1-50 ticket creation requests

Response (202 Accepted):
- job_id: UUID to poll for job status and results

Job Status Polling:
- Use GET /jobs/{job_id} to check status
- Status flow: QUEUED → RUNNING → SUCCESS/FAILED
- On SUCCESS: all tickets were created; no per-ticket result data is returned
- On FAILED: job.failure_reason contains a JSON object with per-ticket breakdown:
  - total/succeeded/failed counts
  - results[]: per-ticket entries with success, error, request_index, identifier

This follows the vendor-first pattern:
1. Job creates tickets in the vendor system (e.g., JIRA) using bulk API
2. For each successful vendor creation, persists to local database

Performance: Returns immediately; processing happens asynchronously



## OpenAPI

````yaml post /itsm/tickets/bulk
openapi: 3.1.0
info:
  title: Leen Security API
  version: 0.0.1
servers:
  - url: https://api.leen.dev/v1
    description: Production API
  - url: https://api.eu-c1.leen.dev/v1
    description: Production API (EU Region)
  - url: https://api.ap-se2.leen.dev/v1
    description: Production Api (APAC Region)
security: []
paths:
  /itsm/tickets/bulk:
    post:
      tags:
        - ITSM
        - Tickets
      summary: Bulk Create ITSM Tickets (Async)
      description: >-
        Create multiple ITSM tickets asynchronously.


        Creates an async job to process the bulk ticket creation and returns
        immediately

        with a job_id. Use GET /jobs/{job_id} to poll for job completion and
        results.


        Request:

        - tickets: List of 1-50 ticket creation requests


        Response (202 Accepted):

        - job_id: UUID to poll for job status and results


        Job Status Polling:

        - Use GET /jobs/{job_id} to check status

        - Status flow: QUEUED → RUNNING → SUCCESS/FAILED

        - On SUCCESS: all tickets were created; no per-ticket result data is
        returned

        - On FAILED: job.failure_reason contains a JSON object with per-ticket
        breakdown:
          - total/succeeded/failed counts
          - results[]: per-ticket entries with success, error, request_index, identifier

        This follows the vendor-first pattern:

        1. Job creates tickets in the vendor system (e.g., JIRA) using bulk API

        2. For each successful vendor creation, persists to local database


        Performance: Returns immediately; processing happens asynchronously
      operationId: bulk_create_tickets
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ITSMTicketBulkCreateRequestModel'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobResponseModel'
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - Connection-ID: []
          API-Key: []
components:
  schemas:
    ITSMTicketBulkCreateRequestModel:
      properties:
        tickets:
          items:
            $ref: '#/components/schemas/ITSMTicketCreateRequestModel'
          type: array
          maxItems: 50
          minItems: 1
          title: Tickets
          description: List of tickets to create (1-50 items)
      type: object
      required:
        - tickets
      title: ITSM Ticket Bulk Create Request
    JobResponseModel:
      properties:
        job_id:
          type: string
          title: Job Id
          description: Job ID for tracking async operation status
      type: object
      required:
        - job_id
      title: JobResponseModel
      description: Response model for job creation endpoints that return a job ID.
    ErrorResponse:
      properties:
        type:
          type: string
          title: Type
          description: Type of error
        code:
          type: string
          title: Code
          description: Error code
        message:
          type: string
          title: Message
          description: Error message
        detail:
          items:
            type: object
          type: array
          title: Detail
          description: List of error dictionaries
      type: object
      required:
        - type
        - code
        - message
        - detail
      title: ErrorResponse
    ITSMTicketCreateRequestModel:
      properties:
        name:
          type: string
          title: Name
          description: Name/Title of the Ticket
        project_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Project Id
          description: >-
            Leen project UUID. Either project_id or project_vendor_id must be
            provided.
        project_vendor_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Vendor Id
          description: >-
            Vendor's project identifier (e.g., Jira project key 'PROJ').
            Alternative to project_id.
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
          description: Type of the Ticket (e.g., Task, Bug, Story)
        type_vendor_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Type Vendor Id
          description: >-
            Vendor issue type ID (e.g., Jira issue type ID). Alternative to type
            — at least one must be provided. Preferred over type when both are
            given.
        type_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Type Id
          description: 'Deprecated: use type_vendor_id instead. Vendor issue type ID.'
          deprecated: true
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Description of the Ticket
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
          description: >-
            Status of the Ticket. Note: Jira does not support setting status at
            creation time — tickets are always created with the workflow's
            default status. Use the update endpoint to change status after
            creation.
        priority:
          anyOf:
            - type: string
            - type: 'null'
          title: Priority
          description: Priority of the Ticket
        assigned_user_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Assigned User Id
          description: >-
            Leen user UUID. Either assigned_user_id or assigned_user_vendor_id
            can be provided.
        assigned_user_vendor_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Assigned User Vendor Id
          description: >-
            Vendor's user identifier (e.g., Jira accountId). Alternative to
            assigned_user_id.
        parent_ticket_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Parent Ticket Id
          description: Parent Ticket ID (for sub-tasks)
        parent_ticket_vendor_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Ticket Vendor Id
          description: >-
            Vendor's ticket identifier (e.g., Jira issue key 'PROJ-123').
            Alternative to parent_ticket_id.
        identifier:
          anyOf:
            - type: string
            - type: 'null'
          title: Identifier
          description: >-
            User-provided tracking identifier (auto-generated from
            project-type-hash if not provided)
      type: object
      required:
        - name
      title: ITSM Ticket Create Request
  securitySchemes:
    Connection-ID:
      type: apiKey
      in: header
      name: X-CONNECTION-ID
    API-Key:
      type: apiKey
      in: header
      name: X-API-KEY

````