API reference
Import history
POST /v1/import/claude-code — add finished Claude Code sessions from before you connected, metadata only.
Adds finished sessions from before you connected, so the weekly view and exports include them. Sessions Agentower already has are skipped, so importing the same sessions twice changes nothing. Imported sessions arrive as Done. Scope: ingest.
#POST /v1/import/claude-code
| Field | Type | Notes |
|---|---|---|
sessions | array | 1–200 sessions |
sessions[].session_id | string | Required. Claude Code's session ID |
sessions[].repo | string | Required. The project's name |
sessions[].started_at | number | Required. Milliseconds since 1970; not before 1 January 2024 |
sessions[].ended_at | number | Required. Its last activity; not before started_at, not in the future |
sessions[].tokens_in, sessions[].tokens_out | number | Required. Whole numbers, 0 or more |
sessions[].model | string | Optional. The model's name |
models_only | boolean | Optional. true only fills in the model of sessions Agentower already has, and adds none |
The whole batch is checked first: one invalid session rejects all of them.
Import two sessions
curl -X POST "$AGENTOWER_URL/v1/import/claude-code" \
-H "authorization: Bearer $AGENTOWER_KEY" \
-H "content-type: application/json" \
-d '{"sessions":[
{"session_id":"a1b2c3d4-docs-import-1","repo":"billing-api","started_at":1788000000000,"ended_at":1788003600000,"tokens_in":120000,"tokens_out":8000,"model":"claude-opus-5-5"},
{"session_id":"a1b2c3d4-docs-import-2","repo":"mobile-app","started_at":1788100000000,"ended_at":1788102000000,"tokens_in":40000,"tokens_out":3000}]}'Response · 200
{ "ok": true, "imported": 2, "skipped": 0 }Run it again and both are skipped: { "ok": true, "imported": 0, "skipped": 2 }.
An invalid batch
curl -X POST "$AGENTOWER_URL/v1/import/claude-code" \
-H "authorization: Bearer $AGENTOWER_KEY" \
-H "content-type: application/json" \
-d '{"sessions":[{"session_id":"x1","repo":"billing-api"}]}'Response · 400
{ "error": "invalid_import", "hint": "Up to 200 sessions: session_id, repo, started_at, ended_at (ms), tokens_in, tokens_out." }Send only the fields above — never prompts, replies, code or paths.