vevee.analytics.setAttributes()POST /api/v1/attributes/values/batchsk_live_

Write many attribute values in one call. Partial-success on purpose: a single invalid value is recorded in rejected and the rest still apply. Use this for bulk onboarding imports.

i
Privileged. setAttributesalways requires a secret key, even when the workspace’s “Client-side attribute writes” flag is ON. Browser code uses setAttribute() one at a time instead.

Signature

vevee.analytics.setAttributes(args: {
  distinctId: string;
  attributes: Record<string, string | number | boolean | string[]>;
}): Promise<{
  personId: string;
  applied: number;
  rejected: Array<{ key: string; reason: string }>;
}>

Parameters

NameTypeDescription
distinctIdrequiredstringYour user’s identifier.
attributesrequiredRecord<string, …>A map of key → value. Keys must match attribute keys declared in the dashboard. Values follow the same shape rules as setAttribute()- type depends on each attribute’s declaration.

Returns

FieldTypeDescription
personIdstringThe resolved person id for distinctId.
appliednumberNumber of values successfully written.
rejectedArray<{ key, reason }>Entries that failed. Possible reason values: attribute_not_defined, attribute_archived, attribute_value_invalid. These are NOT thrown - inspect this array after the call.

Errors

CodeStatusWhen
requires_secret_key403Called with a pk_* key.
invalid_request400Body shape is wrong - e.g. attributes is missing or not an object.

Per-row validation failures are returned in the rejected array, not thrown. The call succeeds as long as the request itself is well-formed.

Example

const result = await vevee.analytics.setAttributes({
  distinctId: user.id,
  attributes: {
    persona: 'teacher',
    goal: 'lesson_planning',
    unknown_one: 'x',            // attribute not in dashboard → rejected
    persona_typo_key: 'student', // attribute not defined → rejected
  },
});
// result.applied === 2
// result.rejected === [
//   { key: 'unknown_one',       reason: 'attribute_not_defined' },
//   { key: 'persona_typo_key',  reason: 'attribute_not_defined' },
// ]
i
Related: setAttribute() for single writes (also browser-safe with the workspace flag ON), getAttributes() to read current values, and the Attributes guide.