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

# Set customer tags

> Set tags on customers.

See [Customer tags](/product/customer-tags) for what they do in the dashboard.

## Parameters

<ParamField body="customers" type="array of customer objects" required>
  The per-customer tag updates, described below. Up to 1,000 per call.
</ParamField>

<ParamField body="upsert" type="boolean" default="false">
  If a (customer, key) pair already exists, overwrite it instead of throwing an error.
</ParamField>

Each object inside `customers` accepts:

<ParamField body="customer_name" type="string" required>
  The same identifier you stamp on your LLM calls when [propagating metadata](/api/gateway/responses#weflayr-fields), so tags land on the same customer.
</ParamField>

<ParamField body="tags" type="object (string values, or null)" required>
  A string value sets the tag; `null` deletes it. Only the keys you post change, existing tags not included are left untouched.
</ParamField>

<RequestExample>
  ```python Python theme={null}
  import weflayr
  from weflayr.openapi.models import SetCustomerTagsInput

  client = weflayr.client()  # reads WEFLAYR_API_KEY

  client.set_customers_tags(body=SetCustomerTagsInput.from_dict({
      "upsert": True,
      "customers": [
          {"customer_name": "c_123", "tags": {"plan": "enterprise", "region": "EU"}},
          {"customer_name": "c_456", "tags": {"plan": "free", "trial": None}},
      ]
  }))
  ```

  ```js Node.js theme={null}
  const weflayr = require('weflayr');

  const client = weflayr.client(); // reads WEFLAYR_API_KEY

  await weflayr.api.setCustomersTags({
    client,
    throwOnError: true,
    body: {
      upsert: true,
      customers: [
        { customerName: 'c_123', tags: { plan: 'enterprise', region: 'EU' } },
        { customerName: 'c_456', tags: { plan: 'free', trial: null } },
      ],
    },
  });
  ```

  ```bash cURL theme={null}
  curl -X POST https://app.weflayr.com/api/customer-tags/ \
    -H "Authorization: Bearer $WEFLAYR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "upsert": true,
      "customers": [
        {"customer_name": "c_123", "tags": {"plan": "enterprise", "region": "EU"}},
        {"customer_name": "c_456", "tags": {"plan": "free", "trial": null}}
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {"ok": true, "customers_updated": 2}
  ```
</ResponseExample>


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