View all methods

aiToolMetrics.pushAll

Add multiple daily usage data records for bespoke AI tools by email, date, and tool combinations in a single request.

Facts

Method POST https://yourinstance.getdx.net/api/aiToolMetrics.pushAll

Arguments

Required arguments

Name Type Description
token Token Auth token passed as an HTTP header.
data Array Array of AI tool metrics records.

Data array object structure

Each object in the data array should contain:

Required fields

Name Type Description
email String User email address.
date String Metrics recording date.
is_active Boolean User activity flag.
tool String AI tool name.

Optional fields

Name Type Description
metrics JSON Object Usage data object.
input_tokens Integer Number of input tokens consumed.
output_tokens Integer Number of output tokens generated.
cache_write_tokens Integer Number of tokens written to cache.
cache_read_tokens Integer Number of tokens read from cache.
spend_cents Integer Amount spent in cents.

Usage info

AI Tool Metrics API methods can be used to add daily usage data for bespoke AI tools to your Data Cloud instance. It allows you to store metrics by email, date, and tool combinations with flexible JSON data. An additional is_active flag can be provided for each record. The records are stored in the bespoke_ai_tool_daily_metrics table that is queryable in Data Studio alongside all of your other Data Cloud data.

This method uses the same API request format as aiToolMetrics.push, except the arguments can be passed inside an array under the data key, allowing you to submit multiple records in a single request.

For more information about the supported SQL operators and functions available for querying the JSON values please reference the PostgreSQL documentation.

Response

Returns an array of created records, each containing:

Name Type Description
id String Generated unique ID for the record.
email String User email address.
date String Metrics recording date.
is_active Boolean User activity flag.
tool String AI tool name.
metrics JSON Object Usage data object.
input_tokens Integer Number of input tokens consumed.
output_tokens Integer Number of output tokens generated.
cache_write_tokens Integer Number of tokens written to cache.
cache_read_tokens Integer Number of tokens read from cache.
spend_cents Integer Amount spent in cents.

Example request

This is a typical request:

curl -X POST https://yourinstance.getdx.net/api/aiToolMetrics.pushAll \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer xxxx-xxxxxxxxx-xxxx' \
  -H 'Content-Type: application/json' \
  --data '{
    "data": [
      {
        "email": "engineer1@company.com",
        "date": "2025-01-15",
        "is_active": true,
        "tool": "tabnine",
        "metrics": {"lines": 150},
        "input_tokens": 10000,
        "output_tokens": 500,
        "cache_write_tokens": 2000,
        "cache_read_tokens": 1000,
        "spend_cents": 100
      }
    ]
  }'