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

# Create data export run

> Initiate an asynchronous data export run with an optional custom activity window.

Use this endpoint to start a new data export. The run is processed asynchronously — poll
[Get data export run](/api-reference/data-exports/get-data-export-by-id) until the status is `Completed`
and a `fileUri` is available.

<Info>
  This endpoint does not require an `x-user-id` header. Exports cover all users for the authenticated partner.
</Info>

## Activity window options

<Tabs>
  <Tab title="Incremental (default)">
    Send an empty request body `{}` to export activity since the latest completed run's `activityTo` through the new run's
    initiation time. On the first export, all historical activity is included (no lower bound).

    ```json theme={null}
    {}
    ```
  </Tab>

  <Tab title="Custom range">
    Pass both `activityFrom` and `activityTo` to backfill or re-export a specific period (maximum 90 days).

    ```json theme={null}
    {
      "activityFrom": "2025-01-01T00:00:00.000Z",
      "activityTo": "2025-01-31T23:59:59.999Z"
    }
    ```
  </Tab>
</Tabs>

<Warning>
  Only one active run (`Pending` or `InProgress`) is allowed at a time. A concurrent request returns `409`
  with the existing run.
</Warning>


## OpenAPI

````yaml POST /b2b/data-exports
openapi: 3.0.3
info:
  title: Wealthyhood Data Exports API
  version: 1.0.0
  description: >
    Partner-level endpoints for initiating and monitoring data export runs. Each
    completed run produces a

    JSON file containing portfolio snapshots and financial activity for a
    configurable time window.


    All requests require a bearer access token with the `wealthyhood:nbg` scope.
    These endpoints do not

    require an `x-user-id` header — exports cover all users for the
    authenticated partner.


    See the [Data Export](/data-exports/data-export) guide for the export file
    schema and integration details.
servers:
  - url: https://{host}
    variables:
      host:
        default: api.wealthyhood.com
        description: Wealthyhood API host name.
security:
  - bearerAuth: []
tags:
  - name: Data Exports
    description: Initiate and monitor partner data export runs.
paths:
  /b2b/data-exports:
    post:
      tags:
        - Data Exports
      summary: Create data export run
      description: >
        Initiates a new data export run. The export is processed asynchronously
        — poll

        `GET /b2b/data-exports/{id}` until the run reaches `Completed` or
        `Failed` status.


        **Activity window (default):** When the request body is empty or omits
        both date fields, activity is

        exported incrementally from the latest completed run's `activityTo`
        through this run's initiation

        time. On the first export, no lower bound is applied.


        **Activity window (custom):** Pass `activityFrom` and `activityTo`
        together to backfill or re-export a

        specific period. Both fields are required when specifying a custom
        window.


        **Validation rules for custom windows:**

        - `activityFrom` must be before `activityTo`

        - `activityTo` cannot be in the future

        - The range cannot exceed 90 days


        Only one active run (`Pending` or `InProgress`) is allowed at a time. If
        a run is already active,

        the API returns `409` with the existing run.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDataExportRunRequest'
            examples:
              incremental:
                summary: Incremental export (default)
                value: {}
              customWindow:
                summary: Custom activity window
                value:
                  activityFrom: '2025-01-01T00:00:00.000Z'
                  activityTo: '2025-01-31T23:59:59.999Z'
      responses:
        '202':
          description: Export run accepted and queued for processing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataExportRun'
              examples:
                incrementalFirstRun:
                  summary: First incremental run (no previous export)
                  value:
                    id: 674a1b2c3d4e5f6789012345
                    status: Pending
                    initiatedAt: '2025-01-16T01:00:00.000Z'
                    schemaVersion: 1.1.1
                    activityTo: '2025-01-16T01:00:00.000Z'
                incrementalWithPrevious:
                  summary: Incremental run after a completed export
                  value:
                    id: 674a1b2c3d4e5f6789012346
                    status: Pending
                    initiatedAt: '2025-01-17T01:00:00.000Z'
                    schemaVersion: 1.1.1
                    activityFrom: '2025-01-16T01:00:00.000Z'
                    activityTo: '2025-01-17T01:00:00.000Z'
                customWindow:
                  summary: Custom activity window
                  value:
                    id: 674a1b2c3d4e5f6789012347
                    status: Pending
                    initiatedAt: '2025-01-18T01:00:00.000Z'
                    schemaVersion: 1.1.1
                    activityFrom: '2025-01-01T00:00:00.000Z'
                    activityTo: '2025-01-31T23:59:59.999Z'
        '400':
          description: Invalid activity date range in request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              examples:
                missingActivityTo:
                  summary: Only activityFrom provided
                  value:
                    status: 400
                    error:
                      message: activityFrom and activityTo must both be provided
                invalidRange:
                  summary: activityFrom is not before activityTo
                  value:
                    status: 400
                    error:
                      message: activityFrom must be before activityTo
                futureActivityTo:
                  summary: activityTo is in the future
                  value:
                    status: 400
                    error:
                      message: activityTo cannot be in the future
                rangeTooLong:
                  summary: Range exceeds 90 days
                  value:
                    status: 400
                    error:
                      message: Activity range cannot exceed 90 days
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          description: An active export run already exists for this partner.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataExportRun'
              example:
                id: 674a1b2c3d4e5f6789012345
                status: Pending
                initiatedAt: '2025-01-16T01:00:00.000Z'
                schemaVersion: 1.1.1
                activityTo: '2025-01-16T01:00:00.000Z'
components:
  schemas:
    CreateDataExportRunRequest:
      type: object
      description: >
        Optional activity window for the export. Omit both fields (or send an
        empty object) for the default

        incremental window. When specifying a custom window, both fields are
        required.
      properties:
        activityFrom:
          type: string
          format: date-time
          description: >
            Lower bound (exclusive) for activity included in the export. Must be
            provided together with

            `activityTo`.
          example: '2025-01-01T00:00:00.000Z'
        activityTo:
          type: string
          format: date-time
          description: >
            Upper bound (inclusive) for activity included in the export. Must be
            provided together with

            `activityFrom`. Cannot be in the future.
          example: '2025-01-31T23:59:59.999Z'
      additionalProperties: false
    DataExportRun:
      type: object
      required:
        - id
        - status
        - initiatedAt
        - schemaVersion
        - activityTo
      properties:
        id:
          type: string
          description: Unique identifier for the export run.
          example: 674a1b2c3d4e5f6789012345
        status:
          type: string
          description: Current processing status of the export run.
          enum:
            - Pending
            - InProgress
            - Completed
            - Failed
          example: Pending
        initiatedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the export run was initiated.
          example: '2025-01-16T01:00:00.000Z'
        exportedAt:
          type: string
          format: date-time
          description: >-
            ISO 8601 timestamp when the export completed. Present when status is
            `Completed`.
          example: '2025-01-16T02:00:00.000Z'
        fileUri:
          type: string
          format: uri
          description: >-
            URL to download the exported JSON file. Present when status is
            `Completed`.
          example: https://data-exports.wealthyhood.cloud/nbg/2026/01/16/export.json
        schemaVersion:
          type: string
          description: Schema version used for the export file (semantic versioning).
          example: 1.1.1
        error:
          type: string
          description: Error message when status is `Failed`.
          example: Unknown error during data export
        activityFrom:
          type: string
          format: date-time
          description: >
            Resolved lower bound (exclusive) for activity in this export.
            Omitted on the first incremental

            run when no previous completed export exists.
          example: '2025-01-15T10:00:00.000Z'
        activityTo:
          type: string
          format: date-time
          description: >
            Resolved upper bound (inclusive) for activity in this export.
            Defaults to the run's initiation

            time when not explicitly requested.
          example: '2025-01-16T01:00:00.000Z'
      additionalProperties: false
    ApiErrorResponse:
      type: object
      properties:
        status:
          type: integer
        error:
          type: object
          properties:
            message:
              type: string
            description:
              type: string
              nullable: true
        responseId:
          type: string
          format: uuid
  responses:
    UnauthorizedError:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 401
            error:
              message: Unauthorized - Invalid or missing authentication token
            responseId: 145f2b0d-1d5b-4e91-8d0d-7af0ae9ad13a
    ForbiddenError:
      description: Authenticated client lacks the required scope.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 403
            error:
              message: Access denied
            responseId: 5e467f79-c62c-4d83-9810-7a0f8529fd76
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Auth0-issued access token that includes the `wealthyhood:nbg` scope.

````