> ## 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 shipping cost settings

> Switch the shipping cost attribution method. `fixedRateAmount` is
required when `method=fixed_rate`.

Triggers a per-order COGS recalculation downstream.

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




## OpenAPI

````yaml /api-reference/openapi.yaml put /accounts/api/costs/shipping-settings
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/shipping-settings:
    put:
      tags:
        - Costs
      summary: Update shipping cost settings
      description: |
        Switch the shipping cost attribution method. `fixedRateAmount` is
        required when `method=fixed_rate`.

        Triggers a per-order COGS recalculation downstream.

        **Required scope:** `costs:write`.
      operationId: updateShippingSettings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateShippingSettingsRequest'
            examples:
              fixedRate:
                summary: Flat $7.50 per order
                value:
                  method: fixed_rate
                  fixedRateAmount: 7.5
                  currency: USD
              shopify:
                summary: Use Shopify-charged shipping
                value:
                  method: shopify_charges
      responses:
        '200':
          description: The updated shipping configuration.
          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:
    UpdateShippingSettingsRequest:
      type: object
      required:
        - method
      properties:
        method:
          $ref: '#/components/schemas/ShippingMethod'
        fixedRateAmount:
          type: number
          minimum: 0
          description: >-
            Required when `method=fixed_rate`. Applied as the per-order shipping
            cost.
        currency:
          type: string
          description: ISO currency code (e.g. `USD`).
    ShippingMethod:
      type: string
      enum:
        - shopify_charges
        - fixed_rate
        - shipping_profiles
      description: >
        Shipping cost attribution method.

        - `shopify_charges` — use the shipping charge captured on each order.

        - `fixed_rate` — apply a flat per-order amount (`fixedRateAmount`
        required).

        - `shipping_profiles` — match shipping zones / weights configured in
        Shopify.
    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.

````