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

# Export workflow run result (PDF)



## OpenAPI

````yaml /api-reference/openapi.json post /v2/workflows/runs/{id}/export
openapi: 3.1.0
info:
  title: Base39 API
  description: Base39 API
  version: 1.0.0
  contact:
    name: Base39 Team
    url: https://base39.com.br
    email: suporte@base39.com.br
  termsOfService: https://base39.com.br/termos
  license:
    name: Proprietary
    url: https://base39.com.br/termos
servers:
  - url: http://localhost:3000
    description: Local
  - url: https://api.dev.base39.cloud
    description: Development
  - url: https://api.base39.com.br
    description: Production
security:
  - OAuth2: []
tags:
  - name: pages
    description: Profiles and reports pages
  - name: pipelines
    description: Pipeline boards (kanban) of pages
  - name: blocks
    description: Blocks operations
  - name: search
    description: Search across content
  - name: targets
    description: Lookup targets via datasets
  - name: CognitoTriggers
    description: Cognito triggers
paths:
  /v2/workflows/runs/{id}/export:
    post:
      tags:
        - workflows
      summary: Export workflow run result (PDF)
      operationId: workflow_export_run
      parameters:
        - name: id
          required: true
          in: path
          description: Workflow run ID
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportWorkflowRunPdfInput'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowRunExportOutput'
        '400':
          description: Invalid workflow run export input
        '401':
          description: Unauthorized
        '404':
          description: Workflow run not found
components:
  schemas:
    ExportWorkflowRunPdfInput:
      type: object
      properties:
        to:
          type: string
          description: Optional channel that receives the generated PDF file after export.
          enum:
            - whatsapp
            - email
    WorkflowRunExportOutput:
      type: object
      properties:
        fileUpload:
          $ref: '#/components/schemas/FileUpload'
        runUpdatedAt:
          type: string
          description: Workflow run updatedAt (ISO 8601) at export time.
          example: '2026-06-14T03:12:45.123Z'
      required:
        - fileUpload
        - runUpdatedAt
    FileUpload:
      type: object
      properties:
        object:
          type: string
          example: page
          description: Object type
          title: Object
          x-locale-pt-br-title: Objeto
        id:
          type: string
          example: p_abc123
          description: Unique identifier
          title: ID
          x-locale-pt-br-title: ID
        createdAt:
          format: date-time
          type: string
          example: '2024-01-15T10:30:00.000Z'
          description: Creation timestamp
          title: Created at
          x-locale-pt-br-title: Criado em
        updatedAt:
          format: date-time
          type: string
          example: '2024-01-15T14:45:00.000Z'
          description: Last update timestamp
          title: Updated at
          x-locale-pt-br-title: Atualizado em
        createdBy:
          type: object
          example:
            object: user
            id: u_abc123
            apiKeyId: bsk_abc123
          description: Principal who created this object
          properties:
            object:
              type: string
              enum:
                - user
                - service_account
              example: user
            id:
              type: string
              example: u_abc123
            apiKeyId:
              type: string
              example: bsk_abc123
          title: Created by
          x-locale-pt-br-title: Criado por
        updatedBy:
          type: object
          example:
            object: user
            id: u_abc123
            apiKeyId: bsk_abc123
          description: Principal who last updated this object
          properties:
            object:
              type: string
              enum:
                - user
                - service_account
                - webhook
                - stream
              example: user
            id:
              type: string
              example: u_abc123
            apiKeyId:
              type: string
              example: bsk_abc123
          title: Updated by
          x-locale-pt-br-title: Atualizado por
        status:
          description: |-
            Upload status
            - pending: Waiting for client upload
            - uploaded: Successfully uploaded
            - failed: Upload failed or expired
          example: uploaded
          allOf:
            - $ref: '#/components/schemas/FileUploadStatus'
        filename:
          type: string
          description: Original filename
          example: report.pdf
        content_type:
          type: string
          description: MIME content type
          example: application/pdf
        size_bytes:
          type: number
          description: File size in bytes (null if not yet uploaded)
          example: 1048576
          nullable: true
        metadata:
          type: object
          description: >-
            File metadata. PDF page count is stored at metadata.page_count when
            available.
          example:
            page_count: 12
          nullable: true
        reused:
          type: boolean
          description: Whether this response reuses an existing file (content-based dedup)
          example: false
        upload_url:
          type: string
          description: >-
            Presigned S3 upload URL (only present when status is 'pending' and
            reused is false)

            Client should PUT file contents to this URL

            Expires after 1 hour
          example: https://s3.amazonaws.com/bucket/key?X-Amz-Signature=...
        upload_headers:
          type: object
          description: >-
            Extra headers required for uploading to the presigned URL (only
            present when status is pending).
          additionalProperties:
            type: string
        url:
          type: string
          description: |-
            Authenticated files URL (CloudFront signed cookies)
            Only present when the file has an S3 key
          example: https://files.base39.cloud/uploads/org_abc/fl_abc123/report.pdf
        preview_url:
          type: string
          description: |-
            Authenticated preview URL for the first generated thumbnail page.
            Only present when a preview image exists.
          example: >-
            https://files.base39.cloud/uploads/org_abc/fl_abc123/preview/page-01.png
        download_url:
          type: string
          description: >-
            Presigned S3 download URL.

            Only returned when explicitly requested via `?fields=downloadUrl`
            and status is 'uploaded'.

            Expires after 1 hour.
          example: https://s3.amazonaws.com/bucket/key?X-Amz-Signature=...
        uploaded_time:
          format: date-time
          type: string
          description: When the file was successfully uploaded (null if pending)
          example: '2024-11-14T10:31:23.456Z'
          nullable: true
        expires_at:
          type: string
          description: When the upload URL expires (ISO 8601 string for API response)
          example: '2024-11-14T11:30:00.000Z'
        page_id:
          type: string
          description: Page ID associated with this file upload (optional)
          example: page_abc123
        purpose:
          description: Upload purpose
          nullable: true
          allOf:
            - $ref: '#/components/schemas/FileUploadPurpose'
        public:
          type: boolean
          description: >-
            Whether this file can be fetched without authentication through
            public_url.
          example: false
        public_url:
          type: string
          description: Direct files URL. Only present when public is true.
          example: https://files.base39.com.br/uploads/org_abc/fl_abc123/report.pdf
        resources:
          description: Provider-specific file resources attached to this upload.
          nullable: true
          type: array
          items:
            type: object
        classification:
          description: >-
            Document classification stage - determines document type and next
            stages
          allOf:
            - $ref: '#/components/schemas/ClassificationStage'
        parse:
          description: Parse stage - converts OCR output to markdown
          allOf:
            - $ref: '#/components/schemas/ParseStage'
        index:
          description: Index stage - vector embedding for semantic search
          allOf:
            - $ref: '#/components/schemas/IndexStage'
        insights:
          description: >-
            Insights stage - skill-based analysis generating
            claims/issues/checks
          allOf:
            - $ref: '#/components/schemas/InsightsStage'
      required:
        - object
        - id
        - createdAt
        - updatedAt
        - status
        - filename
        - content_type
        - size_bytes
        - metadata
        - uploaded_time
        - expires_at
        - public
        - classification
        - parse
        - index
        - insights
    FileUploadStatus:
      type: string
      enum:
        - pending
        - uploaded
        - failed
      description: |-
        Upload status
        - pending: Waiting for client upload
        - uploaded: Successfully uploaded
        - failed: Upload failed or expired
    FileUploadPurpose:
      type: string
      enum:
        - agent
        - knowledge
        - skill
        - metadata
        - dataset
        - company
        - page
        - session
        - page_run_output
        - export
        - whatsapp
        - fiscal_document
      description: Upload purpose
    ClassificationStage:
      type: object
      properties:
        status:
          description: Processing stage status
          example: completed
          allOf:
            - $ref: '#/components/schemas/ProcessingStageStatus'
        started_at:
          type: string
          description: When the stage started (ISO 8601)
          example: '2024-12-07T11:01:00.000Z'
        completed_at:
          type: string
          description: When the stage completed (ISO 8601)
          example: '2024-12-07T11:02:30.000Z'
        error:
          type: string
          description: Error message from the last failed attempt
          example: 'Unsupported file type for parsing: arquivo.exe'
        document_type:
          type: string
          description: Detected document type
          example: balance_sheet
        confidence:
          type: number
          description: Classification confidence score (0-1)
          example: 0.98
      required:
        - status
    ParseStage:
      type: object
      properties:
        status:
          description: Processing stage status
          example: completed
          allOf:
            - $ref: '#/components/schemas/ProcessingStageStatus'
        started_at:
          type: string
          description: When the stage started (ISO 8601)
          example: '2024-12-07T11:01:00.000Z'
        completed_at:
          type: string
          description: When the stage completed (ISO 8601)
          example: '2024-12-07T11:02:30.000Z'
        error:
          type: string
          description: Error message from the last failed attempt
          example: 'Unsupported file type for parsing: arquivo.exe'
        jobId:
          type: string
          description: AWS Textract job ID
      required:
        - status
    IndexStage:
      type: object
      properties:
        status:
          description: Processing stage status
          example: completed
          allOf:
            - $ref: '#/components/schemas/ProcessingStageStatus'
        started_at:
          type: string
          description: When the stage started (ISO 8601)
          example: '2024-12-07T11:01:00.000Z'
        completed_at:
          type: string
          description: When the stage completed (ISO 8601)
          example: '2024-12-07T11:02:30.000Z'
        error:
          type: string
          description: Error message from the last failed attempt
          example: 'Unsupported file type for parsing: arquivo.exe'
      required:
        - status
    InsightsStage:
      type: object
      properties:
        status:
          description: Processing stage status
          example: completed
          allOf:
            - $ref: '#/components/schemas/ProcessingStageStatus'
        started_at:
          type: string
          description: When the stage started (ISO 8601)
          example: '2024-12-07T11:01:00.000Z'
        completed_at:
          type: string
          description: When the stage completed (ISO 8601)
          example: '2024-12-07T11:02:30.000Z'
        error:
          type: string
          description: Error message from the last failed attempt
          example: 'Unsupported file type for parsing: arquivo.exe'
        facts:
          description: Facts extracted from the document
          type: array
          items:
            $ref: '#/components/schemas/InsightFact'
        claims:
          description: Claims extracted from the document
          type: array
          items:
            $ref: '#/components/schemas/ClaimOutput'
        issues:
          description: Issues found during document analysis
          type: array
          items:
            $ref: '#/components/schemas/IssueOutput'
        checks:
          description: Validation checks performed during insights
          type: array
          items:
            $ref: '#/components/schemas/CheckOutput'
      required:
        - status
    ProcessingStageStatus:
      type: string
      enum:
        - not_started
        - pending
        - processing
        - completed
        - failed
        - ignored
      description: Processing stage status
    InsightFact:
      type: object
      properties:
        id:
          type: string
        source_id:
          type: string
        entity_indexes:
          type: array
          items:
            type: number
        statement:
          type: string
        references:
          type: array
          items:
            $ref: '#/components/schemas/FactReference'
        method:
          type: string
          enum:
            - verbatim
            - calculated
            - inferred
        confidence:
          type: number
        entities:
          type: array
          items:
            $ref: '#/components/schemas/FactEntity'
      required:
        - id
        - entity_indexes
        - statement
        - references
        - method
        - confidence
    ClaimOutput:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the claim
          example: cl_abc123
        statement:
          type: string
          description: The auditable statement
          example: Company revenue increased 15% YoY
        confidence:
          type: number
          description: Confidence score (0-1)
          example: 0.92
          nullable: true
        supporting_facts:
          description: IDs of supporting facts
          example:
            - f_xyz789
          type: array
          items:
            type: string
        category:
          type: string
          description: Claim category
          example: financial
      required:
        - id
        - statement
        - confidence
        - supporting_facts
        - category
    IssueOutput:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the issue
          example: iss_abc123
        type:
          type: string
          description: Type of issue
          example: missing_data
        description:
          type: string
          description: Issue description
          example: Required field "date" is missing
        severity:
          type: string
          description: Issue severity
          example: warning
          enum:
            - info
            - warning
            - error
            - critical
        fact_id:
          type: string
          description: Related fact ID
          example: f_xyz789
          nullable: true
      required:
        - id
        - type
        - description
        - severity
        - fact_id
    CheckOutput:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the check
          example: chk_abc123
        name:
          type: string
          description: Check name
          example: total_assets_validation
        passed:
          type: boolean
          description: Whether the check passed
          example: true
        message:
          type: string
          description: Check result message
          example: Total assets matches sum of components
        severity:
          type: string
          description: Check severity
          example: info
          enum:
            - info
            - warning
            - error
      required:
        - id
        - name
        - passed
        - message
        - severity
    FactReference:
      type: object
      properties:
        page_number:
          type: number
      required:
        - page_number
    FactEntity:
      type: object
      properties:
        type:
          type: string
          enum:
            - company
            - person
        name:
          type: string
        document:
          type: string
      required:
        - type
        - name
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://id.local.base39.cloud/oauth2/authorize
          tokenUrl: https://id.local.base39.cloud/oauth2/token
          scopes:
            profile: Read user profile
            email: Read user email
            openid: OpenID authentication
      description: OAuth2 Authorization Code flow

````