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

# Import a CSV of usage events

> Use to submit a CSV of usage events for async ingestion. The CSV must already have been uploaded to the Tirdad-managed imports bucket (currently via CSV Box) — pass the upload_id and the backend fetches the file from S3 and streams rows into ClickHouse. Returns the task ID and Temporal workflow IDs for polling.



## OpenAPI

````yaml /api-reference/openapi.json post /tasks
openapi: 3.0.1
info:
  title: Tirdad API
  description: Tirdad API Service
  contact:
    name: API Support
  version: '1.0'
servers:
  - url: https://api.tirdad.ai/v1
    description: Tirdad API
security: []
paths:
  /tasks:
    post:
      tags:
        - Tasks
      summary: Import a CSV of usage events
      description: >-
        Use to submit a CSV of usage events for async ingestion. The CSV must
        already have been uploaded to the Tirdad-managed imports bucket
        (currently via CSV Box) — pass the upload_id and the backend fetches the
        file from S3 and streams rows into ClickHouse. Returns the task ID and
        Temporal workflow IDs for polling.
      operationId: createTask
      requestBody:
        description: Import request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.TemporalWorkflowResult'
        '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: []
      x-codeSamples:
        - lang: go
          label: Go
          source: "package main\n\nimport(\n\t\"context\"\n\ttirdad \"github.com/tirdad-billing/go-sdk/v2\"\n\t\"github.com/tirdad-billing/go-sdk/v2/models/types\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := tirdad.New(\n        tirdad.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n    )\n\n    res, err := s.Tasks.CreateTask(ctx, types.CreateTaskRequest{\n        EntityType: types.EntityTypeFeatures,\n        FileProvider: \"<value>\",\n        FileType: types.FileTypeJSON,\n        TaskType: types.TaskTypeExport,\n        UploadID: \"<id>\",\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.ModelsTemporalWorkflowResult != nil {\n        // handle response\n    }\n}"
        - lang: python
          label: Python
          source: |-
            from tirdad_sdk import Tirdad


            with Tirdad(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as f_client:

                res = f_client.tasks.create_task(entity_type="FEATURES", file_provider="<value>", file_type="JSON", task_type="EXPORT", upload_id="<id>")

                # Handle response
                print(res)
        - lang: typescript
          label: TypeScript
          source: |-
            import { Tirdad } from "@tirdad/sdk";

            const tirdad = new Tirdad({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await tirdad.tasks.createTask({
                entityType: "FEATURES",
                fileProvider: "<value>",
                fileType: "JSON",
                taskType: "EXPORT",
                uploadId: "<id>",
              });

              console.log(result);
            }

            run();
components:
  schemas:
    CreateTaskRequest:
      required:
        - entity_type
        - file_provider
        - file_type
        - task_type
        - upload_id
      type: object
      properties:
        entity_type:
          $ref: '#/components/schemas/types.EntityType'
        file_name:
          type: string
        file_provider:
          type: string
        file_type:
          $ref: '#/components/schemas/types.FileType'
        metadata:
          type: object
          additionalProperties: true
        task_type:
          $ref: '#/components/schemas/types.TaskType'
        upload_id:
          type: string
    models.TemporalWorkflowResult:
      type: object
      properties:
        message:
          type: string
        run_id:
          type: string
        workflow_id:
          type: string
    errors.ErrorResponse:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/errors.ErrorCode'
        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
    errors.ErrorCode:
      type: string
      enum:
        - http_client_error
        - system_error
        - internal_error
        - not_found
        - already_exists
        - version_conflict
        - validation_error
        - invalid_operation
        - permission_denied
        - database_error
        - service_unavailable
        - too_many_requests
        - not_implemented
      x-enum-varnames:
        - ErrCodeHTTPClient
        - ErrCodeSystemError
        - ErrCodeInternalError
        - ErrCodeNotFound
        - ErrCodeAlreadyExists
        - ErrCodeVersionConflict
        - ErrCodeValidation
        - ErrCodeInvalidOperation
        - ErrCodePermissionDenied
        - ErrCodeDatabase
        - ErrCodeServiceUnavailable
        - ErrCodeTooManyRequests
        - ErrCodeNotImplemented
      x-speakeasy-name-override: ErrorCode
  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

````

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