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

# Cancel Export

> Cancels an export, setting its `status` to `cancelled`. An export that has already `completed` cannot be cancelled; an already-cancelled export is returned unchanged.



## OpenAPI

````yaml /openapi.json post /v1/exports/{id}/cancel
openapi: 3.1.0
info:
  title: Flex API
  description: >-
    The Flex API powers HSA/FSA payment processing for healthcare commerce:
    checkout sessions, payment intents, subscriptions, customers, refunds,
    disputes, and eligibility. Authenticate with your partner API key as a
    Bearer token. All endpoints are scoped to your partner account, and test
    mode is fully supported via test API keys.
  version: 0.1.0
servers:
  - url: https://api.withflex.com
security:
  - BearerAuth: []
tags:
  - name: Balance Transactions
  - name: Captures
  - name: Checkout Sessions
  - name: Coupons
  - name: Customers
  - name: Disputes
  - name: Events
  - name: Exports
  - name: Files
  - name: Invoices
  - name: Letters
  - name: Orders
  - name: Payment Intents
  - name: Payment Links
  - name: Payouts
  - name: Prices
  - name: Products
  - name: Promo Codes
  - name: Receipts
  - name: Refunds
  - name: Setup Intents
  - name: Shipping Rates
  - name: Subscriptions
paths:
  /v1/exports/{id}/cancel:
    post:
      tags:
        - Exports
      summary: Cancel Export
      description: >-
        Cancels an export, setting its `status` to `cancelled`. An export that
        has already `completed` cannot be cancelled; an already-cancelled export
        is returned unchanged.
      operationId: v1.export.cancel
      parameters:
        - in: path
          name: id
          required: true
          schema:
            examples:
              - fxprt_01J9XR8M3K7VZ8N2YB4WJ6T0RA
            type: string
          style: simple
          example: fxprt_01J9XR8M3K7VZ8N2YB4WJ6T0RA
      responses:
        '200':
          description: An envelope wrapping a single export object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExportBody_for_Export'
              example:
                export:
                  export_id: fxprt_01J9XR8M3K7VZ8N2YB4WJ6T0RA
                  description: Premium SPF 50 mineral sunscreen
                  type: product
                  status: created
                  created_at: '2026-06-15T14:30:00Z'
                  started_at: '2026-06-15T14:30:00Z'
                  completed_at: '2026-06-15T14:30:00Z'
                  metadata:
                    order_id: '8842'
                    channel: shopify
                  test_mode: false
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorOut'
              example:
                code: string
                detail: string
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorOut'
              example:
                code: string
                detail: string
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorOut'
              example:
                code: string
                detail: string
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorOut'
              example:
                code: string
                detail: string
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
              example:
                detail:
                  - loc:
                      - string
                    msg: string
                    type: string
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpErrorOut'
              example:
                code: string
                detail: string
components:
  schemas:
    ExportBody_for_Export:
      description: An envelope wrapping a single export object.
      type: object
      required:
        - export
      properties:
        export:
          $ref: '#/components/schemas/Export'
          description: The Export object.
      example:
        export:
          export_id: fxprt_01J9XR8M3K7VZ8N2YB4WJ6T0RA
          description: Premium SPF 50 mineral sunscreen
          type: product
          status: created
          created_at: '2026-06-15T14:30:00Z'
          started_at: '2026-06-15T14:30:00Z'
          completed_at: '2026-06-15T14:30:00Z'
          metadata:
            order_id: '8842'
            channel: shopify
          test_mode: false
    HttpErrorOut:
      title: HttpError
      description: The error response returned when a request cannot be completed.
      type: object
      required:
        - code
        - detail
      properties:
        code:
          description: A short machine-readable error code identifying the type of error.
          type: string
        detail:
          description: A human-readable explanation of what went wrong.
          type: string
      example:
        code: string
        detail: string
    HTTPValidationError:
      description: The error response returned when request validation fails (HTTP 422).
      type: object
      required:
        - detail
      properties:
        detail:
          description: The list of validation errors, one entry per invalid field.
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
      example:
        detail:
          - loc:
              - string
            msg: string
            type: string
    Export:
      description: >-
        An Export represents an asynchronous request to generate a CSV file of
        your data, such as payments, subscriptions, customers, or reconciliation
        records. Create one to start the job, poll it until its `status` is
        `completed`, then request a presigned URL to download the file.
      type: object
      required:
        - created_at
        - export_id
        - status
        - test_mode
        - type
      properties:
        export_id:
          description: Unique identifier for the export.
          type: string
          example: fxprt_01J9XR8M3K7VZ8N2YB4WJ6T0RA
        description:
          description: >-
            An arbitrary description you can attach to the export for your own
            reference.
          type:
            - string
            - 'null'
          example: Premium SPF 50 mineral sunscreen
        type:
          $ref: '#/components/schemas/ExportType'
          description: The kind of data the export generates.
        status:
          $ref: '#/components/schemas/ExportStatus'
          description: >-
            The current state of the export job. The file is available to
            download only once the status is `completed`.
        created_at:
          $ref: '#/components/schemas/Timestamptz'
          description: Time at which the export was created, as an RFC 3339 timestamp.
          example: '2026-06-15T14:30:00Z'
        started_at:
          description: >-
            Time at which the export job began processing, as an RFC 3339
            timestamp. `null` until processing starts.
          anyOf:
            - $ref: '#/components/schemas/Timestamptz'
            - type: 'null'
          example: '2026-06-15T14:30:00Z'
        completed_at:
          description: >-
            Time at which the export job finished, as an RFC 3339 timestamp.
            `null` until the export completes.
          anyOf:
            - $ref: '#/components/schemas/Timestamptz'
            - type: 'null'
          example: '2026-06-15T14:30:00Z'
        metadata:
          description: >-
            Set of key-value pairs you can attach to the export for storing
            additional structured information.
          type:
            - object
            - 'null'
          example:
            order_id: '8842'
            channel: shopify
        filters:
          description: >-
            The criteria that restrict which records the export includes. `null`
            when no filter was supplied, in which case all records are exported.
          anyOf:
            - $ref: '#/components/schemas/Filters'
            - type: 'null'
        test_mode:
          description: >-
            Whether the export was created in test mode. `true` for test-mode
            exports, `false` for live-mode exports.
          type: boolean
          example: false
      example:
        export_id: fxprt_01J9XR8M3K7VZ8N2YB4WJ6T0RA
        description: Premium SPF 50 mineral sunscreen
        type: product
        status: created
        created_at: '2026-06-15T14:30:00Z'
        started_at: '2026-06-15T14:30:00Z'
        completed_at: '2026-06-15T14:30:00Z'
        metadata:
          order_id: '8842'
          channel: shopify
        filters:
          payment: {}
        test_mode: false
    ValidationErrorItem:
      description: >-
        Validation errors have their own schema to provide context for invalid
        requests eg. mismatched types and out of bounds values. There may be any
        number of these per 422 UNPROCESSABLE ENTITY error.
      type: object
      required:
        - loc
        - msg
        - type
      properties:
        loc:
          description: >-
            The location as a [`Vec`] of [`String`]s -- often in the form
            `["body", "field_name"]`, `["query", "field_name"]`, etc. They may,
            however, be arbitarily deep.
          type: array
          items:
            type: string
        msg:
          description: The message accompanying the validation error item.
          type: string
        type:
          description: >-
            The type of error, often "type_error" or "value_error", but
            sometimes with more context like as "value_error.number.not_ge"
          type: string
      example:
        loc:
          - string
        msg: string
        type: string
    ExportType:
      description: The type of records the export contains.
      type: string
      enum:
        - product
        - payment
        - subscription
        - customer
        - checkout_session
        - charge_reconciliation
        - payout
        - line_item
        - line_item_revenue
        - dispute
      example: product
    ExportStatus:
      description: The processing status of the export.
      type: string
      enum:
        - created
        - started
        - cancelled
        - failed
        - processing
        - completed
      example: created
    Timestamptz:
      description: >-
        A timestamp encoded as an RFC 3339 / ISO 8601 string (e.g.
        `2026-06-15T14:30:00Z`).
      type: string
      example: string
    Filters:
      description: >-
        Criteria that restrict which records an export includes. The filter
        variant must match the export's `type` (e.g. a `payment` export takes
        the `payment` filter); the unused criteria are ignored. When no filter
        is supplied, the export includes all of your records.
      example:
        payment:
          status: canceled
          starting_after: string
          ending_before: string
          customer: fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA
      type: object
      properties:
        payment:
          type: object
          properties:
            limit:
              description: Accepted but not currently applied to the export.
              type:
                - integer
                - 'null'
              format: int32
            status:
              description: Accepted but not currently applied to the export.
              anyOf:
                - $ref: '#/components/schemas/PaymentIntentStatus'
                - type: 'null'
            starting_after:
              description: >-
                Includes only payments created at or after this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            ending_before:
              description: >-
                Includes only payments created at or before this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            customer:
              description: Accepted but not currently applied to the export.
              type:
                - string
                - 'null'
              example: fcus_01J9XR8M3K7VZ8N2YB4WJ6T0RA
          description: Filters a `payment` export.
        checkout_session:
          type: object
          properties:
            limit:
              description: Accepted but not currently applied to the export.
              type:
                - integer
                - 'null'
              format: int64
            offset:
              description: Accepted but not currently applied to the export.
              type:
                - integer
                - 'null'
              format: int64
            payment_intent:
              description: Accepted but not currently applied to the export.
              type:
                - string
                - 'null'
              example: fpi_01J9XR8M3K7VZ8N2YB4WJ6T0RA
            client_reference_id:
              description: Accepted but not currently applied to the export.
              type:
                - string
                - 'null'
            start_date:
              description: >-
                Includes only checkout sessions created at or after this RFC
                3339 timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            end_date:
              description: >-
                Includes only checkout sessions created at or before this RFC
                3339 timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
          description: Filters a `checkout_session` export.
        subscription:
          type: object
          properties:
            limit:
              description: Accepted but not currently applied to the export.
              type:
                - integer
                - 'null'
              format: int32
            offset:
              description: Accepted but not currently applied to the export.
              type:
                - integer
                - 'null'
              format: int32
            starting_after:
              description: Accepted but not currently applied to the export.
              type:
                - string
                - 'null'
              example: fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA
            ending_before:
              description: Accepted but not currently applied to the export.
              type:
                - string
                - 'null'
              example: fsub_01J9XR8M3K7VZ8N2YB4WJ6T0RA
            start_date:
              description: >-
                Includes only subscriptions created at or after this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            end_date:
              description: >-
                Includes only subscriptions created at or before this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
          description: Filters a `subscription` export.
        customer:
          $ref: '#/components/schemas/PaginationFilter'
          description: Filters a `customer` export by creation date range.
        product:
          $ref: '#/components/schemas/PaginationFilter'
          description: Filters a `product` export by creation date range.
        charge_reconciliation:
          type: object
          properties:
            start_date:
              description: >-
                Includes only charges created at or after this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            end_date:
              description: >-
                Includes only charges created at or before this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
          description: Filters a `charge_reconciliation` export.
        payout:
          type: object
          properties:
            start_date:
              description: >-
                Includes only payouts created at or after this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            end_date:
              description: >-
                Includes only payouts created at or before this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
          description: Filters a `payout` export.
        dispute:
          type: object
          properties:
            start_date:
              description: >-
                Includes only disputes opened at or after this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            end_date:
              description: >-
                Includes only disputes opened at or before this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
          description: Filters a `dispute` export by dispute (chargeback) open date.
        line_item:
          type: object
          properties:
            start_date:
              description: >-
                Includes only line items created at or after this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            end_date:
              description: >-
                Includes only line items created at or before this RFC 3339
                timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
          description: Filters a `line_item` export.
        line_item_revenue:
          type: object
          properties:
            start_date:
              description: >-
                Includes only line item revenue records created at or after this
                RFC 3339 timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
            end_date:
              description: >-
                Includes only line item revenue records created at or before
                this RFC 3339 timestamp.
              anyOf:
                - $ref: '#/components/schemas/Timestamptz'
                - type: 'null'
          description: Filters a `line_item_revenue` export.
      additionalProperties: false
    PaymentIntentStatus:
      description: The current lifecycle status of the payment intent.
      type: string
      enum:
        - canceled
        - processing
        - requires_action
        - requires_capture
        - requires_confirmation
        - requires_payment_method
        - succeeded
      example: canceled
    PaginationFilter:
      description: Date-range bounds applied when generating customer and product exports.
      type: object
      properties:
        limit:
          description: >-
            Accepted but not currently applied; the export includes all records
            within the date range.
          type:
            - integer
            - 'null'
          format: int32
        offset:
          description: >-
            Accepted but not currently applied; the export includes all records
            within the date range.
          type:
            - integer
            - 'null'
          format: int32
        starting_after:
          description: >-
            Includes only records created at or after this RFC 3339 timestamp.
            When omitted, the export has no lower time bound.
          anyOf:
            - $ref: '#/components/schemas/Timestamptz'
            - type: 'null'
        ending_before:
          description: >-
            Includes only records created at or before this RFC 3339 timestamp.
            When omitted, the export has no upper time bound.
          anyOf:
            - $ref: '#/components/schemas/Timestamptz'
            - type: 'null'
      example:
        starting_after: string
        ending_before: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Use a Bearer token to access this API.

````