> ## Documentation Index
> Fetch the complete documentation index at: https://docs.costory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get one live enrichment document

> One live document in the JSON form of the YAML file. A response saved unmodified is a valid `PUT` body. `conditions` is the stored CEL and is omitted when unset. Any member.



## OpenAPI

````yaml https://app-api.costory.io/docs/openapi.json get /enrichments/{name}
openapi: 3.0.0
info:
  title: Costory
  version: '1.0'
  description: API Documentation
servers:
  - url: ''
    description: Production server
security: []
paths:
  /enrichments/{name}:
    get:
      tags:
        - Enrichments
      summary: Get one live enrichment document
      description: >-
        One live document in the JSON form of the YAML file. A response saved
        unmodified is a valid `PUT` body. `conditions` is the stored CEL and is
        omitted when unset. Any member.
      operationId: getEnrichment
      parameters:
        - schema:
            type: string
            description: Document name. Must match `name` in the body.
          required: true
          description: Document name. Must match `name` in the body.
          name: name
          in: path
      responses:
        '200':
          description: Live document
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnrichmentDocument'
              examples:
                merge:
                  summary: Merge columns from a key
                  description: >-
                    One key writes several columns. `merge` leaves a value the
                    row already has.
                  value:
                    name: 02_namespace_to_org
                    description: >-
                      EKS pods the pod label does not resolve -> namespace's
                      responsible organization
                    keyField: cos_namespace
                    priority: 2
                    conditions: >-
                      input.cos_cluster_name != null && input.cos_namespace !=
                      ""
                    targetColumns:
                      - name: owner_org
                        mode: merge
                      - name: owner_org_code
                        mode: merge
                    entries:
                      - key: team-a
                        then:
                          owner_org: Platform
                          owner_org_code: PLAT
                split:
                  summary: Split the cost
                  description: >-
                    One key splits the billed row. The weights of `then` sum to
                    1.
                  value:
                    name: 03_account_split
                    description: Split a shared account across the teams that use it
                    keyField: cos_account_id
                    priority: 3
                    targetColumns:
                      - name: owner_org
                        mode: merge
                    entries:
                      - key: '111122223333'
                        then:
                          - owner_org: Platform
                            weight: 0.6
                          - owner_org: Data
                            weight: 0.4
                datedReplace:
                  summary: Replace inside a date window
                  description: >-
                    The same key writes a different value in each window.
                    Windows for one key must not overlap. `replace` overwrites a
                    value the row already has.
                  value:
                    name: 04_project_owner
                    description: Project owner changed on 1 July 2024
                    keyField: cos_project_id
                    priority: 4
                    targetColumns:
                      - name: owner_org
                        mode: replace
                    entries:
                      - key: billing-prod
                        when:
                          start: '2024-01-01'
                          end: '2024-06-30'
                        then:
                          owner_org: Finance
                      - key: billing-prod
                        when:
                          start: '2024-07-01'
                        then:
                          owner_org: Platform
                metric:
                  summary: Split from a metric table
                  description: >-
                    One key splits each day's cost from a BigQuery measure.
                    `integrationId` is an active BigQuery integration.
                    `propagates` names the target columns the metric table
                    fills.
                  value:
                    name: 05_shared_ml_platform
                    description: Split a shared platform by daily CPU hours
                    keyField: cos_feature
                    priority: 5
                    targetColumns:
                      - name: app
                        mode: replace
                      - name: team
                        mode: replace
                      - name: cost_center
                        mode: replace
                    entries:
                      - key: shared-ml-platform
                        then:
                          integrationId: clx8f2k9a0001qw3h7bn2m5vz
                          metric:
                            table: >-
                              costory-prod.example_metrics.shared_ml_platform_usage
                            dateColumn: date
                            metricColumn: cpu_hours
                          propagates:
                            - app
                            - team
                            - cost_center
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
        '404':
          description: Unknown name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
      security:
        - bearerAuth: []
components:
  schemas:
    EnrichmentDocument:
      type: object
      properties:
        name:
          type: string
          description: Must match the name in the URL.
        description:
          type: string
        keyField:
          type: string
          description: Billing column whose value selects an entry.
        priority:
          type: integer
          minimum: 0
        conditions:
          type: string
          description: >-
            CEL expression. Every field is `input.` plus one SQL identifier.
            Omitted when unset.
        targetColumns:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              mode:
                type: string
                enum:
                  - replace
                  - merge
            required:
              - name
              - mode
        entries:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                description: Value of `keyField` this entry matches.
              when:
                type: object
                properties:
                  start:
                    type: string
                    description: Inclusive start, YYYY-MM-DD.
                  end:
                    type: string
                    description: Inclusive end, YYYY-MM-DD.
                description: Optional date window. Set start, end, or both.
              then:
                anyOf:
                  - type: object
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: number
                        - nullable: true
                          type: string
                          enum:
                            - null
                    description: >-
                      Column values this entry writes. `weight` is the share of
                      the billed row and defaults to 1.
                  - type: array
                    items:
                      type: object
                      additionalProperties:
                        anyOf:
                          - type: string
                          - type: number
                          - nullable: true
                            type: string
                            enum:
                              - null
                      description: >-
                        Column values this entry writes. `weight` is the share
                        of the billed row and defaults to 1.
                  - $ref: '#/components/schemas/EnrichmentMetricThen'
                description: >-
                  One allocation, several when the entry splits the cost, or a
                  metric then.
            required:
              - key
              - then
      required:
        - name
        - keyField
        - priority
        - targetColumns
        - entries
    Unauthorized:
      type: object
      properties:
        error:
          type: string
          description: Unauthorized error message
      required:
        - error
    NotFound:
      type: object
      properties:
        error:
          type: string
          description: Resource not found error code
      required:
        - error
    EnrichmentMetricThen:
      type: object
      properties:
        integrationId:
          type: string
          description: Active BigQuery integration of this organization.
        metric:
          type: object
          properties:
            table:
              type: string
              description: BigQuery table as project.dataset.table.
            dateColumn:
              type: string
            metricColumn:
              type: string
          required:
            - table
            - dateColumn
            - metricColumn
        propagates:
          type: array
          items:
            type: string
          description: Target columns filled from the metric table.
      required:
        - integrationId
        - metric
        - propagates
      description: >-
        Split the billed row by a daily BigQuery measure instead of static
        weights.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT or Clerk ak_* API key
      description: >-
        Send `Authorization: Bearer <credential>` using either a Clerk session
        JWT or a Clerk API key (`ak_*`). API keys may identify a user (`user_*`)
        or organization (`org_*`) principal and are generated in the Clerk
        Dashboard under API keys.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.