Ungrouped Variant

View as Markdown

Ungrouped Variant

Ungrouped variants are individual variants that are not linked to any variant group. This means they exist independently, without being part of a larger set or category of related variants. This approach allows for greater flexibility in managing and using these variants as they are not constrained by group associations.

Create variant

The Create variant method allows you to create an ungrouped variant.

NameTypeDescription
data (required)object

Details of the entry variant

Example:

import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const data = {
  "uid": "iphone_color_white", // optional
  "name": "White",
  "personalize_metadata": {
      "experience_uid": "exp1",
      "experience_short_uid": "expShortUid1",
      "project_uid": "project_uid1",
      "variant_short_uid": "variantShort_uid1"
  },
}
client.stack({ api_key: 'api_key'}).variants().create({ data })
.then((variant) => console.log(variant))

Delete variant

The Delete variant method allows you to delete a specific variant.

NameTypeDescription
variant_uid (required)String

Enter the UID of the variant

Example:

import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).variants('variant_uid').delete()
.then((response) => console.log(response.notice))

Get a single variant

The Get a single variant method allows you to retrieve the details for a specific variant.

NameTypeDescription
variant_uid (required)String

Enter the UID of the variant

Example:

import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).variants('variant_uid').fetch()
.then((variant) => console.log(variant))

Get all variant

The Get all variants method allows you to retrieve details for all or specific variants.

NameTypeDescription
params.query (required)object

Queries to retrieve filtered results

Example:

import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).variants().query({ query: { title: 'variant title' } }).find()

.then((variants) => console.log(variants))
))

Get variants by UIDs

The Get variants by UIDs method allows you to retrieve the details for specific variants by their specified UIDs.

NameTypeDescription
variant_uids (required)string[]

Enter the UIDs of variants

Example:

import * as contentstack from '@Contentstack/management'

const client = contentstack.client({ authtoken })

client.stack({ api_key: 'api_key'}).variants().fetchByUIDs(['uid1','uid2',.....]).then((variants) => console.log(variants))