Customer tags
Manage customer tags programmatically instead of uploading CSVs.
import weflayr
client = weflayr.client(api_key="wf-...")
const weflayr = require('weflayr');
const client = weflayr.client({ apiKey: 'wf-...' });
# Passed as a Bearer token on every request
export WEFLAYR_API_KEY="wf-..."
Set customer tags
from weflayr.openapi.models import SetCustomerTagsInput
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}},
]
}))
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 } },
],
},
});
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}}
]
}'
Output:
{"ok": true, "customers_updated": 2}
Input params:
| Field | Accepts | Behaviour |
|---|---|---|
customersRequired |
array of customer objects | The per-customer tag updates, described in the table below. Up to 1,000 per call. |
upsertOptional |
boolean (default false) |
If a (customer, key) pair already exists, overwrite it instead of throwing an error. |
Each object inside customers accepts:
| Customer field | Accepts | Behaviour |
|---|---|---|
customer_nameRequired |
string | The same identifier you stamp on your LLM calls when propagating metadata, so tags land on the same customer. |
tagsRequired |
object (string values, or null) |
A string value sets the tag; null deletes it. Only the keys you post change, existing tags not included are left untouched. |
Get customer tags
client.get_customers_tags(customer_names=["c_123", "c_456"])
await weflayr.api.getCustomersTags({
client,
throwOnError: true,
query: { customerNames: ['c_123', 'c_456'] },
});
curl "https://app.weflayr.com/api/customer-tags/?customer_names=c_123&customer_names=c_456" \
-H "Authorization: Bearer $WEFLAYR_API_KEY"
Output:
{
"customers": [
{"customer_name": "c_123", "tags": {"plan": "enterprise", "region": "EU"}},
{"customer_name": "c_456", "tags": {"plan": "free"}}
],
"next_cursor": null,
"has_more": false
}
Input params:
| Field | Accepts | Behaviour |
|---|---|---|
customer_namesOptional |
list[string] | Specify the names of the customers whose tags should be fetched. Not setting it means “all customers”. |
limitOptional |
integer (default 100, max 1000) |
Numbers of customers to fetch. |
cursorOptional |
string | The route is paginated: pass the previous page’s next_cursor to fetch the next page. PS: has_more from the output says whether another page exists. |
Delete customer tags
client.delete_customers_tags(customer_names=["c_123", "c_456"])
await weflayr.api.deleteCustomersTags({
client,
throwOnError: true,
query: { customerNames: ['c_123', 'c_456'] },
});
curl -X DELETE "https://app.weflayr.com/api/customer-tags/?customer_names=c_123&customer_names=c_456" \
-H "Authorization: Bearer $WEFLAYR_API_KEY"
Output:
{"ok": true, "tags_deleted": 2}
Input params: passed in the query string.
| Field | Accepts | Behaviour |
|---|---|---|
customer_namesRequired |
list[string] | Delete every tag of these customers. The customer records themselves are kept. |