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

# Patch Collection

> Rename a collection and/or add, replace, or remove clauses by id.



## OpenAPI

````yaml patch /v1/collections/{collection_id}
openapi: 3.1.0
info:
  title: Channel3 API
  version: 0.1.0
servers:
  - url: https://api.trychannel3.com
    description: Production
security: []
paths:
  /v1/collections/{collection_id}:
    patch:
      tags:
        - collections
      summary: Patch Collection
      description: Rename a collection and/or add, replace, or remove clauses by id.
      operationId: patch_collection_v1_collections__collection_id__patch
      parameters:
        - name: collection_id
          in: path
          required: true
          schema:
            type: string
            title: Collection Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchCollectionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionResponse'
        '401':
          description: Unauthorized - Invalid or missing authentication
          content:
            application/json:
              examples:
                missing_key:
                  summary: Missing API Key
                  value:
                    detail: >-
                      Unauthorized. Missing authentication key. Make sure to
                      attach an x-api-key with your request. Need help? Reach
                      out to support@trychannel3.com.
                invalid_key:
                  summary: Invalid API Key
                  value:
                    detail: >-
                      API key was provided but is invalid. Need help? Reach out
                      to support@trychannel3.com.
              schema:
                $ref: '#/components/schemas/app__routers__utils__ErrorResponse'
        '402':
          description: Payment required
          content:
            application/json:
              examples:
                credits_exhausted:
                  summary: API key out of credits
                  value:
                    detail: >-
                      You have used all of your free credits. Add a payment
                      method to continue.
                mpp_challenge:
                  summary: MPP Tempo payment required
                  value:
                    detail: >-
                      Payment required. Satisfy the MPP Tempo challenge in
                      WWW-Authenticate.
              schema:
                $ref: '#/components/schemas/app__routers__utils__ErrorResponse'
        '404':
          description: Not found
          content:
            application/json:
              example:
                detail: Collection not found
              schema:
                $ref: '#/components/schemas/app__routers__utils__ErrorResponse'
        '422':
          description: Validation error or invalid brand_ids / category_ids / website_ids
          content:
            application/json:
              example:
                detail: >-
                  Collection was not created. Invalid brand_ids:
                  'brand_nike_abc123'
              schema:
                $ref: '#/components/schemas/app__routers__utils__ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/app__routers__utils__ErrorResponse'
              example:
                detail: Internal Server Error
      security:
        - APIKeyHeader: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |
            from channel3_sdk import Channel3
            from channel3_sdk.environment import Channel3Environment

            client = Channel3(
                api_key="<value>",
                environment=Channel3Environment.PRODUCTION,
            )

            client.collections.update(
                collection_id="collection_id",
            )
        - lang: typescript
          label: TypeScript
          source: |
            import { Channel3 } from "@channel3/sdk";

            const client = new Channel3({ apiKey: "YOUR_API_KEY" });

            await client.collections.update({
                collection_id: "collection_id"
            });
components:
  schemas:
    PatchCollectionRequest:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        description:
          anyOf:
            - type: string
              maxLength: 1000
            - type: 'null'
          title: Description
        add_clauses:
          anyOf:
            - items:
                $ref: '#/components/schemas/CollectionClauseInput'
              type: array
            - type: 'null'
          title: Add Clauses
        replace_clauses:
          anyOf:
            - items:
                $ref: '#/components/schemas/CollectionClause'
              type: array
            - type: 'null'
          title: Replace Clauses
          description: >-
            Replace existing clauses in place by clause_id. Position in the
            clauses list is unchanged.
        remove_clause_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Remove Clause Ids
      additionalProperties: false
      type: object
      title: PatchCollectionRequest
    CollectionResponse:
      properties:
        collection_id:
          type: string
          title: Collection Id
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
        clauses:
          items:
            $ref: '#/components/schemas/CollectionClause'
          type: array
          title: Clauses
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - collection_id
        - name
        - clauses
        - created_at
        - updated_at
      title: CollectionResponse
    app__routers__utils__ErrorResponse:
      properties:
        detail:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
          title: Detail
      type: object
      required:
        - detail
      title: ErrorResponse
    CollectionClauseInput:
      properties:
        brand_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Brand Ids
          description: >-
            OR within this list (any slot). AND with the clause's other lists.
            OR against other clauses.
        website_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Website Ids
          description: >-
            Merchant ids; OR within this list (any matching offer). AND with the
            clause's other lists. Domains are accepted on write and stored as
            merchant ids.
        category_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Category Ids
          description: OR within this list. AND with the clause's other lists.
        product_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Product Ids
      additionalProperties: false
      type: object
      title: CollectionClauseInput
      description: Clause payload for create / add_clauses (server mints clause_id).
    CollectionClause:
      properties:
        brand_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Brand Ids
          description: >-
            OR within this list (any slot). AND with the clause's other lists.
            OR against other clauses.
        website_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Website Ids
          description: >-
            Merchant ids; OR within this list (any matching offer). AND with the
            clause's other lists. Domains are accepted on write and stored as
            merchant ids.
        category_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Category Ids
          description: OR within this list. AND with the clause's other lists.
        product_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Product Ids
        clause_id:
          type: string
          title: Clause Id
      additionalProperties: false
      type: object
      required:
        - clause_id
      title: CollectionClause
      description: Persisted clause with a stable server-minted id.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````

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