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

# Create an export

> Generate a downloadable CSV or JSONL file with the complete filtered dataset of one entity (up to 100,000 rows). Runs as an async job: the request waits inline up to `Prefer: wait=N` seconds (default 20, max 55) and returns `200 { data }` with the download URL if the file is ready in time; otherwise it returns `202` with a job envelope to poll at `GET /jobs/{id}` (or delivers it to `callback_url`). The URL expires 24 hours after completion.



## OpenAPI

````yaml legal/openapi.json POST /v1/exports
openapi: 3.1.0
info:
  title: Croma Legal API
  version: 1.0.0
  description: >-
    Read-only access to your organization's litigation portfolio in Croma Legal:
    cases (processes), actuaciones, defendants, portfolio analytics and bulk
    exports. Every request is scoped to the organization that owns the API key.
servers:
  - url: https://api.legal.usecroma.com
security:
  - bearerAuth: []
tags:
  - name: Processes
    description: Cases in your portfolio.
  - name: Actuaciones
    description: Court filings and events across every case.
  - name: Defendants
    description: Demandados and the cases linked to them.
  - name: Analytics
    description: Aggregates over the portfolio.
  - name: Exports
    description: Bulk CSV / JSONL files.
  - name: Jobs
    description: Async job status.
paths:
  /v1/exports:
    post:
      tags:
        - Exports
      summary: Create an export
      description: >-
        Generate a downloadable CSV or JSONL file with the complete filtered
        dataset of one entity (up to 100,000 rows). Runs as an async job: the
        request waits inline up to `Prefer: wait=N` seconds (default 20, max 55)
        and returns `200 { data }` with the download URL if the file is ready in
        time; otherwise it returns `202` with a job envelope to poll at `GET
        /jobs/{id}` (or delivers it to `callback_url`). The URL expires 24 hours
        after completion.
      operationId: create_export
      parameters:
        - name: Prefer
          in: header
          required: false
          description: >-
            `wait=N`: seconds to wait inline before returning `202` (default 20,
            max 55). `wait=0` returns `202` immediately.
          schema:
            type: string
          example: wait=30
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportRequest'
            example:
              entity: processes
              format: csv
              filters:
                status: TRACKING
                date_from: '2024-01-01'
      responses:
        '200':
          description: Successful response
          headers:
            X-Request-Id:
              description: >-
                Unique id for the request (req_…). Include it in support
                reports.
              schema:
                type: string
            X-RateLimit-Limit:
              description: Requests allowed in the current window.
              schema:
                type: integer
            X-RateLimit-Remaining:
              description: Requests left before you are throttled.
              schema:
                type: integer
            X-RateLimit-Reset:
              description: ISO 8601 timestamp when the window resets.
              schema:
                type: string
                format: date-time
            X-Job-Id:
              description: The job id.
              schema:
                type: string
            Preference-Applied:
              description: Echoes the inline wait that was applied, e.g. `wait=20`.
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: '#/components/schemas/ExportResult'
              example:
                data:
                  url: >-
                    https://files.usecroma.com/legal-exports/processes-2026-08-21.csv
                  entity: processes
                  format: csv
                  rows: 1280
                  bytes: 418233
                  truncated: false
                  expires_at: '2026-08-22T14:03:10.000Z'
        '202':
          description: >-
            Accepted: the file was not ready within the wait. Poll
            `job.status_url` (also in `Location`), or wait for the callback if
            you sent `callback_url`.
          headers:
            X-Request-Id:
              description: >-
                Unique id for the request (req_…). Include it in support
                reports.
              schema:
                type: string
            X-RateLimit-Limit:
              description: Requests allowed in the current window.
              schema:
                type: integer
            X-RateLimit-Remaining:
              description: Requests left before you are throttled.
              schema:
                type: integer
            X-RateLimit-Reset:
              description: ISO 8601 timestamp when the window resets.
              schema:
                type: string
                format: date-time
            Location:
              description: The job's `status_url`.
              schema:
                type: string
                format: uri
            Retry-After:
              description: Suggested seconds before polling.
              schema:
                type: integer
            X-Job-Id:
              description: The job id.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobEnvelope'
              example:
                job:
                  id: run_abc123def456
                  status: running
                  endpoint: /v1/exports
                  created_at: '2026-08-21T14:03:10.000Z'
                  finished_at: null
                  status_url: https://api.legal.usecroma.com/jobs/run_abc123def456
                data: null
                error: null
        '400':
          description: Invalid body
          headers:
            X-Request-Id:
              description: >-
                Unique id for the request (req_…). Include it in support
                reports.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error:
                  type: invalid_request_error
                  code: invalid_param
                  message: >-
                    Invalid option: expected one of
                    "processes"|"actions"|"defendants"
                  param: entity
                  details:
                    issues:
                      - path: entity
                        message: >-
                          Invalid option: expected one of
                          "processes"|"actions"|"defendants"
        '401':
          description: Missing or invalid API key
          headers:
            X-Request-Id:
              description: >-
                Unique id for the request (req_…). Include it in support
                reports.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error:
                  type: authentication_error
                  code: invalid_api_key
                  message: Invalid or missing API key.
        '429':
          description: Rate limit exceeded
          headers:
            X-Request-Id:
              description: >-
                Unique id for the request (req_…). Include it in support
                reports.
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error:
                  type: rate_limit_error
                  code: rate_limited
                  message: Rate limit exceeded. Try again in 42 seconds.
        '500':
          description: Unexpected internal error
          headers:
            X-Request-Id:
              description: >-
                Unique id for the request (req_…). Include it in support
                reports.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error:
                  type: api_error
                  code: internal_error
                  message: >-
                    Internal error. Contact support with the X-Request-Id if it
                    persists.
        '502':
          description: The export job failed
          headers:
            X-Request-Id:
              description: >-
                Unique id for the request (req_…). Include it in support
                reports.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error:
                  type: api_error
                  code: job_failed
                  message: The job could not be completed.
      security:
        - bearerAuth: []
      externalDocs:
        description: Guide and examples
        url: https://docs.usecroma.com/legal/exports
components:
  schemas:
    ExportRequest:
      type: object
      required:
        - entity
      additionalProperties: false
      properties:
        entity:
          type: string
          enum:
            - processes
            - actions
            - defendants
          description: Dataset to export.
        format:
          type: string
          enum:
            - csv
            - jsonl
          default: csv
          description: >-
            `csv` (UTF-8 with BOM, Excel-friendly) or `jsonl` (one JSON object
            per line).
        filters:
          $ref: '#/components/schemas/ExportFilters'
        callback_url:
          type: string
          format: uri
          description: >-
            Public HTTPS URL to `POST` the finished job envelope to. When set,
            the request returns `202` immediately.
    ExportResult:
      type: object
      required:
        - url
        - entity
        - format
        - rows
        - bytes
        - truncated
        - expires_at
      properties:
        url:
          type: string
          format: uri
          description: >-
            Download URL. Unguessable, but not authenticated: anyone holding it
            can download the file until it expires.
        entity:
          type: string
          enum:
            - processes
            - actions
            - defendants
        format:
          type: string
          enum:
            - csv
            - jsonl
        rows:
          type: integer
          description: Rows written to the file.
        bytes:
          type: integer
          description: File size in bytes.
        truncated:
          type: boolean
          description: >-
            `true` when the 100,000-row cap was hit; the file is then not the
            complete dataset. Narrow the filters and export again.
        expires_at:
          type: string
          format: date-time
          description: >-
            The URL is guaranteed until this time (24 hours after completion)
            and removed shortly after.
    JobEnvelope:
      type: object
      required:
        - job
        - data
        - error
      description: >-
        Returned by `POST /v1/exports` (202) and by `GET /jobs/{id}`. `data`
        holds the export result once `status` is `completed`; `error` is
        populated once `status` is `failed`.
      properties:
        job:
          type: object
          required:
            - id
            - status
            - endpoint
            - created_at
            - finished_at
            - status_url
          properties:
            id:
              type: string
            status:
              type: string
              enum:
                - queued
                - running
                - completed
                - failed
                - canceled
                - expired
            endpoint:
              type: string
              description: The endpoint path that created this job.
            created_at:
              type:
                - string
                - 'null'
              format: date-time
            finished_at:
              type:
                - string
                - 'null'
              format: date-time
            status_url:
              type: string
              format: uri
              description: GET this URL to poll the job.
        data:
          description: The export result once completed; null until then.
          oneOf:
            - $ref: '#/components/schemas/ExportResult'
            - type: 'null'
        error:
          description: Populated once the job has failed; null otherwise.
          oneOf:
            - type: object
              required:
                - type
                - code
                - message
              properties:
                type:
                  type: string
                code:
                  type: string
                message:
                  type: string
            - type: 'null'
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
          properties:
            type:
              type: string
              description: >-
                Broad category: invalid_request_error, authentication_error,
                not_found_error, rate_limit_error, api_error.
            code:
              type: string
              description: Machine-readable specific code.
            message:
              type: string
              description: Human-readable explanation, safe to surface in UI.
            param:
              type: string
              description: Field that triggered the error. Present on validation errors.
            details:
              type: object
              description: Free-form structured detail.
    ExportFilters:
      type: object
      additionalProperties: false
      description: >-
        Same names as the list endpoints' query params. One flat object for
        every entity: filters that do not apply to the chosen entity are
        ignored.
      properties:
        q:
          type: string
          description: >-
            Partial match on the registration number (radicado). Processes and
            actions.
        status:
          type: string
          enum:
            - TRACKING
            - NOT_TRACKING
          description: Processes only.
        priority:
          type: string
          enum:
            - HIGH
            - MEDIUM
            - NONE
          description: Processes only. See the note on priority in `GET /v1/processes`.
        defendant:
          type: string
          description: Partial match on the defendant name. Processes and actions.
        defendant_id:
          type: string
          description: >-
            Partial match on the defendant identification number. Processes and
            actions.
        office:
          type: string
          description: Partial match on the judicial office. Processes and actions.
        date_from:
          type: string
          format: date
          description: 'ISO 8601. Processes: filing date >=. Actions: judicial date >=.'
        date_to:
          type: string
          format: date
          description: 'ISO 8601. Processes: filing date <=. Actions: judicial date <=.'
        has_actions:
          type: boolean
          description: Processes only.
        content:
          type: string
          description: 'Actions only: keyword in the actuación text.'
        since:
          type: string
          format: date
          description: 'Actions only: only actuaciones recorded on or after this date.'
        source:
          type: string
          description: 'Actions only: public source the actuación was recorded from.'
        name:
          type: string
          description: 'Defendants only: partial match on the name.'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Use Authorization: Bearer YOUR_API_KEY'

````