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

# Create groups and membership

> Requires `groups:write`. See [Groups and membership behavior](/developer-documentation/api/management) and [common API rules](/developer-documentation/api/overview).

Requires `groups:write`. See the [groups and membership guide](https://www.referly.so/docs/developer-documentation/api/management.md) for behavior and examples.


## OpenAPI

````yaml POST /groups
openapi: 3.0.3
info:
  title: Referly API
  description: >-
    REST API for affiliates, referrals, sales, links, coupons, programs, groups,
    commission plans, commissions, adjustments, balances, payouts, analytics and
    webhooks. Send Authorization: Bearer <YOUR_API_KEY>. Keys have resource
    permissions and optional expiry. Requests default to the key’s original
    program; operational endpoints also support X-Program-Id for a program
    created by that exact key. See the authentication and operational API guides
    for scope, pagination, errors and retry behavior.
  version: 1.0.0
servers:
  - url: https://www.referly.so/api/v1
security:
  - bearerAuth: []
paths:
  /groups:
    post:
      tags:
        - groups
      summary: Create groups and membership
      description: >-
        Requires `groups:write`. See [Groups and membership
        behavior](/developer-documentation/api/management) and [common API
        rules](/developer-documentation/api/overview).
      operationId: post_groups
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            minLength: 8
            maxLength: 200
            pattern: ^[\x21-\x7e]+$
          description: >-
            Optional retry key, unique within the selected program. Reuse the
            same key, method, path and validated payload; a conflicting reuse
            returns 409.
        - name: X-Program-Id
          in: header
          required: false
          description: >-
            Select the key's original program or a program provisioned by this
            exact key. Other owned programs remain inaccessible.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OperationalGroupCreate'
      responses:
        '201':
          description: Success; see management guide for state and accounting semantics
          content:
            application/json:
              schema:
                $ref: 2fa7a82d-a403-4e4e-bea5-49cf500bf2cf
              example:
                id: group_content_partners
                name: Content Partners
                color: '#2f7f6f'
                affiliateProgramId: prog_acme_partners
                defaultCommissionPlanId: plan_content
                createdAt: '2026-09-02T09:00:00.000Z'
                updatedAt: '2026-09-02T09:00:00.000Z'
        '400':
          description: Request failed (400); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_json
                  message: Invalid JSON body
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
        '401':
          description: Request failed (401); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: unauthorized
                  message: Invalid, expired or revoked API key
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
        '403':
          description: Request failed (403); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: groups_unavailable
                  message: Business plan or above is required for affiliate groups
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
        '404':
          description: Request failed (404); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: not_found
                  message: Resource not found
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
        '409':
          description: Request failed (409); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: concurrent_request
                  message: Concurrent operation; retry the same request
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
        '413':
          description: Request failed (413); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: body_too_large
                  message: Request body must be at most 64 KiB
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
        '422':
          description: Request failed (422); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: validation_error
                  message: Invalid request parameters
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
        '429':
          description: Request failed (429); see the common error contract
          content:
            application/json:
              schema:
                $ref: f48d42e5-fe37-407f-b348-be8b1adae0be
              example:
                error: Too many requests. Please slow down.
                retryAfter: 42
        '500':
          description: Request failed (500); see the common error contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: internal_error
                  message: Request failed
                  requestId: 5c1f7a2e-2b39-4c2d-9c31-7a6e0f6a9b21
components:
  schemas:
    OperationalGroupCreate:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
        color:
          type: string
          pattern: ^#[0-9a-fA-F]{6}$
          default: '#6366f1'
      required:
        - name
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human readable description of what went wrong
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.