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

# Update a cost line

> Partial-update an existing cost line by its ULID. Only the fields
supplied in `updates` are written; omitted fields stay as-is.
Triggers a per-order COGS recalculation downstream (except for
`variable` and `fixed`).

**Required scope:** `costs:write`.




## OpenAPI

````yaml /api-reference/openapi.yaml put /accounts/api/costs/lines/{lineId}
openapi: 3.1.0
info:
  title: Upstack Data API
  version: '1.0'
  description: >
    Programmatic access to your Upstack Data pixel — analytics queries, the

    measures/dimensions catalog, and dashboard view management.


    All requests authenticate with two headers:


    - `x-api-key`: your Upstack API key (mint one at **Settings → API Keys** in
    the dashboard).

    - `x-pixel-id`: the pixel id the request targets. One key is scoped to one
    pixel.
servers:
  - url: https://api.upstackdata.com
    description: Production
security:
  - apiKey: []
    pixelId: []
tags:
  - name: Analytics
    description: Query events, attribution, and cohort analyses.
  - name: Catalog
    description: List the measures available to your pixel.
  - name: Dashboards
    description: >-
      Manage dashboard views — create, update, copy, delete, and the high-level
      preset builder.
  - name: Account
    description: >-
      Read and update the account that owns this API key — display name, active
      owners and admins, and subscription summary.
  - name: Costs
    description: >-
      Read and update every cost surface — global product overrides, shipping
      method, per-variant handling fees and COGS history, and per-type cost
      lines (order / gateway / shipping profile / variable / fixed). Mutations
      trigger the same per-order COGS recalculation as web-UI changes.
  - name: Products
    description: Browse products + variants in the configured catalog.
  - name: Events
    description: Send server-side tracking events directly from your backend.
paths:
  /accounts/api/costs/lines/{lineId}:
    put:
      tags:
        - Costs
      summary: Update a cost line
      description: |
        Partial-update an existing cost line by its ULID. Only the fields
        supplied in `updates` are written; omitted fields stay as-is.
        Triggers a per-order COGS recalculation downstream (except for
        `variable` and `fixed`).

        **Required scope:** `costs:write`.
      operationId: updateCostLine
      parameters:
        - name: lineId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCostLineRequest'
            examples:
              bumpRate:
                summary: Change a variable-cost percent rate
                value:
                  costType: variable
                  updates:
                    percentRate: 2.5
      responses:
        '200':
          description: The updated cost config.
          content:
            application/json:
              schema:
                type: object
                required:
                  - config
                properties:
                  config:
                    type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    UpdateCostLineRequest:
      type: object
      required:
        - costType
        - updates
      description: |
        Partial update — every field of the corresponding line shape is
        optional in `updates`. Only the supplied fields are written;
        omitted fields stay as-is.
      properties:
        costType:
          $ref: '#/components/schemas/LineCostType'
        updates:
          type: object
          description: Subset of fields from the line shape selected by `costType`.
          additionalProperties: true
    LineCostType:
      type: string
      enum:
        - order
        - gateway
        - shipping
        - variable
        - fixed
      description: |
        The five cost-line surfaces. Each value selects the corresponding
        line shape in the `line` (POST) or `updates` (PUT) field of the
        request body.
    Error:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human-readable error message.
        errors:
          type: array
          description: Per-field validation errors (present on 400 responses).
          items:
            type: object
            properties:
              message:
                type: string
              key:
                type: string
              path:
                type: array
                items:
                  type: string
  responses:
    BadRequest:
      description: Validation error. Includes an `errors` array with per-field detail.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: >-
        Missing or invalid `x-api-key` / `x-pixel-id`, or key is
        revoked/expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        API key does not carry the required scope for this endpoint, or body
        `pixelId` does not match the `x-pixel-id` header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The addressed resource does not exist (or belongs to a different pixel).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Your Upstack API key. Starts with `upstack_`.
    pixelId:
      type: apiKey
      in: header
      name: x-pixel-id
      description: The pixel id the request targets.

````