Example code:
import { buildClient } from '@datocms/cma-client-node';
async function run() {
const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
const modelIdOrApiKey = 'blog_post';
const itemType = await client.itemTypes.duplicate(modelIdOrApiKey);
console.log(itemType);
}
run();
Returned output:
{
id: 'DxMaW10UQiCmZcuuA-IkkA',
name: 'Blog post',
api_key: 'post',
collection_appearance: 'compact',
singleton: false,
all_locales_required: false,
sortable: true,
modular_block: false,
draft_mode_active: false,
tree: false,
ordering_direction: null,
ordering_meta: 'created_at',
hint: 'Blog posts will be shown in our website under the Blog section',
inverse_relationships_enabled: false,
meta: {
has_singleton_item: false
},
singleton_item: null,
fields: [
{
type: 'field',
id: 'Pkg-oztERp6o-Rj76nYKJg'
}
],
fieldsets: [
{
type: 'fieldset',
id: '93Y1C2sySkG4Eg0atBRIwg'
}
],
title_field: null,
image_preview_field: null,
excerpt_field: null,
ordering_field: null,
workflow: null
}