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

# Stream a CSV export of all matching contacts

> Streams a CSV of every contact matching the supplied filter as `text/csv` with `Content-Disposition: attachment; filename="contacts-YYYY-MM-DD.csv"`. Columns: `First Name, Last Name, Phone, Email, Pipeline, Stage, Created Date`. Uses a Mongo cursor so even multi-thousand exports stream incrementally without buffering. Filter semantics match the other `query-*` endpoints, but parameters are passed as query string: `stageIds` is a comma-separated list, `advancedParams` is a JSON-encoded string (malformed JSON is silently ignored).



## OpenAPI

````yaml /api-reference/openapi.yaml get /api/contacts/query-bulk-export
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/contacts/query-bulk-export:
    get:
      tags:
        - Contacts
      summary: Stream a CSV export of all matching contacts
      description: >-
        Streams a CSV of every contact matching the supplied filter as
        `text/csv` with `Content-Disposition: attachment;
        filename="contacts-YYYY-MM-DD.csv"`. Columns: `First Name, Last Name,
        Phone, Email, Pipeline, Stage, Created Date`. Uses a Mongo cursor so
        even multi-thousand exports stream incrementally without buffering.
        Filter semantics match the other `query-*` endpoints, but parameters are
        passed as query string: `stageIds` is a comma-separated list,
        `advancedParams` is a JSON-encoded string (malformed JSON is silently
        ignored).
      operationId: get_contact_query_bulk_export
      parameters:
        - in: query
          name: stageIds
          required: false
          description: Comma-separated pipeline-stage IDs. Required unless `orgWide=true`.
          schema:
            type: string
          example: 64b2c3d4e5f60012345678aa,64b2c3d4e5f60012345678ab
        - in: query
          name: pipelineType
          required: false
          description: Which model to export from. Defaults to `Contact`.
          schema:
            type: string
            enum:
              - Contact
              - Application
        - in: query
          name: orgWide
          required: false
          description: >-
            Set to `true` to export across the whole organization and ignore
            `stageIds`.
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
        - in: query
          name: ownerFilter
          required: false
          description: >-
            Owner-based scope (`owned` / `unowned`) applied identically to the
            contacts list view.
          schema:
            type: string
        - in: query
          name: advancedParams
          required: false
          description: >-
            JSON-encoded filter object (same shape used by the Contacts list
            view advanced filters). Malformed JSON is silently ignored.
          schema:
            type: string
          example: '{"createdAfter":"2026-01-01T00:00:00.000Z"}'
      responses:
        '200':
          description: CSV stream
          headers:
            Content-Disposition:
              description: Attachment header carrying the date-stamped filename.
              schema:
                type: string
              example: attachment; filename="contacts-2026-05-20.csv"
          content:
            text/csv:
              schema:
                type: string
                example: >
                  First Name,Last Name,Phone,Email,Pipeline,Stage,Created Date

                  "Alex","Morgan","+14165550100","alex.morgan@example.com","Sales","New
                  Lead","2026-05-20"
        '400':
          description: Missing `stageIds` when `orgWide` is not `true`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    LegacyErrorResponse:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        data: {}
      additionalProperties: true
      example:
        error: Attachment not found
        message: Attachment not found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````