> ## 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.

# Aiven Billing Setup

> Connect Aiven billing data to Costory via the Aiven Billing API.

> [tab] Terraform
>
> To install and authenticate the provider, see [Terraform setup](https://docs.costory.io/setup/terraform.md).
>
> ```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 "aiven_api_secret" {
>   type        = string
>   description = "Aiven API token used to fetch billing data."
>   sensitive   = true
> }
>
> provider "costory" {
>   token = var.costory_api_token
> }
>
> resource "costory_billing_datasource_aiven" "main" {
>   name            = "Aiven Billing"
>   api_secret      = var.aiven_api_secret
>   organization_id = "aiven-organization-id"
> }
> ```

> [tab] Manual setup
>
> Open Costory and go to **Billing > Import new billing datasource > Aiven**. The stepper guides you through each field.
>
> 1. In the Aiven console, create a dedicated `costory` application user and grant it **organization:billing:read** permission.
> 2. Generate an API token for the `costory` application user.
> 3. Enter the **Organization ID** and **API Token** in the Costory stepper.
>
> Costory fetches invoice data via the Aiven Billing API. On first sync, Costory backfills up to **12 months** of historical data (depending on your Aiven account). New data appears the next day.

**What Costory includes**

* **Invoice-level billing data** from all Aiven services in your organization.
* **Per-service cost breakdown** (group by **Service name**).

**What Costory does not include**

* **Credits or promotional discounts** outside invoice line items.
* **Aiven support or marketplace fees** that are billed separately.


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