Content type snippets
- Snippets cannot contain the URL slug, subpage, and content type snippet elements.
- Snippets cannot specify their own content groups.
https://manage.kontent.ai/v2/projects/{environment_id}/snippetshttps://manage.kontent.ai/v2/projects/{environment_id}/snippets/{snippet_identifier}https://manage.kontent.ai/v2/projects/{environment_id}/snippetshttps://manage.kontent.ai/v2/projects/{environment_id}/snippets/{snippet_identifier}https://manage.kontent.ai/v2/projects/{environment_id}/snippets/{snippet_identifier}environment_idThe content type snippet to be added.
codenamenameelements[]idcodenamelast_modifiedenvironment_idsnippet_identifieridcodenamelast_modifiedenvironment_idx-continuationsnippets[]environment_idsnippet_identifierThe operations to perform on the specified content type snippet and its elements.
idcodenamelast_modifiedenvironment_idsnippet_identifierexternal_idnameelements[]external_idnameelements[]external_idpaginationoppathvaluenamenameelements[]external_idnametypecodenameexternal_idnametypeidcodenamenametypeidcodenametypecodenameexternal_idguidelinesasset_count_limitvalueconditionmaximum_file_sizeallowed_file_typesimage_width_limitvalueconditionimage_height_limitvalueconditionis_requiredis_non_localizabledefaultcontent_groupidcodenameexternal_idbeforeafternametypeidcodenameguidelinesasset_count_limitvalueconditionmaximum_file_sizeallowed_file_typesimage_width_limitvalueconditionimage_height_limitvalueconditionis_requiredis_non_localizabledefaultexternal_idguidelinesasset_count_limitvalueconditionmaximum_file_sizeallowed_file_typesimage_width_limitvalueconditionimage_height_limitvalueconditionis_requiredis_non_localizabledefaultexternal_idguidelinesasset_count_limitvalueconditionmaximum_file_sizeallowed_file_typesimage_width_limitvalueconditionimage_height_limitvalueconditionis_requiredis_non_localizabledefaultexternal_idguidelinesasset_count_limitvalueconditionmaximum_file_sizeallowed_file_typesimage_width_limitvalueconditionimage_height_limitvalueconditionis_requiredis_non_localizabledefaultaddInto operation to add new objects. For example, add an element to the content type snippet, or add a multiple choice element option.move operation to reorder objects. For example, change the position of an element within the content type snippet or the position of a multiple choice element option.remove operation to delete objects. For example, delete an element from the content type snippet, or delete a specific multiple choice element option.replace operation to update values. For example, replace the value of a specific object property such as a codename.path to the element or its property using a {path_reference}. Path references can use internal IDs, codenames, or external IDs.
id:5eb3d03e-c69d-4e93-b4cc-76f453271386codename:snippet_codename__my_text_elementexternal_id:id_from_external_source – Special characters such as slashes (/) need to be escaped. For example, to reference an object using its external ID of my/value, you use a path reference of external_id:my\\/value.name and can later be modified.name and can later be modified.baf884be-531f-441f-ae88-64205efdd0f6), external ID (e.g., external-id/snippet-type-123), or codename (e.g., codename/metadata).name and can later be modified.x-continuation header parameter to the value of the continuation_token property.baf884be-531f-441f-ae88-64205efdd0f6), external ID (e.g., external-id/snippet-type-123), or codename (e.g., codename/metadata).name and can later be modified.baf884be-531f-441f-ae88-64205efdd0f6), external ID (e.g., external-id/snippet-type-123), or codename (e.g., codename/metadata).{path_reference} for the element.path to /elements.path to /elements/{path_reference}/allowed_content_types.path to /elements/{path_reference}/allowed_elements.path to /elements/{path_reference}/optionspath:name.name.value.value.value.content_group property is present only if one or more content groups are defined in the content type.codename property must meet the conditions defined in rules for codenames.idcodenamelast_modifiednameelements[]external_idvalue.value.value.name.value.value.value.name.value.value.value.external_id property must not contain the following characters: /, ., ;.name.value.value.value.nametypeidcodenameexternal_idguidelinesasset_count_limitvalueconditionmaximum_file_sizeallowed_file_typesimage_width_limitvalueconditionimage_height_limitvalueconditionis_requiredis_non_localizabledefaultname and can later be modified.name.value.value.value.addInto to add new objectsmove to reorder objectsremove to delete objectsreplace to modify object properties{
"id": "baf884be-531f-441f-ae88-64205efdd0f6",
"codename": "my_metadata",
"last_modified": "2019-10-20T12:03:17.4685693Z",
"name": "My metadata",
"elements": [
{
"name": "Meta title",
"guidelines": "Length: 30–60 characters",
"is_non_localizable": false,
"type": "text",
"id": "09398b24-61ed-512e-5b5c-affd54a098e5",
"codename": "my_metadata__meta_title"
},
{
"name": "Meta description",
"guidelines": "Length: 70–150 characters",
"is_non_localizable": false,
"type": "text",
"id": "2e555cc1-1eae-520c-189e-28548904f529",
"codename": "my_metadata__meta_description"
}
],
"external_id": "my-valuable-metadata"
}{
"id": "c295baa0-f910-499f-9ca2-523be657019d",
"codename": "my_metadata",
"name": "Metadata",
"external_id": "my_metadata_elements",
"elements": [
{
"name": "Meta title",
"guidelines": "Length: 30–60 characters",
"is_non_localizable": false,
"type": "text",
"id": "c44bf9dd-aa3f-41c7-b4d9-a09390e41e16",
"codename": "my_metadata__meta_title",
"external_id": "my-meta-title"
},
{
"name": "Meta description",
"guidelines": "Length: 70-150 characters",
"is_non_localizable": false,
"type": "text",
"id": "59b9800b-81a9-4720-bef0-d4cecbaa646c",
"codename": "my_metadata__meta_description",
"external_id": "my-meta-description"
}
]
}{
"id": "baf884be-531f-441f-ae88-64205efdd0f6",
"codename": "my_metadata",
"last_modified": "2018-06-20T10:25:49.133Z",
"name": "My metadata",
"external_id": "snippet-type-123",
"elements": [
{
"name": "Meta title",
"guidelines": "Length: 30–60 characters",
"is_non_localizable": false,
"type": "text",
"id": "09398b24-61ed-512e-5b5c-affd54a098e5",
"codename": "my_metadata__meta_title"
},
{
"name": "Meta description",
"guidelines": "Length: 70–150 characters",
"is_non_localizable": false,
"type": "text",
"id": "2e555cc1-1eae-520c-189e-28548904f529",
"codename": "my_metadata__meta_description"
}
]
}{
"snippets": {
"id": "baf884be-531f-441f-ae88-64205efdd0f6",
"codename": "my_metadata",
"last_modified": "2019-10-20T12:03:17.4685693Z",
"name": "My metadata",
"elements": [
{
"name": "Meta title",
"guidelines": "Length: 30–60 characters",
"is_non_localizable": false,
"type": "text",
"id": "09398b24-61ed-512e-5b5c-affd54a098e5",
"codename": "my_metadata__meta_title"
},
{
"name": "Meta description",
"guidelines": "Length: 70–150 characters",
"is_non_localizable": false,
"type": "text",
"id": "2e555cc1-1eae-520c-189e-28548904f529",
"codename": "my_metadata__meta_description"
}
],
"external_id": "my-valuable-metadata"
},
"pagination": {
"continuation_token": "W3sidG9rZW4iOiIrUklEOn...",
"next_page": "https://manage.kontent.ai/v2/your/chosen/list/endpoint"
}
}{
"request_id": "|e7fd2e620a1e6445ab42f555d8fd7b6f.1c90015b_",
"error_code": 0,
"message": "Type 'Metadata (baf884be-531f-441f-ae88-64205efdd0f6)' is still used and cannot be archived."
}// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: 'KONTENT_AI_ENVIRONMENT_ID',
apiKey: 'KONTENT_AI_MANAGEMENT_API_KEY',
});
const response = await client
.viewContentTypeSnippet()
.byTypeId('269202ad-1d9d-47fd-b3e8-bdb05b3e3cf0')
// .byTypeCodename('hosted_video')
// .byTypeExternalId('snippet-type-123')
.toPromise();
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: 'KONTENT_AI_ENVIRONMENT_ID',
apiKey: 'KONTENT_AI_MANAGEMENT_API_KEY',
});
// Gets the first page of results
const response = await client.listContentTypeSnippets().toPromise();
// Gets all pages of results
// const response = await client.listContentTypeSnippets()
// .toAllPromise();
{
"id": "c8fcc464-b937-4558-a386-c1e25aa93813",
"codename": "my_metadata_snippet",
"last_modified": "2019-08-06T09:19:12.241774Z",
"external_id": "my-metadata-snippet-id",
"name": "A new snippet name",
"elements": [
{
"maximum_text_length": {
"value": 150,
"applies_to": "characters"
},
"name": "My meta description",
"guidelines": "Length: 70-150 characters.",
"is_required": false,
"is_non_localizable": false,
"type": "text",
"id": "f79ad793-b01d-42b0-b06c-7043cd9b6f31",
"codename": "my_metadata_snippet__my_meta_description"
},
{
"maximum_text_length": null,
"name": "My meta title",
"guidelines": "Length: 30–60 characters.",
"is_required": false,
"is_non_localizable": false,
"type": "text",
"external_id": "my-meta-title-id",
"id": "0eb2bcda-5b9f-4425-b9e1-c7679356e456",
"codename": "my_metadata_snippet__my_meta_title"
},
{
"mode": "single",
"options": [
{
"id": "8e6ec8b1-6510-4b9b-b4be-6c977f4bdfbc",
"codename": "another_multiple_choice_option",
"name": "Another multiple choice option"
},
{
"id": "6bfe5a60-5cc2-4303-8f72-9cc53431046b",
"codename": "my_other_multiple_choice_option",
"name": "My other multiple choice option"
}
],
"name": "My multiple choice",
"guidelines": null,
"is_required": false,
"is_non_localizable": false,
"id": "fcc30f1e-9abf-41da-8693-ed89f3be438d",
"codename": "my_metadata_snippet__my_multiple_choice",
"type": "multiple_choice",
"external_id": "my-multiple-choice-id"
}
]
}// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: 'KONTENT_AI_ENVIRONMENT_ID',
apiKey: 'KONTENT_AI_MANAGEMENT_API_KEY',
});
const response = await client
.deleteContentTypeSnippet()
.byTypeId('baf884be-531f-441f-ae88-64205efdd0f6')
// .byTypeCodename('metadata')
// .byTypeExternalId('snippet-type-123')
.toPromise();
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: 'KONTENT_AI_ENVIRONMENT_ID',
apiKey: 'KONTENT_AI_MANAGEMENT_API_KEY',
});
const response = await client
.addContentTypeSnippet()
.withData((builder) => {
return {
name: 'metadata',
codename: 'my_metadata',
external_id: 'snippet-item-123',
elements: [
builder.textElement({
name: 'Meta title',
codename: 'my_metadata__meta_title',
guidelines: 'Length: 30–60 characters',
type: 'text',
external_id: 'meta_title',
}),
builder.textElement({
name: 'Meta description',
codename: 'my_metadata__meta_description',
guidelines: 'Length: 70-150 characters',
external_id: 'meta_title',
}),
],
};
})
.toPromise();
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: 'KONTENT_AI_ENVIRONMENT_ID',
apiKey: 'KONTENT_AI_MANAGEMENT_API_KEY',
});
const response = await client
.modifyContentTypeSnippet()
.byTypeId('269202ad-1d9d-47fd-b3e8-bdb05b3e3cf0')
// .byTypeCodename('hosted_video')
// .byTypeExternalId('snippet-type-123')
.withData([
{
op: 'replace',
path: '/name',
value: 'A new snippet name',
},
{
op: 'replace',
path: '/elements/codename:my_metadata__my_meta_description/guidelines',
value: 'Length: 70-150 characters.',
},
{
op: 'addInto',
path: '/elements',
value: {
name: 'My meta title',
type: 'text',
guidelines: 'Length: 30–60 characters.',
external_id: 'my-meta-title-id',
},
},
{
op: 'remove',
path: '/elements/id:0b2015d0-16ae-414a-85f9-7e1a4b3a3eae',
},
{
op: 'remove',
path: '/elements/external_id:my_multiple_choice/options/codename:my_option',
},
])
.toPromise();