---
title: "Import Microdata files"
method: POST
path: "/jobs/import_microdata/{project_id}"
tags: ["Job Types"]
---

# Import Microdata files

`POST /jobs/import_microdata/{project_id}`

## Request

- Base URL: `https://localhost/index.php/api`
- URL: `https://localhost/index.php/api/jobs/import_microdata/{project_id}`
- Auth: API key in header `X-API-Key`
- TypeScript: <https://skmtc.dev/worldbank/apis/metadata-editor-jobs-api/docs/jobs/import_microdata/:project_id/post.ts> (a function with typed inputs; its response is checked against the schema)

Upload and import a data file in one step (multipart/form-data). Creates an import_microdata background job after upload. Equivalent to uploading separately then POST /jobs with job_type import_microdata and payload file_id + project_id.

## Path parameters

- `project_id` string, required

## Request body `multipart/form-data`

- object
  - `file` string, binary, required: The data file to upload (CSV, DTA, SAV, etc.)
  - `overwrite` 0 | 1: Whether to overwrite existing file (0 or 1)
  - `store_data` 'store' | 'remove': Whether to store data ("store" or "remove")
  - `description` string: File description (datafile-schema.json)
  - `producer` string: File producer
  - `data_checks` string: Processing / data checks
  - `missing_data` string: Missing data documentation
  - `version` string: File version
  - `notes` string: File notes
  - `priority` integer: Job queue priority; higher values are processed before lower ones

## Response `201`

File uploaded and job created successfully

- ImportMicrodataJobResponse: Response from import_microdata endpoint (upload + job creation)
  - `status` string
  - `message` string
  - `file_id` string: ID of the uploaded file
  - `uuid` string: UUID of the created import job
  - `job` Job: Job object
    - `uuid` string
    - `job_type` 'generate_pdf' | 'generate_microdata_resource' | 'import_microdata' | 'import_indicator_data' | 'publish_project' | 'hello_world': Registered background job type identifier
    - `status` 'pending' | 'held' | 'processing' | 'completed' | 'failed': Current job status
    - `priority` integer: Job priority
    - `user_id` integer: User who initiated the job (NULL for system jobs)
    - `payload` union: Job-specific parameters; shape depends on job_type (see *JobPayload schemas)
      - GeneratePdfJobPayload: Payload for PDF generation job (used in generic /jobs endpoint)
        - `project_id` integer, required: Project ID for which to generate the PDF
        - `options` object: Optional PDF generation options
          - `template` string: PDF template to use (optional)
          - `format` string: PDF format options (optional)
      - GenerateMicrodataResourceJobPayload: Payload for generate_microdata_resource job (used in generic /jobs endpoint)
        - `project_id` integer, required: Project ID (sid)
        - `export_format` string, required: csv, dta, sav, xpt, or json
        - `export_version` string: Stata version when export_format is dta
        - `file_ids` string[]
        - `zip` boolean
        - `overwrite` boolean
        - `resource_id` integer: Regenerate an existing generated resource
        - `refresh_description` boolean
        - `max_wait_seconds` integer
      - ImportMicrodataJobPayload: Payload for microdata import job
        - `file_id` string, required: File ID of the uploaded data file to import
        - `project_id` string, required: Project ID where the data will be imported
      - ImportIndicatorDataJobPayload: Payload for import_indicator_data job (used in generic /jobs endpoint)
        - `project_id` integer, required: Project sid
        - `upload_id` string, required: Completed resumable upload ID
        - `indicator_value` string, required
        - `delimiter` string
        - `keep_extra_csv_columns` boolean
      - PublishProjectJobPayload: Payload for publish_project job (used in generic /jobs endpoint)
        - `project_id` union, required
          - integer
          - string
        - `catalog_connection_id` integer, required
        - `user_id` integer, required: User performing the publish (set automatically by convenience endpoint)
        - `publish_metadata` boolean
        - `publish_thumbnail` boolean
        - `publish_resources` boolean
        - `publish_dsd` boolean
        - `dsd_overwrite` boolean
        - `publish_indicator_data` boolean
        - `delete_nada_resources` boolean
        - `options` object
      - HelloWorldJobPayload: Payload for hello_world job (testing/demo; POST /jobs only)
        - `message` string: Optional greeting message
    - `result` union: Job result when completed; shape depends on job_type (see *JobResult schemas)
      - GeneratePdfJobResult: Result returned when PDF generation job completes successfully
        - `pdf_path` string: File path to the generated PDF
        - `project_id` integer: Project ID for which the PDF was generated
        - `generated_at` string, date-time: Timestamp when PDF was generated
      - GenerateMicrodataResourceJobResult: Result returned when microdata resource generation job completes
        - `status` 'success' | 'skipped'
        - `project_id` integer
        - `export_format` string
        - `resource_id` integer
        - `filename` string
        - `links_count` integer
        - `message` string: Present when status is skipped (resource already exists)
      - ImportMicrodataJobResult: Result returned when microdata import job completes successfully
        - `fastapi_job_id` string: FastAPI processing job ID
        - `file_id` string: File ID that was imported
        - `project_id` union: Project ID where data was imported
          - string
          - integer
        - `datafile_path` string: Path to the processed data file
        - `variables_imported` integer: Number of variables imported from the data dictionary
        - `case_count` integer, nullable: Row count from the data dictionary
        - `csv_file` string, nullable: Basename of the CSV file after cleanup
        - `fastapi_status` string
        - `message` string
      - ImportIndicatorDataJobResult: Result returned when indicator data import job completes successfully
        - `status` string
        - `indicator_value` string
        - `job_id` string: FastAPI replace-from-csv job ID
      - PublishProjectJobResult: Result returned when publish_project job completes
        - `results` object: Per-step publish outcomes (metadata, thumbnail, resources, dsd, etc.)
        - `errors` object: Non-fatal step errors keyed by step name
        - `project_id` union
          - integer
          - string
        - `catalog_connection_id` integer
        - `published_at` string, date-time
      - HelloWorldJobResult: Result returned when hello_world job completes
        - `message` string
        - `processed_at` string, date-time
        - `job_id` integer: Internal job queue ID
    - `error_message` string: Error details if job failed
    - `attempts` integer: Number of processing attempts
    - `max_attempts` integer: Maximum retry attempts
    - `created_at` string, date-time: Job creation timestamp
    - `started_at` string, date-time: Job processing start timestamp (null if not started)
    - `completed_at` string, date-time: Job completion timestamp (null if not completed)
    - `worker_id` string: Worker identifier processing this job (null if not processing)
  - `upload_result` object: File upload result details
    - `uploaded` object
      - `uploaded_file_name` string
      - `base64` string
    - `file_id` string

## Other responses

- `400`: Bad request (invalid file, project not found, etc.)

## Changes

- **2026-06-06** `7f334b22fc50`: 4 breaking, 6 warning
  - added `#/components/schemas/GeneratePdfJobPayload, #/components/schemas/GenerateMicrodataResourceJobPayload, #/components/schemas/ImportMicrodataJobPayload, #/components/schemas/ImportIndicatorDataJobPayload, #/components/schemas/PublishProjectJobPayload, #/components/schemas/HelloWorldJobPayload` to the `job/payload` response property `oneOf` list for the response status `201`
  - added `#/components/schemas/GeneratePdfJobResult, #/components/schemas/GenerateMicrodataResourceJobResult, #/components/schemas/ImportMicrodataJobResult, #/components/schemas/ImportIndicatorDataJobResult, #/components/schemas/PublishProjectJobResult, #/components/schemas/HelloWorldJobResult` to the `job/result` response property `oneOf` list for the response status `201`
  - the `job/payload` response's property type changed from `object` to no type for status `201`
  - the `job/result` response's property type changed from `object` to no type for status `201`
  - …6 more
- **2026-05-24** `1ff58dcd71a4`: 1 warning, 1 info
  - added the new `held` enum value to the `job/status` response property for the response status `201`
  - added the new optional request property `priority`
- …earlier changes not shown

[Operation history](https://skmtc.dev/worldbank/apis/metadata-editor-jobs-api/changes/jobs/import_microdata/:project_id/post.md)

---

[API](https://skmtc.dev/worldbank/apis/metadata-editor-jobs-api.md) - [All operations](https://skmtc.dev/worldbank/apis/metadata-editor-jobs-api/llms.txt) - [OpenAPI document](https://skmtc.dev/worldbank/apis/metadata-editor-jobs-api/revisions/755536b6492e?raw)
