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

# Create Product Collection Group

> Add a new group to a product collection.



## OpenAPI

````yaml post /product-collections/{id}/groups
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.102.0
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /product-collections/{id}/groups:
    post:
      tags:
        - Product Collections
      operationId: add_group_to_collection
      parameters:
        - name: id
          in: path
          description: Product Collection Id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCollectionGroup'
        required: true
      responses:
        '200':
          description: Group added successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductCollectionGroupResponse'
        '404':
          description: Product Collection not found
        '422':
          description: Invalid Request Object or Parameters
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import DodoPayments from 'dodopayments';


            const client = new DodoPayments({
              bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
            });


            const productCollectionGroupResponse = await
            client.productCollections.groups.create('id', {
              products: [{ product_id: 'product_id' }],
            });


            console.log(productCollectionGroupResponse.group_id);
        - lang: Python
          source: >-
            import os

            from dodopayments import DodoPayments


            client = DodoPayments(
                bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
            )

            product_collection_group_response =
            client.product_collections.groups.create(
                id="id",
                products=[{
                    "product_id": "product_id"
                }],
            )

            print(product_collection_group_response.group_id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\tproductCollectionGroupResponse, err := client.ProductCollections.Groups.New(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\tdodopayments.ProductCollectionGroupNewParams{\n\t\t\tProductCollectionGroupDetails: dodopayments.ProductCollectionGroupDetailsParam{\n\t\t\t\tProducts: dodopayments.F([]dodopayments.GroupProductParam{{\n\t\t\t\t\tProductID: dodopayments.F(\"product_id\"),\n\t\t\t\t}}),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", productCollectionGroupResponse.GroupID)\n}\n"
        - lang: Java
          source: >-
            package com.dodopayments.api.example;


            import com.dodopayments.api.client.DodoPaymentsClient;

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;

            import
            com.dodopayments.api.models.productcollections.groups.GroupCreateParams;

            import
            com.dodopayments.api.models.productcollections.groups.GroupProduct;

            import
            com.dodopayments.api.models.productcollections.groups.ProductCollectionGroupDetails;

            import
            com.dodopayments.api.models.productcollections.groups.ProductCollectionGroupResponse;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    GroupCreateParams params = GroupCreateParams.builder()
                        .id("id")
                        .productCollectionGroupDetails(ProductCollectionGroupDetails.builder()
                            .addProduct(GroupProduct.builder()
                                .productId("product_id")
                                .build())
                            .build())
                        .build();
                    ProductCollectionGroupResponse productCollectionGroupResponse = client.productCollections().groups().create(params);
                }
            }
        - lang: Kotlin
          source: >-
            package com.dodopayments.api.example


            import com.dodopayments.api.client.DodoPaymentsClient

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient

            import
            com.dodopayments.api.models.productcollections.groups.GroupCreateParams

            import
            com.dodopayments.api.models.productcollections.groups.GroupProduct

            import
            com.dodopayments.api.models.productcollections.groups.ProductCollectionGroupDetails

            import
            com.dodopayments.api.models.productcollections.groups.ProductCollectionGroupResponse


            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val params: GroupCreateParams = GroupCreateParams.builder()
                    .id("id")
                    .productCollectionGroupDetails(ProductCollectionGroupDetails.builder()
                        .addProduct(GroupProduct.builder()
                            .productId("product_id")
                            .build())
                        .build())
                    .build()
                val productCollectionGroupResponse: ProductCollectionGroupResponse = client.productCollections().groups().create(params)
            }
        - lang: Ruby
          source: >-
            require "dodopayments"


            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )


            product_collection_group_response =
            dodo_payments.product_collections.groups.create("id", products:
            [{product_id: "product_id"}])


            puts(product_collection_group_response)
        - lang: PHP
          source: |-
            <?php

            require_once dirname(__DIR__) . '/vendor/autoload.php';

            use Dodopayments\Client;
            use Dodopayments\Core\Exceptions\APIException;

            $client = new Client(
              bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
              environment: 'test_mode',
            );

            try {
              $productCollectionGroupResponse = $client->productCollections->groups->create(
                'id',
                products: [['productID' => 'product_id', 'status' => true]],
                groupName: 'group_name',
                status: true,
              );

              var_dump($productCollectionGroupResponse);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: >-
            using System;

            using DodoPayments.Client;

            using DodoPayments.Client.Models.ProductCollections.Groups;


            DodoPaymentsClient client = new();


            GroupCreateParams parameters = new()

            {
                ID = "id",
                Products =
                [
                    new()
                    {
                        ProductID = "product_id",
                        Status = true,
                    },
                ],
            };


            var productCollectionGroupResponse = await
            client.ProductCollections.Groups.Create(parameters);


            Console.WriteLine(productCollectionGroupResponse);
components:
  schemas:
    ProductCollectionGroup:
      type: object
      required:
        - products
      properties:
        group_name:
          type:
            - string
            - 'null'
          description: >-
            Optional group name. Multiple groups can have null names, but named
            groups must be unique per collection
        products:
          type: array
          items:
            $ref: '#/components/schemas/GroupProduct'
          description: Products in this group
        status:
          type:
            - boolean
            - 'null'
          description: Status of the group (defaults to true if not provided)
    ProductCollectionGroupResponse:
      type: object
      required:
        - group_id
        - status
        - products
      properties:
        group_id:
          type: string
        group_name:
          type:
            - string
            - 'null'
        products:
          type: array
          items:
            $ref: '#/components/schemas/ProductCollectionProductResponse'
        status:
          type: boolean
    GroupProduct:
      type: object
      required:
        - product_id
      properties:
        product_id:
          type: string
          description: Product ID to include in the group
        status:
          type:
            - boolean
            - 'null'
          description: >-
            Status of the product in this group (defaults to true if not
            provided)
    ProductCollectionProductResponse:
      type: object
      required:
        - id
        - product_id
        - status
        - is_recurring
        - license_key_enabled
        - meters_count
        - files_count
        - addons_count
        - has_credit_entitlements
      properties:
        addons_count:
          type: integer
          format: int64
        currency:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Currency'
        description:
          type:
            - string
            - 'null'
        files_count:
          type: integer
          format: int64
        has_credit_entitlements:
          type: boolean
          description: Whether this product has any credit entitlements attached
        id:
          type: string
        is_recurring:
          type: boolean
        license_key_enabled:
          type: boolean
        meters_count:
          type: integer
          format: int64
        name:
          type:
            - string
            - 'null'
        price:
          type:
            - integer
            - 'null'
          format: int32
        price_detail:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Price'
        product_id:
          type: string
        status:
          type: boolean
        tax_category:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TaxCategory'
        tax_inclusive:
          type:
            - boolean
            - 'null'
    Currency:
      type: string
      enum:
        - AED
        - ALL
        - AMD
        - ANG
        - AOA
        - ARS
        - AUD
        - AWG
        - AZN
        - BAM
        - BBD
        - BDT
        - BGN
        - BHD
        - BIF
        - BMD
        - BND
        - BOB
        - BRL
        - BSD
        - BWP
        - BYN
        - BZD
        - CAD
        - CHF
        - CLP
        - CNY
        - COP
        - CRC
        - CUP
        - CVE
        - CZK
        - DJF
        - DKK
        - DOP
        - DZD
        - EGP
        - ETB
        - EUR
        - FJD
        - FKP
        - GBP
        - GEL
        - GHS
        - GIP
        - GMD
        - GNF
        - GTQ
        - GYD
        - HKD
        - HNL
        - HRK
        - HTG
        - HUF
        - IDR
        - ILS
        - INR
        - IQD
        - JMD
        - JOD
        - JPY
        - KES
        - KGS
        - KHR
        - KMF
        - KRW
        - KWD
        - KYD
        - KZT
        - LAK
        - LBP
        - LKR
        - LRD
        - LSL
        - LYD
        - MAD
        - MDL
        - MGA
        - MKD
        - MMK
        - MNT
        - MOP
        - MRU
        - MUR
        - MVR
        - MWK
        - MXN
        - MYR
        - MZN
        - NAD
        - NGN
        - NIO
        - NOK
        - NPR
        - NZD
        - OMR
        - PAB
        - PEN
        - PGK
        - PHP
        - PKR
        - PLN
        - PYG
        - QAR
        - RON
        - RSD
        - RUB
        - RWF
        - SAR
        - SBD
        - SCR
        - SEK
        - SGD
        - SHP
        - SLE
        - SLL
        - SOS
        - SRD
        - SSP
        - STN
        - SVC
        - SZL
        - THB
        - TND
        - TOP
        - TRY
        - TTD
        - TWD
        - TZS
        - UAH
        - UGX
        - USD
        - UYU
        - UZS
        - VES
        - VND
        - VUV
        - WST
        - XAF
        - XCD
        - XOF
        - XPF
        - YER
        - ZAR
        - ZMW
    Price:
      oneOf:
        - allOf:
            - $ref: '#/components/schemas/OneTimePrice'
              description: One-time price details.
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - one_time_price
                  x-stainless-const: true
          title: One Time Price
          description: One-time price details.
        - allOf:
            - $ref: '#/components/schemas/RecurringPrice'
              description: Recurring price details.
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - recurring_price
                  x-stainless-const: true
          title: Recurring Price
          description: Recurring price details.
        - allOf:
            - $ref: '#/components/schemas/UsageBasedPrice'
              description: Usage Based price details.
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - usage_based_price
                  x-stainless-const: true
          title: Usage Based Price
          description: Usage Based price details.
      discriminator:
        propertyName: type
    TaxCategory:
      type: string
      description: >-
        Represents the different categories of taxation applicable to various
        products and services.
      enum:
        - digital_products
        - saas
        - e_book
        - edtech
    OneTimePrice:
      type: object
      title: One Time Price
      required:
        - price
        - currency
        - discount
        - purchasing_power_parity
      properties:
        currency:
          $ref: '#/components/schemas/Currency'
          description: The currency in which the payment is made.
        discount:
          type: integer
          format: int64
          description: >-
            Discount applied to the price, represented as a percentage (0 to
            100).
        pay_what_you_want:
          type: boolean
          description: >-
            Indicates whether the customer can pay any amount they choose.

            If set to `true`, the [`price`](Self::price) field is the minimum
            amount.
        price:
          type: integer
          format: int32
          description: >-
            The payment amount, in the smallest denomination of the currency
            (e.g., cents for USD).

            For example, to charge $1.00, pass `100`.


            If [`pay_what_you_want`](Self::pay_what_you_want) is set to `true`,
            this field represents

            the **minimum** amount the customer must pay.
        purchasing_power_parity:
          type: boolean
          description: >-
            Indicates if purchasing power parity adjustments are applied to the
            price.

            Purchasing power parity feature is not available as of now.
        suggested_price:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            A suggested price for the user to pay. This value is only considered
            if

            [`pay_what_you_want`](Self::pay_what_you_want) is `true`. Otherwise,
            it is ignored.
        tax_inclusive:
          type:
            - boolean
            - 'null'
          description: Indicates if the price is tax inclusive.
    RecurringPrice:
      type: object
      title: Recurring Price
      required:
        - price
        - currency
        - discount
        - purchasing_power_parity
        - payment_frequency_count
        - payment_frequency_interval
        - subscription_period_count
        - subscription_period_interval
      properties:
        currency:
          $ref: '#/components/schemas/Currency'
          description: The currency in which the payment is made.
        discount:
          type: integer
          format: int64
          description: >-
            Discount applied to the price, represented as a percentage (0 to
            100).
        payment_frequency_count:
          type: integer
          format: int32
          description: >-
            Number of units for the payment frequency.

            For example, a value of `1` with a `payment_frequency_interval` of
            `month` represents monthly payments.
        payment_frequency_interval:
          $ref: '#/components/schemas/TimeInterval'
          description: >-
            The time interval for the payment frequency (e.g., day, month,
            year).
        price:
          type: integer
          format: int32
          description: >-
            The payment amount. Represented in the lowest denomination of the
            currency (e.g., cents for USD).

            For example, to charge $1.00, pass `100`.
        purchasing_power_parity:
          type: boolean
          description: >-
            Indicates if purchasing power parity adjustments are applied to the
            price.

            Purchasing power parity feature is not available as of now
        subscription_period_count:
          type: integer
          format: int32
          description: >-
            Number of units for the subscription period.

            For example, a value of `12` with a `subscription_period_interval`
            of `month` represents a one-year subscription.
        subscription_period_interval:
          $ref: '#/components/schemas/TimeInterval'
          description: >-
            The time interval for the subscription period (e.g., day, month,
            year).
        tax_inclusive:
          type:
            - boolean
            - 'null'
          description: Indicates if the price is tax inclusive
        trial_period_days:
          type: integer
          format: int32
          description: >-
            Number of days for the trial period. A value of `0` indicates no
            trial period.
    UsageBasedPrice:
      type: object
      title: Usage Based Price
      required:
        - fixed_price
        - currency
        - discount
        - purchasing_power_parity
        - payment_frequency_count
        - payment_frequency_interval
        - subscription_period_count
        - subscription_period_interval
      properties:
        currency:
          $ref: '#/components/schemas/Currency'
          description: The currency in which the payment is made.
        discount:
          type: integer
          format: int64
          description: >-
            Discount applied to the price, represented as a percentage (0 to
            100).
        fixed_price:
          type: integer
          format: int32
          description: >-
            The fixed payment amount. Represented in the lowest denomination of
            the currency (e.g., cents for USD).

            For example, to charge $1.00, pass `100`.
        meters:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/AddMeterToPrice'
        payment_frequency_count:
          type: integer
          format: int32
          description: >-
            Number of units for the payment frequency.

            For example, a value of `1` with a `payment_frequency_interval` of
            `month` represents monthly payments.
        payment_frequency_interval:
          $ref: '#/components/schemas/TimeInterval'
          description: >-
            The time interval for the payment frequency (e.g., day, month,
            year).
        purchasing_power_parity:
          type: boolean
          description: >-
            Indicates if purchasing power parity adjustments are applied to the
            price.

            Purchasing power parity feature is not available as of now
        subscription_period_count:
          type: integer
          format: int32
          description: >-
            Number of units for the subscription period.

            For example, a value of `12` with a `subscription_period_interval`
            of `month` represents a one-year subscription.
        subscription_period_interval:
          $ref: '#/components/schemas/TimeInterval'
          description: >-
            The time interval for the subscription period (e.g., day, month,
            year).
        tax_inclusive:
          type:
            - boolean
            - 'null'
          description: Indicates if the price is tax inclusive
    TimeInterval:
      type: string
      enum:
        - Day
        - Week
        - Month
        - Year
    AddMeterToPrice:
      type: object
      title: Add Meter To Price
      required:
        - meter_id
      properties:
        credit_entitlement_id:
          type:
            - string
            - 'null'
          description: >-
            Optional credit entitlement ID to link this meter to for
            credit-based billing
        description:
          type:
            - string
            - 'null'
          description: >-
            Meter description. Will ignored on Request, but will be shown in
            response
        free_threshold:
          type:
            - integer
            - 'null'
          format: int64
        measurement_unit:
          type:
            - string
            - 'null'
          description: >-
            Meter measurement unit. Will ignored on Request, but will be shown
            in response
        meter_id:
          type: string
        meter_units_per_credit:
          type:
            - string
            - 'null'
          description: >-
            Number of meter units that equal one credit. Required when
            credit_entitlement_id is set.
        name:
          type:
            - string
            - 'null'
          description: Meter name. Will ignored on Request, but will be shown in response
        price_per_unit:
          type:
            - string
            - 'null'
          description: >-
            The price per unit in lowest denomination. Must be greater than
            zero. Supports up to 5 digits before decimal point and 12 decimal
            places.
          example: '10.50'
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````