Entry Variant
Entry Variant
The Entry Variants feature allows you to easily create and manage different content variations for various audiences, languages, and marketing experiments.
When Personalize creates a variant in the CMS, it assigns a "Variant Alias" to identify that specific variant. When fetching entry variants using the Delivery API, you can pass variant aliases in place of variant UIDs in the x-cs-variant-uid header.
Get all entry variants
The Get all entry variants method allows you to retrieve details for all or specific entries.
| Name | Type | Description |
|---|---|---|
| content_type_uid (required) | string | Enter the UID of the content type |
| entry_uid (required) | string | Enter the UID of the entry |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('entry_uid').variants().query().find()
.then((variant) => console.log(variant))Get a single entry variant
The Get a single entry variant method allows you to retrieve the details for a specific entry variant.
| Name | Type | Description |
|---|---|---|
| variant_uid/variant_alias (required) | string | Enter the UID/Alias of the variant |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('entry_uid').variants('variant_uid/variant_alias').fetch()
.then((variant) => console.log(variant))Delete entry variant
The Delete entry variant method allows you to delete a specific entry variant.
| Name | Type | Description |
|---|---|---|
| variant_uid/variant_alias (required) | string | Enter the UID/Alias of the variant |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('entry_uid').variants('variant_uid/variant_alias').delete()
.then((response) => console.log(response.notice))Update entry variant
The Update entry variant method allows you to update a specific entry variant.
| Name | Type | Description |
|---|---|---|
| variant_uid/variant_alias (required) | string | Enter the UID of the variant |
| data (required) | object | Details of the entry variant |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const data = {
"customized_fields": [
"title",
"url"
],
"base_entry_version": 10, // optional
"entry": {
"title": "example",
"url": "/example"
}
}
}
client.stack({ api_key: 'api_key'}).variantGroup('variant_group_uid/variant_group_alias').variants('variant_uid/variant_alias').update({ data })
.then((variant) => console.log(variant))