This document will help you set up a dedicated service account for Costory and grant appropriate billing permissions.
You will need to provide to Costory:
Organization ID
API token for the
costoryservice account
Costory will only request organization:billing:read at the billing group level to process your billing information.
Prerequisites
β
Access to your Aiven organization with admin privileges
β
Aiven Terraform provider configured
Step 1: On Aiven, Generate An Access Token Using Terraform
Create the costory application user (service account):
resource "aiven_organization_application_user" "costory" {
organization_id = aiven_organization.customer_name.id
name = "costory"
}Create a user group for billing services:
resource "aiven_organization_user_group" "svc_billing" {
organization_id = aiven_organization.customer_name.id
description = "Service groups for technical services (billing)"
name = "svc_billing"
}Add the costory user to the billing group:
resource "aiven_organization_user_group_member" "svc_groups" {
group_id = aiven_organization_user_group.svc_billing.id
organization_id = aiven_organization.customer_name.id
user_id = aiven_organization_application_user.costory.user_id
}Grant read-only billing permissions to the group:
resource "aiven_organization_permission" "org_permission" {
organization_id = aiven_organization.customer_name.id
resource_id = aiven_organization.customer_name.id
resource_type = "organization"
permissions {
permissions = [ "organization:billing:read" ]
principal_id = aiven_organization_user_group.svc_billing.group_id
principal_type = "user_group"
}
}Generate an API token for the costory user:
resource "aiven_organization_application_user_token" "costory" {
organization_id = aiven_organization.customer_name.id
user_id = aiven_organization_application_user.costory.user_id
description = "Token for costory access to Aiven"
}
Then apply the Terraform config and retrieve the costory API token
Step 2: Share Credentials with Costory
Provide the following information to your Costory contact or through the Costory platform.
To do so, navigate to Settings -> Data Sources -> Billing and select "Add New".
In this setup form, select Aiven and provide your
Organization ID:
<from terraform output>API Token:
<from terraform output -raw costory_api_token>
Costory will use these credentials to automatically fetch your billing invoices via the Aiven Billing API.
How Costory Ingests Your Data
Once configured, Costory will:
Authenticate using the provided API token
Periodically fetch invoice data in CSV format via the Aiven Billing API Get CSV endpoint
Process and visualize your Aiven spending in the Costory dashboard
Data will be available the next day or as soon as the first sync completes.

