ManagementClient
definition when using an SDK).
After making the request, you’ll get a JSON response like this:
{
"id": "f15799a1-dff0-5216-a014-e963f9ea6bbc",
"codename": "cafe",
"last_modified": "2019-10-08T12:47:27.4261844Z",
"external_id": "cafe",
"name": "Cafe",
"content_groups": [],
"elements": [
{
"name": "Price per unit",
"guidelines": null,
"is_required": false,
"type": "number",
"id": "965cf18c-998a-456b-bee3-91defdf39782",
"codename": "price_per_unit"
},
{
"guidelines": "<h2>Keep Guidelines where the creative process happens.</h2>\n<p>These are sample guidelines that you can place for the whole content item. It’s a place where you can include your content brief, voice and tone recommendations or the URL to a wireframe, so the author will have all the relevant instructions at hand before writing a single line.</p>\n<p>Besides overview guidelines, you can include instructions for each particular content element, as you will see below.</p>",
"type": "guidelines",
"id": "8816e7d0-ca5e-4cfa-88b4-c1944862ff9f",
"codename": "n8e317a38_e3bc_4d98_a63d_f1e336c5a9e6"
},
{
"maximum_text_length": null,
"name": "Street",
"guidelines": null,
"is_required": false,
"type": "text",
"id": "2b7b256c-73cc-4be0-b749-4c410209df02",
"codename": "street"
},
{
"maximum_text_length": null,
"name": "City",
"guidelines": null,
"is_required": false,
"type": "text",
"id": "fa17f73a-833c-4cf2-aa7b-3b5c4edad6b3",
"codename": "city"
},
{
"maximum_text_length": null,
"name": "Country",
"guidelines": null,
"is_required": false,
"type": "text",
"id": "2b36b05e-5f4f-4630-b502-154f5b3b90c3",
"codename": "country"
},
{
"maximum_text_length": null,
"name": "State",
"guidelines": null,
"is_required": false,
"type": "text",
"id": "3638f2cd-3fea-4a4e-a6b6-bdd39f3b9f66",
"codename": "state"
},
{
"maximum_text_length": null,
"name": "ZIP Code",
"guidelines": null,
"is_required": false,
"type": "text",
"id": "35ad677a-cfe5-4573-814d-5895e3de8396",
"codename": "zip_code"
},
{
"maximum_text_length": null,
"name": "Phone",
"guidelines": null,
"is_required": false,
"type": "text",
"id": "4ec54355-4177-4b29-9a16-b25a7c8fba26",
"codename": "phone"
},
{
"maximum_text_length": null,
"name": "Email",
"guidelines": null,
"is_required": false,
"type": "text",
"id": "9bc4b679-4353-40c7-bcfd-145110ced7d9",
"codename": "email"
},
{
"asset_count_limit": null,
"maximum_file_size": null,
"allowed_file_types": "any",
"image_width_limit": null,
"image_height_limit": null,
"name": "Photo",
"guidelines": null,
"is_required": false,
"type": "asset",
"id": "1693ecd3-fb15-4d56-975a-4b8dbdedf65b",
"codename": "photo"
}
]
}
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';
const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_MANAGEMENT_API_KEY>'
});
const response = await client
.addContentType()
.withData((builder) => {
return {
codename: 'cafe',
name: 'Cafe',
external_id: 'cafe',
elements: [
builder.numberElement({
name: 'Price per unit',
type: 'number',
codename: 'price_per_unit'
}),
builder.guidelinesElement({
guidelines:
'<h2>Keep Guidelines where the creative process happens.</h2>\n<p>These are sample guidelines that you can place for the whole content item. It’s a place where you can include your content brief, voice and tone recommendations or the URL to a wireframe, so the author will have all the relevant instructions at hand before writing a single line.</p>\n<p>Besides overview guidelines, you can include instructions for each particular content element, as you will see below.</p>',
type: 'guidelines',
codename: 'n2f836bce_e062_b2cd_5265_f5c3be3aa6f5'
}),
builder.textElement({
name: 'Street',
type: 'text',
codename: 'street'
}),
builder.textElement({
name: 'City',
type: 'text',
codename: 'city'
}),
builder.textElement({
name: 'Country',
type: 'text',
codename: 'country'
}),
builder.textElement({
name: 'State',
type: 'text',
codename: 'state'
}),
builder.textElement({
name: 'ZIP Code',
type: 'text',
codename: 'zip_code'
}),
builder.textElement({
name: 'Phone',
type: 'text',
codename: 'phone'
}),
builder.textElement({
name: 'Email',
type: 'text',
codename: 'email'
}),
builder.assetElement({
name: 'Photo',
type: 'asset',
codename: 'photo'
})
]
};
})
.toPromise();