> ## 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.

# Update Campaign Affiliate

> Sets the creator's default affiliate tag (spoken discount / coupon code) to an exact string. Codes must be unique inside the organization. Fires campaign_affiliate.code_updated.

Sets the creator's default affiliate tag (the spoken discount / coupon code) to an exact string. Use this after a creator joins if you want to keep the code they already say on camera, or to migrate an existing roster onto a revenue campaign.

Codes are unique inside your organization. A rename fires `campaign_affiliate.code_updated` so any coupons you mint from the webhook tag stay in sync.

For 300+ creators, prefer [Bulk Update Campaign Affiliates](/api-reference/endpoint/bulk-update-campaign-affiliates) instead of looping this endpoint (the public API also enforces a 2-second gap between requests).

## Path Parameters

| Parameter | Type    | Description                                               | Required |
| --------- | ------- | --------------------------------------------------------- | -------- |
| `id`      | Integer | Campaign-affiliate (enrollment) ID from the list endpoint | Yes      |

## Request Body

| Field | Type   | Description                                                             | Required |
| ----- | ------ | ----------------------------------------------------------------------- | -------- |
| `tag` | String | New default affiliate tag. Stored lowercase. Must be unique in the org. | Yes      |

## Request Example

```bash theme={null}
curl -X PATCH "https://api.growi.io/api/public/v1/campaign_affiliates/3490313" \
     -H "Authorization: Bearer YOUR_PUBLIC_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "tag": "THEIREXISTINGCODE"
     }'
```

## Response Example

```json theme={null}
{
  "success": true,
  "id": 3490313,
  "tag": "theirexistingcode"
}
```

## 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": "Campaign affiliate not found." }`                                  | Unknown or foreign enrollment id.                  |
| `422`  | `{ "error": "tag is required" }`                                                | Missing / blank `tag`.                             |
| `422`  | `{ "error": "Sorry, that code is already taken. Please try a different one." }` | Another creator in the org already holds this tag. |


## OpenAPI

````yaml PATCH /campaign_affiliates/{id}
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/{id}:
    patch:
      description: >-
        Sets the creator's default affiliate tag (spoken discount / coupon code)
        to an exact string. Codes must be unique inside the organization. Fires
        campaign_affiliate.code_updated.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Campaign-affiliate (enrollment) ID from GET /campaign_affiliates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tag
              properties:
                tag:
                  type: string
                  example: THEIREXISTINGCODE
                  description: New default affiliate tag. Stored lowercase.
      responses:
        '200':
          description: Tag updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  id:
                    type: integer
                    example: 3490313
                  tag:
                    type: string
                    example: theirexistingcode
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Authenticated
        '403':
          description: Read-only API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: This API key is read-only and cannot modify data.
        '422':
          description: Not found, missing tag, or tag already taken
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: >-
                      Sorry, that code is already taken. Please try a different
                      one.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````