Box Developer Documentation

Create a metadata cascade policy

Create a metadata cascade policy

When a metadata template has been applied to a folder, a metadata cascade policy can be created by calling the POST /metadata_cascade_policies API endpoint with the folder_id of the folder to apply the policy to, and the scope and templateKey of metadata template to.

cURL
curl -i -X POST "https://api.box.com/2.0/metadata_cascade_policies" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "folder_id": "12321",
       "scope": "enterprise_27335",
       "templateKey": "productInfo"
     }'
TypeScript Gen
await client.metadataCascadePolicies.createMetadataCascadePolicy({
  folderId: folder.id,
  scope: 'enterprise' as CreateMetadataCascadePolicyRequestBodyScopeField,
  templateKey: templateKey,
} satisfies CreateMetadataCascadePolicyRequestBody);
Python Gen
client.metadata_cascade_policies.create_metadata_cascade_policy(
    folder.id, CreateMetadataCascadePolicyScope.ENTERPRISE.value, template_key
)
.NET Gen
await client.MetadataCascadePolicies.CreateMetadataCascadePolicyAsync(requestBody: new CreateMetadataCascadePolicyRequestBody(folderId: folder.Id, scope: CreateMetadataCascadePolicyRequestBodyScopeField.Enterprise, templateKey: templateKey));
Swift Gen (Beta)
try await client.metadataCascadePolicies.createMetadataCascadePolicy(requestBody: CreateMetadataCascadePolicyRequestBody(folderId: folder.id, scope: CreateMetadataCascadePolicyRequestBodyScopeField.enterprise, templateKey: templateKey))
Python
folder = client.folder(folder_id='22222')
metadata_template = client.metadata_template('enterprise', 'securityClassiciation')

cascade_policy = folder.cascade_metadata(metadata_template)
print(f'Folder {cascade_policy.parent.id} has a metadata cascade policy for {cascade_policy.scope} template "{cascade_policy.templateKey}"')
.NET
BoxMetadataCascadePolicy metadataCascadePolicy = await client.MetadataCascadePolicyManager
    .CreateCascadePolicyAsync("22222", "enterprise_11111", "templateKey");
Node
var folderID = '22222';
client.metadata.createCascadePolicy('enterprise', 'testTemplate', folderID)
	.then(cascadePolicy => {
		/* cascadePolicy -> {
			id: '84113349-794d-445c-b93c-d8481b223434',
			type: 'metadata_cascade_policy',
			owner_enterprise: {
				type: 'enterprise',
				id: '11111'
			},
			parent: {
				type: 'folder',
				id: '22222'
			},
			scope: 'enterprise_11111',
			templateKey: 'testTemplate'
		}
		*/
	});

To get the scope and templateKey for a template, either list all metadata templates, or list all instances on an file.

A cascade policy can only be created if a metadata instance has already been applied to the folder with the given scope and templateKey.