Expenses

Cost tracking ledger.

6 actions. Each is callable by the agent as a tool, over HTTP via /api/invoke, and (usually) from a UI page.

expenses.summary

GET

Roll up costs from the expense_ledger by actor / category / time. Optionally scope to a project, mission, subject, or actor.

  • AI tool: expenses_summary
  • API: GET /api/invoke/expenses.summary

Input

Field Type Required Description
since any
until any
projectId string
missionId string
subjectId string
actorId string
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "since": {},
    "until": {},
    "projectId": {
      "type": "string",
      "minLength": 1
    },
    "missionId": {
      "type": "string",
      "minLength": 1
    },
    "subjectId": {
      "type": "string",
      "minLength": 1
    },
    "actorId": {
      "type": "string",
      "minLength": 1
    }
  }
}

expenses.list

GET

List ledger entries, newest first. Filter by scope or category.

  • AI tool: expenses_list
  • API: GET /api/invoke/expenses.list

Input

Field Type Required Description
since any
until any
actorId string
projectId string
missionId string
sourceType string
category "ai-inference" | "human-labor" | "integration-fee" | "subscription" | "compute" | "travel" | "other"
limit integer
offset integer
orderBy string
orderDir "asc" | "desc"
q string
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "since": {},
    "until": {},
    "actorId": {
      "type": "string",
      "minLength": 1
    },
    "projectId": {
      "type": "string",
      "minLength": 1
    },
    "missionId": {
      "type": "string",
      "minLength": 1
    },
    "sourceType": {
      "type": "string"
    },
    "category": {
      "type": "string",
      "enum": [
        "ai-inference",
        "human-labor",
        "integration-fee",
        "subscription",
        "compute",
        "travel",
        "other"
      ]
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 500
    },
    "offset": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "orderBy": {
      "type": "string"
    },
    "orderDir": {
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ]
    },
    "q": {
      "type": "string"
    }
  }
}

expenses.add_manual

POST · mutating

Insert a manual expense (vendor bill, reimbursement, one-off). For any other cost, use the appropriate sidecar (time_entries.* / sms.send / etc.).

  • AI tool: expenses_add_manual
  • API: POST /api/invoke/expenses.add_manual

Input

Field Type Required Description
actorId string
category "ai-inference" | "human-labor" | "integration-fee" | "subscription" | "compute" | "travel" | "other"
amount number yes
currency string
occurredAt any
description string
projectId string
missionId string
subjectId string
ticketId string
metadata object
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "actorId": {
      "type": "string",
      "minLength": 1
    },
    "category": {
      "default": "other",
      "type": "string",
      "enum": [
        "ai-inference",
        "human-labor",
        "integration-fee",
        "subscription",
        "compute",
        "travel",
        "other"
      ]
    },
    "amount": {
      "type": "number"
    },
    "currency": {
      "default": "USD",
      "type": "string"
    },
    "occurredAt": {},
    "description": {
      "default": "",
      "type": "string"
    },
    "projectId": {
      "type": "string",
      "minLength": 1
    },
    "missionId": {
      "type": "string",
      "minLength": 1
    },
    "subjectId": {
      "type": "string",
      "minLength": 1
    },
    "ticketId": {
      "type": "string",
      "minLength": 1
    },
    "metadata": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    }
  },
  "required": [
    "amount"
  ]
}

expenses.backfill

POST · mutating

Walk a cost source's sidecar table and create ledger rows for anything that doesn't yet have one. Idempotent.

  • AI tool: expenses_backfill
  • API: POST /api/invoke/expenses.backfill

Input

Field Type Required Description
sourceType string yes
since any
until any
limit integer
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "sourceType": {
      "type": "string"
    },
    "since": {},
    "until": {},
    "limit": {
      "default": 5000,
      "type": "integer",
      "minimum": 1,
      "maximum": 50000
    }
  },
  "required": [
    "sourceType"
  ]
}

expenses.reattribute_llm

POST · mutating

Repair historical LLM cost rows that were stamped on human actors (old chat bug) — moves them to the workspace agent. Safe to run multiple times; only touches llm-trace rows on human actors.

  • AI tool: expenses_reattribute_llm
  • API: POST /api/invoke/expenses.reattribute_llm

Input

No parameters.

JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {},
  "additionalProperties": {}
}

expenses.cost_sources

GET

Catalog of registered cost sources (llm-trace, time-entry, salary-accrual, manual, integration-fee, …).

  • AI tool: expenses_cost_sources
  • API: GET /api/invoke/expenses.cost_sources

Input

No parameters.

JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {},
  "additionalProperties": {}
}