This guide explains how to upload Claude Code usage metrics into DX using a CSV file. Once an API is made available by Anthropic, this process will be automated through a DX data connector.
Prerequisites
an Anthropic account with access to export Claude Code API usage
a DX database user with write access
Instructions
Step 1- Create custom table
To import Claude Code usage metrics into DX, you’ll first need to create a custom table in your DX database.
Use a Postgres client (Postico or pgAdmin) to connect to your DX database.
Then, execute the SQL statement below:
CREATE TABLE custom.claude_code_daily_usages (
id SERIAL PRIMARY KEY,
date DATE NOT NULL,
model_version text,
api_key text,
workspace text,
usage_type text,
usage_input_tokens_no_cache integer,
usage_input_tokens_cache_write_5m integer,
usage_input_tokens_cache_write_1h integer,
usage_input_tokens_cache_read integer,
usage_output_tokens integer,
web_search_count integer
);
Step 2- Prepare Claude Code data
Download a raw export of your Claude Code usage metrics and update the CSV file to match the schema in Step 1. Ensure that the usage_date_utc
header is renamed to date!
Step 3- Import Claude Code data
Use the Import CSV feature in Postico or pgAdmin to upload your data to DX.
Right-click the
custom.claude_code_daily_usages
table and click Import CSV.Select the formatted CSV from Step 2.
Ensure “First row is header” is checked.
Click Import.
Step 4- Create & View reports
Once your data is uploaded, use DX's prebuilt reports or use Data Studio to create custom reports. Please reach out and we can set up some standardized custom reports with this data.