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

# Bulk Update Campaign Affiliates

> Sets default affiliate tags for up to 300 creators in one request. Valid rows still update when another row fails. Each success fires campaign_affiliate.code_updated.

Sets default affiliate tags for many creators in one request. Built for spoken-code migrations (keep the codes creators already use when you move them onto a revenue campaign).

Each row is independent: valid rows still update when another row fails. Codes must be unique inside your organization. Each successful rename fires `campaign_affiliate.code_updated`.

Maximum **300** affiliates per request.

## Request Body

| Field        | Type  | Description                                                                                  | Required |
| ------------ | ----- | -------------------------------------------------------------------------------------------- | -------- |
| `affiliates` | Array | Rows to update. Each row needs `id` (campaign-affiliate enrollment ID) and `tag` (new code). | Yes      |

## Request Example

```bash theme={null}
curl -X PATCH "https://api.growi.io/api/public/v1/campaign_affiliates/bulk" \
     -H "Authorization: Bearer YOUR_PUBLIC_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "affiliates": [
         { "id": 3490313, "tag": "OLLYCODE" },
         { "id": 3490314, "tag": "SURESH10" }
       ]
     }'
```

## Response Example

All rows succeeded:

```json theme={null}
{
  "success": true,
  "updated": [
    { "id": 3490313, "tag": "ollycode" },
    { "id": 3490314, "tag": "suresh10" }
  ],
  "errors": []
}
```

Partial failure (HTTP 422 — successful rows are still saved):

```json theme={null}
{
  "success": false,
  "updated": [
    { "id": 3490313, "tag": "ollycode" }
  ],
  "errors": [
    { "id": 0, "error": "Campaign affiliate not found." }
  ]
}
```

## Authentication

Send your organization's public API key as a Bearer token. **Viewer (read-only) keys cannot call this.** See [Rate Limits & Authentication](/api-reference/introduction).

## Error Responses

| Status | Body                                                               | When                                                      |
| ------ | ------------------------------------------------------------------ | --------------------------------------------------------- |
| `401`  | `{ "error": "Not Authenticated" }`                                 | Missing or invalid API key.                               |
| `403`  | `{ "error": "This API key is read-only and cannot modify data." }` | Viewer key.                                               |
| `422`  | `{ "error": "affiliates is required" }`                            | Missing / empty `affiliates`.                             |
| `422`  | `{ "error": "Maximum 300 affiliates per request." }`               | More than 300 rows.                                       |
| `422`  | `{ "success": false, "updated": [...], "errors": [...] }`          | At least one row failed. Successful rows are still saved. |


## OpenAPI

````yaml PATCH /campaign_affiliates/bulk
openapi: 3.0.1
info:
  title: Growi API
  description: >-
    API documentation for Growi platform, showcasing the public tracking event
    endpoint
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.growi.io/api/public/v1
security:
  - bearerAuth: []
paths:
  /campaign_affiliates/bulk:
    patch:
      description: >-
        Sets default affiliate tags for up to 300 creators in one request. Valid
        rows still update when another row fails. Each success fires
        campaign_affiliate.code_updated.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - affiliates
              properties:
                affiliates:
                  type: array
                  maxItems: 300
                  items:
                    type: object
                    required:
                      - id
                      - tag
                    properties:
                      id:
                        type: integer
                        example: 3490313
                        description: Campaign-affiliate (enrollment) ID
                      tag:
                        type: string
                        example: OLLYCODE
                        description: New default affiliate tag. Stored lowercase.
      responses:
        '200':
          description: Every row updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  updated:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        tag:
                          type: string
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        error:
                          type: string
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Authenticated
        '422':
          description: >-
            Empty payload, over the 300-row cap, or at least one row failed
            (successful rows are still saved)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  updated:
                    type: array
                    items:
                      type: object
                  errors:
                    type: array
                    items:
                      type: object
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````