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

# Exportar planilha

> Cria uma operação de export assíncrona (XLSX). O body depende do `{type}` na URL (veja os schemas abaixo).

A operação fica `pending` e o arquivo fica disponível em `GET /spreadsheet-operations/{operation}/download` após `completed`.



## OpenAPI

````yaml /api-reference/openapi.json post /api/management/spreadsheet-operations/export/{type}
openapi: 3.0.0
info:
  title: Olie API
  version: 1.0.0
  description: >
    # Introdução 👋


    Olá! Esta é a documentação oficial da API da [olie.ai](https://olie.ai/).
    Aqui você encontra as referências e exemplos de uso dos nossos endpoints.


    Para uma visão completa, recomendamos fortemente que você leia a
    [documentação oficial](https://docs.olie.ai/api-reference/introduction). Lá
    estão detalhados tópicos essenciais como
    [autenticação](https://docs.olie.ai/api-reference/introduction/authentication),
    [estrutura de
    respostas](https://docs.olie.ai/api-reference/general/response-structure),
    [paginação](https://docs.olie.ai/api-reference/general/pagination) e outros
    guias de integração.


    No Postman, esta coleção foca nas informações específicas de cada requisição
    (endpoints, parâmetros e exemplos), servindo como apoio rápido para testes e
    desenvolvimento.
servers:
  - url: https://api.olie.ai
security:
  - BearerAuth: []
paths:
  /api/management/spreadsheet-operations/export/{type}:
    parameters:
      - name: type
        in: path
        required: true
        description: >-
          Tipo de exportação: `project`, `customer`, `contact`, `form_answer`,
          `answer_history`, `agent_execution` ou `project_execution`.
        schema:
          type: string
          enum:
            - project
            - customer
            - contact
            - form_answer
            - answer_history
            - agent_execution
            - project_execution
        example: project
    post:
      tags:
        - spreadsheet-operations
        - export
      summary: Exportar planilha
      description: >-
        Cria uma operação de export assíncrona (XLSX). O body depende do
        `{type}` na URL (veja os schemas abaixo).


        A operação fica `pending` e o arquivo fica disponível em `GET
        /spreadsheet-operations/{operation}/download` após `completed`.
      operationId: exportarPlanilha
      requestBody:
        content:
          application/json:
            schema:
              title: Exportação de Planilha
              description: >-
                Payload de exportação. O schema correto depende do `{type}` na
                URL.
              oneOf:
                - title: Export Project
                  type: object
                  description: Payload para `POST /export/project`.
                  properties:
                    columns:
                      type: array
                      description: >-
                        Chaves das colunas (deve incluir todas as requiredKeys
                        do catálogo em GET /export/{type}/columns).
                      items:
                        type: string
                      example:
                        - project.id
                        - project.name
                        - project.customer
                    dynamic_forms:
                      type: array
                      description: >-
                        Formulários dinâmicos opcionais que entram no layout e
                        no payload de exportação.
                      items:
                        type: object
                        properties:
                          model:
                            type: string
                            enum:
                              - project
                              - project_funnel
                              - funnel_step
                          id:
                            type: string
                            format: uuid
                            description: Obrigatório para `project_funnel` e `funnel_step`.
                        required:
                          - model
                      example:
                        - model: project
                        - model: project_funnel
                          id: 019dd427-5d13-71bf-9a09-d75aa2bf4bd7
                    filters:
                      type: array
                      description: Busca avançada (array de filtros).
                      items:
                        type: object
                  required:
                    - columns
                - title: Export Customer
                  type: object
                  description: Payload para `POST /export/customer`.
                  properties:
                    columns:
                      type: array
                      description: >-
                        Chaves das colunas (deve incluir todas as requiredKeys
                        do catálogo em GET /export/{type}/columns).
                      items:
                        type: string
                      example:
                        - customer.id
                        - customer.name
                    include_dynamic_form:
                      type: boolean
                      description: >-
                        Quando `true`, inclui o formulário dinâmico do frame no
                        payload/colunas do export.
                      example: true
                    filters:
                      type: array
                      description: Busca avançada (array de filtros).
                      items:
                        type: object
                  required:
                    - columns
                - title: Export Contact
                  type: object
                  description: Payload para `POST /export/contact`.
                  properties:
                    columns:
                      type: array
                      description: >-
                        Chaves das colunas (deve incluir todas as requiredKeys
                        do catálogo em GET /export/{type}/columns).
                      items:
                        type: string
                      example:
                        - contact.id
                        - contact.name
                    include_dynamic_form:
                      type: boolean
                      description: >-
                        Quando `true`, inclui o formulário dinâmico do frame no
                        payload/colunas do export.
                      example: true
                    filters:
                      type: array
                      description: Busca avançada (array de filtros).
                      items:
                        type: object
                  required:
                    - columns
                - title: Export Form Answer
                  type: object
                  description: >-
                    Payload para `POST /export/form_answer`. Exporta respostas
                    do formulário; colunas dinâmicas vêm das edges do form.
                  properties:
                    form_id:
                      type: integer
                      description: >-
                        ID do formulário (do frame atual) cujas respostas serão
                        exportadas.
                      example: 18
                  required:
                    - form_id
                - title: Export Answer History
                  type: object
                  description: >-
                    Payload para `POST /export/answer_history`. Identifica o
                    pivot/modelo cujo histórico de respostas será exportado.
                  properties:
                    target:
                      type: object
                      properties:
                        pivot_class:
                          type: string
                          description: FQCN do modelo pivot.
                          example: App\Models\Project
                        form_id:
                          type: integer
                          description: ID do formulário associado ao histórico.
                          example: 18
                        id:
                          type: string
                          format: uuid
                          description: ID do registro pivot (quando aplicável).
                          example: 019dd427-5d13-71bf-9a09-d75aa2bf4bd7
                        father_class:
                          type: string
                          description: >-
                            FQCN do modelo pai, quando o pivot depende de um
                            pai.
                        father_id:
                          type: string
                          format: uuid
                          description: Obrigatório quando `father_class` é informado.
                      required:
                        - pivot_class
                        - form_id
                  required:
                    - target
                - title: Export Agent Execution
                  type: object
                  description: >-
                    Payload para `POST /export/agent_execution`. Exporta todas
                    as colunas do catálogo. Body opcional com filtros Spatie
                    QueryBuilder.
                  properties:
                    filter:
                      type: object
                      description: >-
                        Filtros Spatie QueryBuilder. Campos: `agent_id`,
                        `status`, `model`, `error`.
                      properties:
                        agent_id:
                          type: string
                          format: uuid
                        status:
                          type: string
                          enum:
                            - pending
                            - completed
                            - failed
                          example: completed
                        model:
                          type: string
                        error:
                          type: string
                      example:
                        status: completed
                    sort:
                      type: string
                      description: >-
                        Ordenação Spatie (`campo` ou `-campo`). Campos:
                        `credits_debited`, `tokens_used`, `latency`,
                        `created_at`.
                      example: '-created_at'
                - title: Export Project Execution
                  type: object
                  description: >-
                    Payload para `POST /export/project_execution`. Exporta todas
                    as colunas do catálogo. Exige `project_id` e/ou `user_id`
                    (ao menos um).
                  properties:
                    project_id:
                      type: string
                      format: uuid
                      description: >-
                        UUID do projeto. Obrigatório se `user_id` não for
                        enviado. Requer permissão de view no projeto.
                      example: 019dd427-5d13-71bf-9a09-d75aa2bf4bd7
                    user_id:
                      type: string
                      format: uuid
                      description: >-
                        UUID do usuário. Obrigatório se `project_id` não for
                        enviado. Requer permissão de view no usuário.
                      example: ee989a1d-afe3-4ff7-f4fb-bec440e8b372
                    filter:
                      type: object
                      description: >-
                        Filtros Spatie QueryBuilder. Campos: `user_id`,
                        `funnel_step_id`, `start_date_gt`, `end_date_lt`,
                        `is_running`.
                      properties:
                        user_id:
                          type: string
                          format: uuid
                        funnel_step_id:
                          type: integer
                        start_date_gt:
                          type: string
                          format: date-time
                        end_date_lt:
                          type: string
                          format: date-time
                        is_running:
                          type: boolean
                          example: false
                      example:
                        is_running: false
                    sort:
                      type: string
                      description: >-
                        Ordenação Spatie (`campo` ou `-campo`). Campos:
                        `started_at`, `finished_at`.
                      example: '-started_at'
        required: true
      responses:
        '200':
          description: Operação de export criada com sucesso
          content:
            application/json:
              schema:
                type: object
                properties:
                  response:
                    type: boolean
                    example: true
                  spreadsheet_operation:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      action:
                        type: string
                        example: export
                      type:
                        type: string
                        example: project
                      status:
                        type: string
                        example: completed
                      total_rows:
                        type: integer
                        example: 120
                      processed_rows:
                        type: integer
                        example: 120
                      percentage:
                        type: integer
                        example: 100
                      errors_count:
                        type: integer
                        example: 0
                      metadata:
                        type: object
                      file_name:
                        type: string
                        example: project_2026-06-01-143022.xlsx
                      initiator_type:
                        type: string
                        example: App\Models\User
                      initiator_id:
                        type: string
                        format: uuid
                      initiator:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                          name:
                            type: string
                          avatar_url:
                            type: string
                      started_at:
                        type: string
                        format: date-time
                      completed_at:
                        type: string
                        format: date-time
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
              example:
                response: true
                spreadsheet_operation:
                  id: c8f6c4a2-31af-f523-ad00-47b2ce67491e
                  action: export
                  type: project
                  status: completed
                  total_rows: 120
                  processed_rows: 120
                  percentage: 100
                  errors_count: 0
                  metadata: {}
                  file_name: project_2026-06-01-143022.xlsx
                  initiator_type: App\Models\User
                  initiator_id: ee989a1d-afe3-4ff7-f4fb-bec440e8b372
                  initiator:
                    id: 7b6c3328-3066-e4e3-ae36-911996a826da
                    name: string
                    avatar_url: string
                  started_at: '2026-04-23T17:57:57.942Z'
                  completed_at: '1980-11-02T01:58:58.018Z'
                  created_at: '1950-02-26T12:34:00.424Z'
                  updated_at: '1955-03-13T19:55:56.035Z'
        '401':
          description: Não autenticado
        '403':
          description: Sem permissão
        '422':
          description: Campos inválidos
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````