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

# Get a Products Variations

> Gets variations for a variable product.




## OpenAPI

````yaml api-reference/v2/openapi-v2-stable.yaml get /products/{id}/variations
openapi: 3.0.3
info:
  title: CoCart - Cart API v2
  version: 4.6.0
  description: >
    CoCart REST API v2 for managing shopping carts, products, and store
    functionality.

    Compared to API v1, this version provides enhanced endpoints for cart
    operations, product management,

    and administrative functions with improved response structures and better
    error handling.
  termsOfService: http://cocartapi.com/terms-of-conditions-polar/
  contact:
    email: support@cocartapi.com
  license:
    name: GNU General Public License v3.0
    url: http://www.gnu.org/licenses/gpl-3.0.html
servers:
  - url: '{protocol}://{host}/wp-json/cocart/v2'
    description: API v2
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      host:
        default: example-store.com
        description: Your store domain
security: []
tags:
  - name: cart
    description: Operations for managing the shopping cart
  - name: cart-items
    description: Operations for managing cart items
  - name: cart-calculate
    description: Operations for calculating cart totals
  - name: products
    description: Operations for browsing and retrieving product information
  - name: product-attributes
    description: Operations for retrieving product attributes and attribute terms
  - name: product-categories
    description: Operations for browsing and filtering product categories
  - name: product-tags
    description: Operations for browsing and filtering product tags
  - name: product-reviews
    description: Operations for retrieving product reviews and ratings
  - name: product-variations
    description: Operations for retrieving variable product variations
  - name: admin-sessions
    description: Administrative operations for managing cart sessions
  - name: authentication
    description: Operations for user authentication
  - name: store
    description: Operations for retrieving store information and configuration
externalDocs:
  description: Find out more about CoCart API
  url: https://docs.cocartapi.com
paths:
  /products/{id}/variations:
    get:
      tags:
        - product-variations
      summary: Get product variations
      description: |
        Gets variations for a variable product.
      parameters:
        - name: id
          in: path
          description: Unique identifier for the variable product.
          required: true
          schema:
            type: integer
        - name: page
          in: query
          description: Current page of the collection.
          schema:
            type: integer
            default: 1
        - name: per_page
          in: query
          description: Maximum number of items to return per page.
          schema:
            type: integer
            default: 10
      responses:
        '200':
          description: Product variations retrieved successfully.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProductVariation'
              example:
                - id: 289
                  parent_id: 278
                  name: Premium Cotton T-Shirt - Large, Navy Blue
                  slug: premium-cotton-t-shirt-large-navy-blue
                  permalink: >-
                    https://example-store.com/product/premium-cotton-t-shirt/?attribute_pa_size=large&attribute_pa_color=navy-blue
                  sku: PCT-2024-L-NAVY
                  description: Premium Cotton T-Shirt in Large, Navy Blue
                  dates:
                    created: '2024-02-10T09:15:00'
                    created_gmt: '2024-02-10T14:15:00'
                    modified: '2024-09-18T11:45:00'
                    modified_gmt: '2024-09-18T16:45:00'
                  featured: false
                  prices:
                    price: '80.00'
                    regular_price: '80.00'
                    sale_price: ''
                    price_range: null
                    on_sale: false
                    date_on_sale:
                      from: null
                      from_gmt: null
                      to: null
                      to_gmt: null
                    currency:
                      code: USD
                      symbol: $
                      position: left
                      decimal_separator: .
                      thousand_separator: ','
                      decimals: 2
                  hidden_conditions:
                    virtual: false
                    downloadable: false
                    manage_stock: true
                    sold_individually: false
                    shipping_required: true
                  images:
                    - id: 724
                      src:
                        thumbnail: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-navy-150x150.jpg
                        medium: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-navy-300x300.jpg
                        large: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-navy-600x600.jpg
                        full: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-navy.jpg
                      name: tshirt-navy
                      alt: Premium Cotton T-Shirt in Navy Blue
                      position: 0
                      featured: true
                  categories:
                    - id: 15
                      name: Clothing
                      slug: clothing
                      rest_url: >-
                        https://example-store.com/wp-json/cocart/v2/products/categories/15
                    - id: 22
                      name: T-Shirts
                      slug: t-shirts
                      rest_url: >-
                        https://example-store.com/wp-json/cocart/v2/products/categories/22
                  tags:
                    - id: 8
                      name: Premium
                      slug: premium
                      rest_url: >-
                        https://example-store.com/wp-json/cocart/v2/products/tags/8
                  attributes:
                    - id: 1
                      name: Size
                      position: 0
                      visible: true
                      variation: true
                      options:
                        - Large
                    - id: 2
                      name: Color
                      position: 1
                      visible: true
                      variation: true
                      options:
                        - Navy Blue
                  stock:
                    is_in_stock: true
                    stock_quantity: 45
                    stock_status: instock
                    backorders: 'no'
                    backorders_allowed: false
                    backordered: false
                    low_stock_amount: null
                  weight:
                    value: '0.2'
                    unit: kg
                  dimensions:
                    length: '12'
                    width: '10'
                    height: '1'
                    unit: cm
                  total_sales: 156
                  add_to_cart:
                    text: Add to cart
                    description: Add Premium Cotton T-Shirt - Large, Navy Blue to your cart
                    is_purchasable: true
                    purchase_quantity:
                      min_purchase: 1
                      max_purchase: 45
                    rest_url: https://example-store.com/wp-json/cocart/v2/cart/add-item
                  meta_data:
                    - key: _fabric
                      value: 100% Cotton
                - id: 290
                  parent_id: 278
                  name: Premium Cotton T-Shirt - Medium, White
                  slug: premium-cotton-t-shirt-medium-white
                  permalink: >-
                    https://example-store.com/product/premium-cotton-t-shirt/?attribute_pa_size=medium&attribute_pa_color=white
                  sku: PCT-2024-M-WHT
                  description: Premium Cotton T-Shirt in Medium, White
                  dates:
                    created: '2024-02-10T09:15:00'
                    created_gmt: '2024-02-10T14:15:00'
                    modified: '2024-09-18T11:45:00'
                    modified_gmt: '2024-09-18T16:45:00'
                  featured: false
                  prices:
                    price: '25.00'
                    regular_price: '30.00'
                    sale_price: '25.00'
                    price_range: null
                    on_sale: true
                    date_on_sale:
                      from: '2024-09-01T00:00:00'
                      from_gmt: '2024-09-01T05:00:00'
                      to: '2024-10-31T23:59:59'
                      to_gmt: '2024-11-01T04:59:59'
                    currency:
                      code: USD
                      symbol: $
                      position: left
                      decimal_separator: .
                      thousand_separator: ','
                      decimals: 2
                  hidden_conditions:
                    virtual: false
                    downloadable: false
                    manage_stock: true
                    sold_individually: false
                    shipping_required: true
                  images:
                    - id: 723
                      src:
                        thumbnail: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-white-150x150.jpg
                        medium: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-white-300x300.jpg
                        large: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-white-600x600.jpg
                        full: >-
                          https://example-store.com/wp-content/uploads/2024/02/tshirt-white.jpg
                      name: tshirt-white
                      alt: Premium Cotton T-Shirt in White
                      position: 0
                      featured: true
                  categories:
                    - id: 15
                      name: Clothing
                      slug: clothing
                      rest_url: >-
                        https://example-store.com/wp-json/cocart/v2/products/categories/15
                    - id: 22
                      name: T-Shirts
                      slug: t-shirts
                      rest_url: >-
                        https://example-store.com/wp-json/cocart/v2/products/categories/22
                  tags:
                    - id: 8
                      name: Premium
                      slug: premium
                      rest_url: >-
                        https://example-store.com/wp-json/cocart/v2/products/tags/8
                  attributes:
                    - id: 1
                      name: Size
                      position: 0
                      visible: true
                      variation: true
                      options:
                        - Medium
                    - id: 2
                      name: Color
                      position: 1
                      visible: true
                      variation: true
                      options:
                        - White
                  stock:
                    is_in_stock: true
                    stock_quantity: 78
                    stock_status: instock
                    backorders: 'no'
                    backorders_allowed: false
                    backordered: false
                    low_stock_amount: null
                  weight:
                    value: '0.2'
                    unit: kg
                  dimensions:
                    length: '12'
                    width: '10'
                    height: '1'
                    unit: cm
                  total_sales: 243
                  add_to_cart:
                    text: Add to cart
                    description: Add Premium Cotton T-Shirt - Medium, White to your cart
                    is_purchasable: true
                    purchase_quantity:
                      min_purchase: 1
                      max_purchase: 78
                    rest_url: https://example-store.com/wp-json/cocart/v2/cart/add-item
                  meta_data:
                    - key: _fabric
                      value: 100% Cotton
        '400':
          description: Bad request - invalid product ID or parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: cocart_invalid_parameter
                message: Invalid product ID or parameter provided.
                data:
                  status: 400
        '404':
          description: Product not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: cocart_product_not_found
                message: Product not found or is not a variable product.
                data:
                  status: 404
components:
  schemas:
    ProductVariation:
      type: object
      description: >
        CoCart v2 Product Variation object. Variations use the same structure as
        Product objects,

        but with the following fields removed: type, short_description,
        hidden_conditions.reviews_allowed,

        average_rating, review_count, rating_count, rated_out_of, reviews,
        default_attributes,

        variations, grouped_products, related, upsells, cross_sells,
        external_url, button_text,

        and add_to_cart.has_options.
      properties:
        id:
          type: integer
          description: Unique identifier for the variation
        parent_id:
          type: integer
          description: Product parent ID (the variable product this variation belongs to)
        name:
          type: string
          description: Variation name
        slug:
          type: string
          description: Variation slug
        permalink:
          type: string
          description: Variation URL
        sku:
          type: string
          description: Unique identifier (SKU)
        description:
          type: string
          description: Variation description
        dates:
          type: object
          description: Variation dates
          properties:
            created:
              type: string
              format: date-time
              description: Date created in local time
            created_gmt:
              type: string
              format: date-time
              description: Date created in GMT
            modified:
              type: string
              format: date-time
              description: Date modified in local time
            modified_gmt:
              type: string
              format: date-time
              description: Date modified in GMT
        featured:
          type: boolean
          description: Whether the variation is featured
        prices:
          type: object
          description: Variation pricing information
          properties:
            price:
              type: string
              description: Current variation price
            regular_price:
              type: string
              description: Variation regular price
            sale_price:
              type: string
              description: Variation sale price (empty string if not on sale)
            price_range:
              type: object
              description: Price range (null for variations)
              nullable: true
            on_sale:
              type: boolean
              description: Whether the variation is on sale
            date_on_sale:
              type: object
              description: Sale date information
              properties:
                from:
                  type: string
                  format: date-time
                  nullable: true
                  description: Sale start date in local time
                from_gmt:
                  type: string
                  format: date-time
                  nullable: true
                  description: Sale start date in GMT
                to:
                  type: string
                  format: date-time
                  nullable: true
                  description: Sale end date in local time
                to_gmt:
                  type: string
                  format: date-time
                  nullable: true
                  description: Sale end date in GMT
            currency:
              $ref: '#/components/schemas/Currency'
        hidden_conditions:
          type: object
          description: Variation conditional flags (note reviews_allowed is not present)
          properties:
            virtual:
              type: boolean
              description: Whether the variation is virtual
            downloadable:
              type: boolean
              description: Whether the variation is downloadable
            manage_stock:
              type: boolean
              description: Whether stock is managed at variation level
            sold_individually:
              type: boolean
              description: Whether only one item can be bought in a single order
            shipping_required:
              type: boolean
              description: Whether the variation needs to be shipped
        images:
          type: array
          description: Variation images
          items:
            $ref: '#/components/schemas/ProductImage'
        categories:
          type: array
          description: Product categories (inherited from parent)
          items:
            $ref: '#/components/schemas/ProductCategory'
        tags:
          type: array
          description: Product tags (inherited from parent)
          items:
            $ref: '#/components/schemas/ProductTag'
        attributes:
          type: array
          description: Variation attributes
          items:
            $ref: '#/components/schemas/ProductAttribute'
        stock:
          type: object
          description: Stock information
          properties:
            is_in_stock:
              type: boolean
              description: Whether the variation is in stock
            stock_quantity:
              type: integer
              nullable: true
              description: Stock quantity (null if not managing stock)
            stock_status:
              type: string
              description: Stock status
              enum:
                - instock
                - outofstock
                - onbackorder
            backorders:
              type: string
              description: If managing stock, this controls if backorders are allowed
              enum:
                - 'no'
                - notify
                - 'yes'
            backorders_allowed:
              type: boolean
              description: Whether backorders are allowed
            backordered:
              type: boolean
              description: Whether the variation is on backorder
            low_stock_amount:
              type: integer
              nullable: true
              description: Low stock threshold amount
        weight:
          type: object
          description: Variation weight
          properties:
            value:
              type: string
              nullable: true
              description: Weight value
            unit:
              type: string
              description: Weight unit (kg, g, lbs, oz, etc.)
        dimensions:
          type: object
          description: Variation dimensions
          properties:
            length:
              type: string
              nullable: true
              description: Length value
            width:
              type: string
              nullable: true
              description: Width value
            height:
              type: string
              nullable: true
              description: Height value
            unit:
              type: string
              description: Dimension unit (cm, m, in, etc.)
        total_sales:
          type: integer
          description: Total number of sales for this variation
        add_to_cart:
          type: object
          description: Add to cart information (note has_options is not present)
          properties:
            text:
              type: string
              description: Add to cart button text
            description:
              type: string
              description: Add to cart description
            is_purchasable:
              type: boolean
              description: Whether the variation is purchasable
            purchase_quantity:
              type: object
              description: Purchase quantity limits
              properties:
                min_purchase:
                  type: integer
                  description: Minimum purchase quantity
                max_purchase:
                  type: integer
                  description: Maximum purchase quantity allowed
            rest_url:
              type: string
              description: REST URL for adding this variation to cart
        meta_data:
          type: array
          description: Meta data
          items:
            type: object
            properties:
              key:
                type: string
              value:
                type: string
    ErrorResponse:
      type: object
      description: Standard error response structure.
      properties:
        code:
          type: string
          description: Machine-readable error code.
          example: cocart_invalid_parameter
        message:
          type: string
          description: Human-readable error message.
          example: Invalid parameter provided.
        data:
          type: object
          description: Additional error data.
          properties:
            status:
              type: integer
              description: HTTP status code.
              example: 400
            params:
              type: object
              description: Parameter-specific error details.
              additionalProperties: true
          additionalProperties: true
    Currency:
      type: object
      properties:
        currency_code:
          type: string
          description: Currency code.
        currency_symbol:
          type: string
          description: Currency symbol.
        currency_symbol_pos:
          type: string
          description: Currency symbol position.
        currency_minor_unit:
          type: integer
          description: Currency minor unit.
        currency_decimal_separator:
          type: string
          description: Currency decimal separator.
        currency_thousand_separator:
          type: string
          description: Currency thousand separator.
        currency_prefix:
          type: string
          description: Currency prefix.
        currency_suffix:
          type: string
          description: Currency suffix.
    ProductImage:
      type: object
      description: CoCart v2 Product Image with multiple size URLs
      properties:
        id:
          type: integer
          description: Image ID
        src:
          type: object
          description: Image URLs in different sizes
          additionalProperties:
            type: string
            description: URL for specific image size (thumbnail, medium, large, full, etc.)
        name:
          type: string
          description: Image name
        alt:
          type: string
          description: Image alternative text
        position:
          type: integer
          description: Image position in gallery
        featured:
          type: boolean
          description: Whether this is the featured image
    ProductCategory:
      type: object
      description: CoCart v2 Product Category
      properties:
        id:
          type: integer
          description: Category ID
        name:
          type: string
          description: Category name
        slug:
          type: string
          description: Category slug
        rest_url:
          type: string
          description: REST URL for this category
    ProductTag:
      type: object
      description: CoCart v2 Product Tag
      properties:
        id:
          type: integer
          description: Tag ID
        name:
          type: string
          description: Tag name
        slug:
          type: string
          description: Tag slug
        rest_url:
          type: string
          description: REST URL for this tag
    ProductAttribute:
      type: object
      properties:
        id:
          type: integer
          description: Attribute ID.
        name:
          type: string
          description: Attribute name.
        position:
          type: integer
          description: Attribute position.
        visible:
          type: boolean
          description: >-
            Define if the attribute is visible on the "Additional information"
            tab in the product's page.
        variation:
          type: boolean
          description: Define if the attribute can be used as variation.
        options:
          type: array
          description: List of available term names of the attribute.
          items:
            type: string

````