> ## 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.

# Get a product variant

> Returns one variant in full — identity, its parent product's details,
current price, handling fee, and both cost histories.

`productCost` is `null` when the pixel has no such variant.

**Required scope:** `costs:read`.




## OpenAPI

````yaml /api-reference/openapi.yaml get /accounts/api/products/{productId}/{variantId}/cost
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: >-
      Upstack Conversion API (CAPI) — send server-side tracking events from your
      backend.
paths:
  /accounts/api/products/{productId}/{variantId}/cost:
    get:
      tags:
        - Products
      summary: Get a product variant
      description: |
        Returns one variant in full — identity, its parent product's details,
        current price, handling fee, and both cost histories.

        `productCost` is `null` when the pixel has no such variant.

        **Required scope:** `costs:read`.
      operationId: getProductCost
      parameters:
        - name: productId
          in: path
          required: true
          schema:
            type: string
        - name: variantId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The variant record, or `null` when the variant doesn't exist.
          content:
            application/json:
              schema:
                type: object
                required:
                  - productCost
                properties:
                  productCost:
                    allOf:
                      - $ref: '#/components/schemas/ProductVariant'
                    nullable: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    ProductVariant:
      type: object
      description: >
        A stored product variant, synced from Shopify. Each variant record also

        carries its parent product's details, so one call gives you both.


        The fields below are the ones worth relying on; the record also includes

        internal index keys (lowercased titles, composite ids) that you should
        ignore.
      additionalProperties: true
      properties:
        productId:
          type: string
        variantId:
          type: string
        sku:
          type: string
        variantTitle:
          type: string
          description: The variant's own name, e.g. "Medium / Blue".
        productTitle:
          type: string
          description: The parent product's name.
        handle:
          type: string
          description: The parent product's Shopify URL handle.
        vendor:
          type: string
        productType:
          type: string
        status:
          type: string
          description: The parent product's Shopify status, e.g. `ACTIVE`.
        tags:
          type: array
          items:
            type: string
        imageUrls:
          type: array
          items:
            type: string
        currency:
          type: string
        currentPrice:
          type: number
          description: The variant's current selling price.
        handlingFee:
          type: number
          description: Per-unit handling fee, set via the handling-fee endpoint.
        shopifyCostHistory:
          type: array
          description: Cost lines synced from Shopify inventory (read-only).
          items:
            $ref: '#/components/schemas/CostHistoryEntry'
        manualCostHistory:
          type: array
          description: >-
            Cost lines you set through the COGS endpoints. Takes precedence over
            the Shopify cost.
          items:
            $ref: '#/components/schemas/CostHistoryEntry'
        variant:
          type: object
          additionalProperties: true
          description: >-
            The raw Shopify variant payload as synced, including inventory
            quantity.
        pixelId:
          type: string
        createdAt:
          type: string
        updatedAt:
          type: string
    CostHistoryEntry:
      type: object
      required:
        - id
        - cost
        - effectiveStartDate
        - effectiveEndDate
      properties:
        id:
          type: string
          description: Server-assigned ULID for the COG line.
        cost:
          type: number
          description: Per-unit cost in the account's reporting currency.
        effectiveStartDate:
          type: string
          description: ISO-8601 date this entry begins applying.
        effectiveEndDate:
          type: string
          nullable: true
          description: ISO-8601 date this entry stops applying — `null` for open-ended.
        description:
          type: string
          description: Optional human-readable note (e.g. "Q1 batch").
    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: >
        The `x-api-key` or `x-pixel-id` header is missing. The request is
        rejected

        before it reaches the API, and the body is `{"message":
        "Unauthorized"}`.

        A key that is present but not accepted returns `403`, not `401`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >
        The key was rejected, or it is valid but not allowed to do this. Either:


        - the key is unknown, revoked, or expired, or the pixel is inactive —
        the body is
          `{"Message": "User is not authorized to access this resource with an explicit deny
          in an identity-based policy"}` (note the capital `M`);
        - the key doesn't carry the scope this endpoint needs, or the body
        `pixelId` doesn't
          match the `x-pixel-id` header — the body is `{"message": "…"}` as described below.
      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.

````