Measura API documentation · v1

Get specific variant

Retrieve a specific variant by product ID and variant ID.

Code example
GET /api/v1/products/{productId}/variants/{variantId}

Headers:
  Authorization: Bearer <api-key>
  Content-Type: application/json

Path parameters

Scroll horizontally to see all columns.

ParameterTypeDescription
productIdstringRequired - The Shopify product REST ID
variantIdstringRequired - The Shopify variant REST ID

Query parameters

Scroll horizontally to see all columns.

ParameterTypeDescription
location_idstring (optional)Positive numeric Shopify location REST ID. Include it to add current measured inventory for one location. Omit it to preserve the existing response and five-minute cache.

Response example (200 success)

Code example
{
  "success": true,
  "data": {
    "variant": {
      "id": "456",
      "isMeasuraEligible": true,
      "fractionalInventory": { "123456": { "quantity": 0.25 } },
      "inventory": {
        "locationId": "123456",
        "tracked": true,
        "available": { "quantity": 12.25, "unit": "kg" }
      },
      "unitMeasurement": {
        "unit": "kg",
        "value": 1
      },
      "settings": {
        "onlineStore": {
          "displayStyle": "number",
          "rules": {
            "min": 0.5,
            "increment": 0.5,
            "defaultValue": 1
          }
        }
      },
      "product": {
        "id": "123",
        "measurementType": "weight"
      }
    }
  },
  "error": null
}

Response fields

Scroll horizontally to see all columns.

FieldTypeDescription
successbooleanIndicates whether the request was successful
dataobjectResponse data object
errornullNull for a successful request
data.variant.inventoryobject (optional)Present only with location_id. The example includes location_id=123456 and Shopify available stock of 12 plus a 0.25 remainder.
data.variant.inventory.locationIdstringRequested Shopify location REST ID.
data.variant.inventory.trackedbooleanWhether Shopify tracks this inventory item.
data.variant.inventory.availableobject | nullMeasured quantity and unit. Null when untracked or not stocked at this location; zero is a real balance.
data.variant.inventory.available.quantitynumberShopify available stock plus its owned fractional remainder, multiplied by unitMeasurement.value. Negative quantities are preserved.
data.variant.inventory.available.unitstringThe configured unitMeasurement.unit, for example kg or g.
data.variantVariantThe variant object

Error responses

Scroll horizontally to see all columns.

Status codeDescription
400Bad Request - Missing product ID or variant ID, or invalid location_id (including an empty value or a GID)
401Unauthorized - Missing or invalid API key
403Forbidden - Public API access is unavailable for this shop
422Unprocessable Entity - Product is not configured for sell-by-measurement, or a location-specific read targets a variant excluded from Measura
429Too Many Requests - API rate limit exceeded
404Not Found - Unknown location, missing variant, or variant does not belong to the specified product
500Internal Server Error - Server error while processing the request

Note

For current stock, request /api/v1/products/123/variants/456?location_id=123456. The example above shows this opt-in response. Without location_id, inventory is omitted and the existing private five-minute cache applies. With location_id, response caches are bypassed and Cache-Control is no-store.

fractionalInventory keeps its existing map of fulfillment-location remainders, even when location_id is supplied. It is not filtered to the requested location. The new inventory field can also read a location outside that fulfillment list.

Availability is measured available stock, not on-hand stock or a reservation. For 12 Shopify units plus 0.75 remainder at 100 g per stock unit, available is 1275 g. Negative remainders from upward rounding are valid. Configuration still uses the existing settings cache; a concurrent inventory write may be in progress.

Untracked inventory returns tracked=false and available=null. A tracked item without a stock level at this location returns tracked=true and available=null. Missing, malformed, or foreign-owned fractional values contribute zero; legacy ownerless values remain accepted.

The variant must belong to the specified product. Without location_id, excluded variants remain readable with isMeasuraEligible=false. A location-specific measured inventory request for an excluded variant returns 422.

Related:

See the Variant object and Product object documentation for response structure details.