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

# Export credit usage as CSV

> Owner or admin only. Downloads every event matching the filters as a CSV file, up to 100,000 rows. Takes the same filters as List credit usage; a larger set is refused with 413 so you can narrow the dates or filters.




## OpenAPI

````yaml /openapi/billing.yaml get /workspaces/{workspaceId}/billing/usage-log/export
openapi: 3.1.0
info:
  title: Connie Billing API
  version: 1.0.0
  description: >
    Endpoints the Connie web app uses for billing. They authenticate with your
    signed-in browser session — see
    https://docs.connie.ai/api-reference/authentication. These are the app's own
    endpoints and can change when the app changes.
servers:
  - url: https://connie.ai/api
security:
  - sessionCookie: []
tags:
  - name: Credits
    description: >
      The workspace's credit balance. Any member can read the balance and plan
      prices; plan details and everything else in Billing are for workspace
      owners and admins only.
  - name: Plan
    description: The workspace's plan and subscription. Owners and admins only.
  - name: Usage log
    description: >-
      Every credit used or added, as shown in Settings > Logs. Owners and admins
      only.
paths:
  /workspaces/{workspaceId}/billing/usage-log/export:
    get:
      tags:
        - Usage log
      summary: Export credit usage as CSV
      description: >
        Owner or admin only. Downloads every event matching the filters as a CSV
        file, up to 100,000 rows. Takes the same filters as List credit usage; a
        larger set is refused with 413 so you can narrow the dates or filters.
      operationId: exportCreditUsage
      parameters:
        - $ref: '#/components/parameters/workspaceId'
        - $ref: '#/components/parameters/q'
        - $ref: '#/components/parameters/period'
        - $ref: '#/components/parameters/from'
        - $ref: '#/components/parameters/to'
        - $ref: '#/components/parameters/movement'
        - $ref: '#/components/parameters/category'
        - $ref: '#/components/parameters/actionKey'
        - $ref: '#/components/parameters/actorId'
        - $ref: '#/components/parameters/surface'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/amountMin'
        - $ref: '#/components/parameters/amountMax'
        - $ref: '#/components/parameters/includeLegacy'
      responses:
        '200':
          description: The CSV file. The `X-Total-Events` header gives the row count.
          headers:
            X-Total-Events:
              description: Number of events in the file.
              schema:
                type: integer
          content:
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadQuery'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/AdminOnly'
        '413':
          description: >
            Too many events. `EXPORT_TOO_LARGE` means more than 100,000 match;
            `SEARCH_CAPPED` means a search covers more events than a search can
            export, so narrow the dates.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - type: object
                    properties:
                      count:
                        type: integer
                      max:
                        type: integer
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    workspaceId:
      name: workspaceId
      in: path
      required: true
      description: The workspace id, as in the app URL `connie.ai/<workspaceId>/...`.
      schema:
        type: string
        format: uuid
    q:
      name: q
      in: query
      description: Search text, 2 to 200 characters.
      schema:
        type: string
        minLength: 2
        maxLength: 200
    period:
      name: period
      in: query
      description: >
        Time window. `billing_period` is the current billing period. `custom`
        uses `from` and `to` and is implied when either is given. Defaults to
        `30d`.
      schema:
        type: string
        enum:
          - today
          - 7d
          - 30d
          - billing_period
          - custom
        default: 30d
    from:
      name: from
      in: query
      description: >-
        Start of a custom range, as `YYYY-MM-DD` or an ISO date-time. Only with
        `period=custom`.
      schema:
        type: string
    to:
      name: to
      in: query
      description: >-
        End of a custom range, as `YYYY-MM-DD` (that whole day is included) or
        an ISO date-time.
      schema:
        type: string
    movement:
      name: movement
      in: query
      description: Only credits used, added, or refunded and adjusted.
      schema:
        type: string
        enum:
          - used
          - added
          - refunded_adjusted
    category:
      name: category
      in: query
      description: One or more categories, repeated or comma-separated.
      style: form
      explode: true
      schema:
        type: array
        items:
          $ref: '#/components/schemas/CreditCategory'
    actionKey:
      name: action_key
      in: query
      description: >-
        One or more exact actions, such as `tool.used`. Repeated or
        comma-separated.
      style: form
      explode: true
      schema:
        type: array
        items:
          type: string
    actorId:
      name: actor_id
      in: query
      description: >-
        Who triggered the event, as a user id or an API key id, or `system`.
        Repeated or comma-separated.
      style: form
      explode: true
      schema:
        type: array
        items:
          type: string
    surface:
      name: surface
      in: query
      description: Where the credits were used. Repeated or comma-separated.
      style: form
      explode: true
      schema:
        type: array
        items:
          $ref: '#/components/schemas/CreditSurface'
    recordId:
      name: record_id
      in: query
      description: Only events charged to these records. Repeated or comma-separated.
      style: form
      explode: true
      schema:
        type: array
        items:
          type: string
          format: uuid
    amountMin:
      name: amount_min
      in: query
      description: Smallest credit amount per event, ignoring sign.
      schema:
        type: number
        minimum: 0
    amountMax:
      name: amount_max
      in: query
      description: Largest credit amount per event, ignoring sign.
      schema:
        type: number
        minimum: 0
    includeLegacy:
      name: include_legacy
      in: query
      description: Include older imported history. Pass `false` to hide it.
      schema:
        type: boolean
        default: true
  responses:
    BadQuery:
      description: >-
        A query parameter is invalid (`VALIDATION_ERROR`); the message says
        which.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: No valid session, or the session has expired (`SESSION_EXPIRED`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    AdminOnly:
      description: >-
        You are not a member of this workspace, or you are not an owner or
        admin.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: >-
        Too many requests (`RATE_LIMIT_EXCEEDED`). Wait for the `Retry-After`
        seconds.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: A readable message.
        code:
          type: string
          description: A machine-readable code, when the route sets one.
    CreditCategory:
      type: string
      enum:
        - ai
        - enrichment
        - workflow
        - tool_integration
        - grant
        - purchase
        - refund
        - adjustment
    CreditSurface:
      type: string
      description: >-
        Where the credits were used, such as Chat (`ai_chat`), MCP, an API key
        or a workflow.
      enum:
        - ai_chat
        - mcp
        - agent
        - workflow
        - ui_enrichment
        - api_key
        - managed_app
        - system
  securitySchemes:
    sessionCookie:
      type: apiKey
      in: header
      name: Cookie
      description: >-
        The full Cookie header copied from a signed-in connie.ai browser
        request. See the Authentication page.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.