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

# Cursor Billing Setup

> Connect Cursor usage and billing data to Costory via Admin API key or Terraform.

<Tabs>
  <Tab title="Terraform">
    ```hcl theme={null}
    terraform {
      required_providers {
        costory = {
          source  = "costory-io/costory"
          version = ">= 0.1.0"
        }
      }
    }

    variable "costory_api_token" {
      type        = string
      description = "Costory API token."
      sensitive   = true
    }

    variable "cursor_admin_api_key" {
      type        = string
      description = "Cursor admin API key used to fetch billing data."
      sensitive   = true
    }

    provider "costory" {
      token = var.costory_api_token
    }

    resource "costory_billing_datasource_cursor" "main" {
      name          = "Cursor Billing"
      admin_api_key = var.cursor_admin_api_key
    }
    ```
  </Tab>

  <Tab title="Manual setup">
    Open Costory and go to **Billing > Import new billing datasource > Cursor**. The stepper guides you through each field.

    1. Generate a **Cursor Admin API key** in your organization admin settings (Billing or API keys).
    2. Provide a datasource name and the **Admin API key** in the Costory stepper.

    On first sync, Costory backfills up to **12 months** of historical usage data.
  </Tab>
</Tabs>

**What Costory includes**

* **Chargeable usage events** only (Cursor marks these as chargeable).
* **Per-user spend** using the `user_email` from Cursor.
* **Per-model usage** (group by **Service name** = model).
* **Feature-level breakdown** using `kind`, `max_mode`, and `is_headless`.

**What Costory does not include**

* **Non-chargeable or included usage** (e.g., free or bundled allowances).
* **Seat or license invoices** that are not emitted as usage events.
* **Taxes or adjustments** outside the usage event stream.

**How to analyze Cursor costs**

* **Per-user email spend:** group by **Resource name** or **Sub account id**
  (both map to the Cursor user email).
* **Per-model costs:** group by **Service name** (model) and break down by
  **SKU** (`input` vs `output` tokens).
* **Feature usage:** group by the `kind`, `max_mode`, and `is_headless` labels to
  compare Compose vs Chat, Max mode usage, or headless runs.

<Note>
  Cursor costs are attributed to **input tokens**. Output token rows are
  included for usage analysis but have \$0 cost.
</Note>
