Entry Variants
Entry Variants
Entry Variants let you create different versions of content for specific audiences, languages, or marketing experiments. Each variant is grouped under a Base Entry—the original content item. Entry Variants are the tailored versions, and all variants are organized into a Variant Group. This setup makes it easier to manage personalized content, maintain consistency, and apply updates across all versions efficiently.
Get All Entry Variants
The Get all entry variants request retrieves all entry variants of the specified entry.
To fetch specific variants, pass one or more variant UIDs in the x-cs-variant-uid header. This returns only the variants applied to the specified entries.
Note You can add up to three variant UIDs in the x-cs-variant-uid header, separated by commas. The first UID in the list has the highest priority and its content will be used first.
>For example, if you enter Red, Green, and Blue in that order, Red will be given priority.
Example: x-cs-variant-uid: cs6c42daef493fb432, cs7697ce80c9bbcc3e, cs8697ce80c9bbcc4f
You can add other Queries to extend the functionality of this API call.
- The API timeout for entry variants is capped at 10 seconds.
- The maximum response document size for all entry variants is 10 MB
Example 1:
import contentstack
stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
content_type = stack.content_type(content_type_uid)
response = content_type.variants('variants_uid1').find()Example 2:
import contentstack
stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
content_type = stack.content_type(content_type_uid)
response = content_type.variants(['variants_uid_1', 'variants_uid_2', 'variants_uid_3' ]).find()Get a Single Entry Variants
The Get a single entry variant request retrieves a single variant entry of a given base entry.
To fetch variants applied to your entries, pass the the variant UID(s) in the x-cs-variant-uid header.
Note You can add up to three variant UIDs in the x-cs-variant-uid header, separated by commas. The first UID in the list has the highest priority and its content will be used first. For example, if you enter Red, Green, and Blue in that order, Red will be given priority.Example: x-cs-variant-uid: cs6c42daef493fb432, cs7697ce80c9bbcc3e, cs8697ce80c9bbcc4f
You can add other Queries to extend the functionality of this API call.
- The API timeout for entry variants is capped at 10 seconds.
- The maximum response document size for all entry variants is 10 MB
Example 1:
import contentstack
stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
entry = stack.content_type(content_type_uid).entry('entry_uid')
response = entry.variants('variants_uid1').fetch()
)Example 2:
import contentstack
stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
entry = stack.content_type(content_type_uid).entry('entry_uid')
response = entry.variants(['variants_uid_1', 'variants_uid_2', 'variants_uid_3' ]).fetch()