---
title: "Genai Custom Attrs Schema"
method: POST
path: "/agents/spans/custom-attrs/schema"
tags: ["Agents"]
---

# Genai Custom Attrs Schema

`POST /agents/spans/custom-attrs/schema`

## Request

- Base URL: `https://trace.wandb.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://trace.wandb.ai/agents/spans/custom-attrs/schema`
- Auth: none declared

Discover typed custom attribute keys on matching agent spans.

## Request body

- AgentCustomAttrsSchemaReq: Request to discover typed custom attribute keys for matching spans.
  - `project_id` string, required
  - `query` Query
    - `$expr` union, required
      - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
        - `$and` union[], required
          - union
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation (recursive)
            - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
              - …
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
              - …
      - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
        - `$or` union[], required
          - union
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
              - …
            - OrOperation (recursive)
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
              - …
      - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
        - `$not` unknown[], required
          - unknown
      - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
        - `$eq` unknown[], required
          - unknown
      - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$gt` unknown[], required
          - unknown
      - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$lt` unknown[], required
          - unknown
      - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$gte` unknown[], required
          - unknown
      - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
        - `$lte` unknown[], required
          - unknown
      - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
        - `$in` unknown[], required
          - unknown
      - ContainsOperation: Case-insensitive substring match. Not part of MongoDB. Weave-specific addition. Example: ``` { "$contains": { "input": {"$getField": "display_name"}, "substr": {"$literal": "llm"}, "case_insensitive": true } } ```
        - `$contains` ContainsSpec, required: Specification for the `$contains` operation. - `input`: The string to search. - `substr`: The substring to search for. - `case_insensitive`: If true, match is case-insensitive.
          - `input` union, required
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
              - …
            - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
              - …
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation (recursive)
          - `substr` union, required
            - LiteralOperation: Represents a constant value in the query language. This can be any standard JSON-serializable value. Example: ``` {"$literal": "predict"} ```
              - …
            - GetFieldOperator: Access a field on the traced call. Supports dot notation for nested access, e.g. `summary.usage.tokens`. Only works on fields present in the `CallSchema`, including: - Top-level fields like `op_name`, `trace_id`, `started_at` - Nested fields like `inputs.input_name`, `summary.usage.tokens`, etc. Example: ``` {"$getField": "op_name"} ```
              - …
            - ConvertOperation: Convert the input value to a specific type (e.g., `int`, `bool`, `string`). Example: ``` { "$convert": { "input": {"$getField": "inputs.value"}, "to": "int" } } ```
              - …
            - SizeOperation: Return the number of elements in a collection or characters in a string. Example: ``` {"$size": {"$getField": "scorer_tags"}} ```
              - …
            - AndOperation: Logical AND. All conditions must evaluate to true. Example: ``` { "$and": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "predict"}]}, {"$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 1000}]} ] } ```
              - …
            - OrOperation: Logical OR. At least one condition must be true. Example: ``` { "$or": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "a"}]}, {"$eq": [{"$getField": "op_name"}, {"$literal": "b"}]} ] } ```
              - …
            - NotOperation: Logical NOT. Inverts the condition. Example: ``` { "$not": [ {"$eq": [{"$getField": "op_name"}, {"$literal": "debug"}]} ] } ```
              - …
            - EqOperation: Equality check between two operands. Example: ``` { "$eq": [{"$getField": "op_name"}, {"$literal": "predict"}] } ```
              - …
            - GtOperation: Greater than comparison. Example: ``` { "$gt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LtOperation: Less than comparison. Example: ``` { "$lt": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - GteOperation: Greater than or equal comparison. Example: ``` { "$gte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - LteOperation: Less than or equal comparison. Example: ``` { "$lte": [{"$getField": "summary.usage.tokens"}, {"$literal": 100}] } ```
              - …
            - InOperation: Membership check. Returns true if the left operand is in the list provided as the second operand. Example: ``` { "$in": [ {"$getField": "op_name"}, [{"$literal": "predict"}, {"$literal": "generate"}] ] } ```
              - …
            - ContainsOperation (recursive)
          - `case_insensitive` boolean, nullable
  - `started_after` string, date-time, nullable
  - `started_before` string, date-time, nullable
  - `limit` integer
  - `offset` integer

## Response `200`

Successful Response

- AgentCustomAttrsSchemaRes: Typed custom attribute keys available for spans query/group/stats APIs.
  - `attributes` AgentCustomAttrSchemaItem[], required
    - `source` 'custom_attrs_string' | 'custom_attrs_int' | 'custom_attrs_float' | 'custom_attrs_bool', required
    - `key` string, required
    - `value_type` 'string' | 'int' | 'float' | 'bool', required
    - `span_count` integer, required
  - `limit` integer, required
  - `offset` integer, required
  - `has_more` boolean, required

## Other responses

- `422`: Validation Error

## Changes

- **2026-10-16** `dd89fadfe4e4`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/wandb/apis/fastapi/changes/agents/spans/custom-attrs/schema/post.md)

---

[API](https://skmtc.dev/wandb/apis/fastapi.md) - [All operations](https://skmtc.dev/wandb/apis/fastapi/llms.txt) - [OpenAPI document](https://skmtc.dev/wandb/apis/fastapi/revisions/f7643c49bf2e?raw)
