Documentation Index
Fetch the complete documentation index at: https://docs.linkutm.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
UTM rules are a single per-workspace configuration that normalizes and validates UTM values. Normalization (force lowercase, space replacement, length trimming) is applied to UTM values when links are created. Validation rules (prohibited values, allowed-character regex, required fields, conditional logic) surface errors and warnings before a value is saved. Every workspace has exactly one UTM rules record. It is created on first access with default settings. Every endpoint lives under/api/v1/utm-rules, requires a JWT, and is workspace-scoped.
What the rules do
Normalization (always applied first)
These three settings are applied, in order, to every UTM value before validation runs and before a link is saved.| Setting | Type | Default | Effect |
|---|---|---|---|
forceLowercase | boolean | true | Converts the value to lowercase. |
spaceCharacter | string | _ | Replaces every run of whitespace with this character. For example, Q2 Launch becomes q2_launch. |
maxParameterLength | integer | 100 | Maximum value length. On the process endpoint the value is truncated to this length. On the validate endpoint an over-length value produces an error instead. |
Validation rules
| Setting | Type | Effect |
|---|---|---|
allowedCharactersRegex | string | A regular expression the processed value must match. A value that does not match produces a Value contains disallowed characters error. An invalid regex is skipped silently. |
prohibitedValues | string[] | A list of banned substrings. The check is case-insensitive: if the processed value contains any prohibited term, a Value contains prohibited term error is produced. |
standardizationRules | object[] | Named rules stored on the record (see Standardization rules). They are persisted by update but are not currently applied by validate or process. |
requiredFieldRules | object[] | Per-field validation rules - empty checks, length checks, regex checks, allowed-value checks (see Required field rules). |
conditionalLogicRules | object[] | If-then rules that auto-set one field based on the value of another (see Conditional logic rules). |
isActive | boolean | Master switch. When false, validate returns valid: true with no processing, and process returns the value unchanged. |
Standardization rules
Each entry instandardizationRules has this shape:
| Field | Type | Notes |
|---|---|---|
name | string | Rule label. |
isActive | boolean | Whether the rule is enabled. |
ruleType | string | One of trim_whitespace, remove_special_chars, replace_pattern, custom. |
description | string | Optional explanation. |
applyToParameters | string[] | Parameter codes the rule targets, e.g., ["source", "medium"]. |
pattern | string | Search pattern, used with replace_pattern. |
replacement | string | Replacement text, used with replace_pattern. |
Standardization rules are stored and returned by the rules record, but the current
validate and process logic does not apply them. Treat them as configuration that is persisted for future use.Required field rules
Each entry inrequiredFieldRules has this shape:
| Field | Type | Notes |
|---|---|---|
name | string | Rule label. |
isActive | boolean | Inactive rules are skipped. |
description | string | Used as the error message when the rule fails. |
validationType | string | One of not_empty, min_length, max_length, regex, allowed_values. |
requiredParameters | string[] | Parameter codes the rule applies to. |
minChar | integer | Minimum length, used with min_length. |
maxChar | integer | Maximum length, used with max_length (defaults to 100 if unset). |
regex | string | Pattern, used with regex. |
allowedValues | string[] | Permitted values, used with allowed_values. |
validationType:
not_empty- the field must be present and not blank.min_length- if the field has a value, it must be at leastminCharcharacters.max_length- if the field has a value, it must be at mostmaxCharcharacters.regex- if the field has a value, it must matchregex. An invalid regex is skipped silently.allowed_values- if the field has a value, it must be one ofallowedValues.
description is used as the error message if set, otherwise a generated default message is used.
Conditional logic rules
Each entry inconditionalLogicRules has this shape:
| Field | Type | Notes |
|---|---|---|
ifField | string | Parameter code to test. |
ifValue | string | Value to compare against. |
condition | string | One of equals, contains, starts_with, ends_with, not_empty. |
thenSet | string | Parameter code to set when the condition is met. |
toValue | string | Value to set thenSet to. |
thenSet is overwritten with toValue in processedParams and a warning is added describing the auto-set. Conditional rules run after normalization and required-field checks.
Get UTM rules
Headers
| Header | Required | Notes |
|---|---|---|
Authorization: Bearer <jwt> | Yes | |
x-workspace-id: <uuid_or_slug> | Yes | Target workspace |
Example request
Example response
Errors
| Code | When |
|---|---|
401 | Missing or invalid JWT |
Update UTM rules
Headers
| Header | Required | Notes |
|---|---|---|
Authorization: Bearer <jwt> | Yes | |
x-workspace-id: <uuid_or_slug> | Yes | Target workspace |
Content-Type: application/json | Yes |
Body
Character that replaces runs of whitespace in UTM values. Send an empty string to disable space replacement.
When
true, UTM values are lowercased during processing.Maximum value length.
process truncates to this; validate flags an over-length value as an error.Regular expression a processed value must match. An invalid regex is skipped during validation.
Banned substrings. Matching is case-insensitive.
Named standardization rules. See Standardization rules for the object shape. Persisted but not currently applied.
Per-field validation rules. See Required field rules for the object shape.
If-then auto-set rules. See Conditional logic rules for the object shape.
Master switch. When
false, validation and processing are bypassed.Example request
Example response
Errors
| Code | When |
|---|---|
401 | Missing or invalid JWT |
Validate UTM parameters
isActive is false, the response is valid: true with empty errors and warnings, and processedParams equal to the input.
Processing order
For each supplied parameter:- Force lowercase (if
forceLowercase). - Replace whitespace with
spaceCharacter(if set). - Check against
maxParameterLength- over-length adds an error. - Check against
prohibitedValues- a contained prohibited term adds an error. - Check against
allowedCharactersRegex- a non-matching value adds an error.
requiredFieldRules run against the processed values, and finally conditionalLogicRules run, which may auto-set fields and add warnings.
Headers
| Header | Required | Notes |
|---|---|---|
Authorization: Bearer <jwt> | Yes | |
x-workspace-id: <uuid_or_slug> | Yes | Target workspace |
Content-Type: application/json | Yes |
Body
The body is a flat object of parameter values. The standard keys are recognized, and any additional custom keys are also accepted and processed.UTM source value.
UTM medium value.
UTM campaign value.
UTM term value.
UTM content value.
Any extra string key beyond the five standard ones is processed the same way. Keys with
undefined or null values are skipped.Example request
Example response
maxParameterLength is exceeded and a prohibited term is present:
Response fields
| Field | Type | Notes |
|---|---|---|
valid | boolean | true when errors is empty. |
errors | object[] | Each is { field, message }. A non-empty list means the values should not be saved. |
warnings | object[] | Each is { field, message }. Currently only emitted by conditional logic rules. Warnings do not make the result invalid. |
processedParams | object | The normalized values, including any fields auto-set by conditional rules. |
Errors
| Code | When |
|---|---|
401 | Missing or invalid JWT |
Process a single value
prohibitedValues, allowedCharactersRegex, requiredFieldRules, or conditionalLogicRules.
When isActive is false, the value is returned unchanged.
Headers
| Header | Required | Notes |
|---|---|---|
Authorization: Bearer <jwt> | Yes | |
x-workspace-id: <uuid_or_slug> | Yes | Target workspace |
Content-Type: application/json | Yes |
Body
The string to normalize.
Example request
Example response
forceLowercase lowercased the string and spaceCharacter (_) replaced the spaces. If the result were longer than maxParameterLength, it would also be truncated to that length.
Errors
| Code | When |
|---|---|
401 | Missing or invalid JWT |