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

# Create a new task

> Use when submitting a file or job for async processing (e.g. export or import). Returns task ID to poll for status and result.



## OpenAPI

````yaml /api-reference/openapi.json post /tasks
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
security: []
paths:
  /tasks:
    post:
      tags:
        - Tasks
      summary: Create a new task
      description: >-
        Use when submitting a file or job for async processing (e.g. export or
        import). Returns task ID to poll for status and result.
      operationId: createTask
      requestBody:
        description: Task configuration
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskRequest'
        required: true
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateTaskRequest:
      required:
        - entity_type
        - file_type
        - file_url
        - task_type
      type: object
      properties:
        entity_type:
          $ref: '#/components/schemas/types.EntityType'
        file_name:
          type: string
        file_type:
          $ref: '#/components/schemas/types.FileType'
        file_url:
          type: string
        metadata:
          type: object
          additionalProperties: true
        task_type:
          $ref: '#/components/schemas/types.TaskType'
    TaskResponse:
      type: object
      properties:
        completed_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        entity_type:
          $ref: '#/components/schemas/types.EntityType'
        environment_id:
          type: string
        error_summary:
          type: string
        failed_at:
          type: string
          format: date-time
        failed_records:
          type: integer
        file_name:
          type: string
        file_type:
          $ref: '#/components/schemas/types.FileType'
        file_url:
          type: string
        id:
          type: string
        metadata:
          type: object
          additionalProperties: true
        processed_records:
          type: integer
        scheduled_task_id:
          type: string
        started_at:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        successful_records:
          type: integer
        task_status:
          $ref: '#/components/schemas/types.TaskStatus'
        task_type:
          $ref: '#/components/schemas/types.TaskType'
        tenant_id:
          type: string
        total_records:
          type: integer
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
        workflow_id:
          type: string
    errors.ErrorResponse:
      type: object
      properties:
        code:
          type: string
          enum:
            - not_found
            - already_exists
            - version_conflict
            - validation_error
            - invalid_operation
            - permission_denied
            - http_client_error
            - database_error
            - system_error
            - internal_error
            - service_unavailable
        details:
          type: object
          additionalProperties:
            type: object
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    types.EntityType:
      type: string
      enum:
        - EVENTS
        - PRICES
        - CUSTOMERS
        - FEATURES
      x-enum-varnames:
        - EntityTypeEvents
        - EntityTypePrices
        - EntityTypeCustomers
        - EntityTypeFeatures
      x-speakeasy-name-override: EntityType
    types.FileType:
      type: string
      enum:
        - CSV
        - JSON
      x-enum-varnames:
        - FileTypeCSV
        - FileTypeJSON
      x-speakeasy-name-override: FileType
    types.TaskType:
      type: string
      enum:
        - IMPORT
        - EXPORT
      x-enum-varnames:
        - TaskTypeImport
        - TaskTypeExport
      x-speakeasy-name-override: TaskType
    types.Status:
      type: string
      enum:
        - published
        - deleted
        - archived
      x-enum-varnames:
        - StatusPublished
        - StatusDeleted
        - StatusArchived
      x-speakeasy-name-override: Status
    types.TaskStatus:
      type: string
      enum:
        - PENDING
        - PROCESSING
        - COMPLETED
        - FAILED
      x-enum-varnames:
        - TaskStatusPending
        - TaskStatusProcessing
        - TaskStatusCompleted
        - TaskStatusFailed
      x-speakeasy-name-override: TaskStatus
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````