Create metadata cascade policy

post
https://api.box.com/2.0
/metadata_cascade_policies

Creates a new metadata cascade policy that applies a given metadata template to a given folder and automatically cascades it down to any files within that folder.

In order for the policy to be applied a metadata instance must first be applied to the folder the policy is to be applied to.

Request

Bearer [ACCESS_TOKEN]
application/json

Request Body

stringin bodyrequired
1234567

The ID of the folder to apply the policy to. This folder will need to already have an instance of the targeted metadata template applied to it.

stringin bodyrequired
enterprise

The scope of the targeted metadata template. This template will need to already have an instance applied to the targeted folder.

Value is one of global,enterprise

stringin bodyrequired
productInfo

The key of the targeted metadata template. This template will need to already have an instance applied to the targeted folder.

Response

Returns a new of metadata cascade policy

application/jsonClient error

Returns an error when any of the parameters are not in a valid format.

  • bad_request - Either the scope, templateKey, or folder_id are not in a valid format.
application/jsonClient error

Returns an error when trying to apply a policy to a restricted folder, for example the root folder with ID 0.

  • forbidden - Although the folder ID was valid and the user has access to the folder, the policy could not be applied to this folder.
application/jsonClient error

Returns an error when the template or folder can not be found, or when the user does not have access to the folder or template.

  • instance_tuple_not_found - The template could not be found or the user does not have access to the template.
  • not_found - The folder could not be found or the user does not have access to the folder.
application/jsonConflict error

Returns an error when a policy for this folder and template is already in place.

  • tuple_already_exists - A cascade policy for this combination of folder_id, scope and templateKey already exists.
application/jsonClient error

An unexpected client error.

post
Create metadata cascade policy
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -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"
     }'
.NET
BoxMetadataCascadePolicy metadataCascadePolicy = await client.MetadataCascadePolicyManager
    .CreateCascadePolicyAsync("22222", "enterprise_11111", "templateKey");
Python
folder = client.folder(folder_id='22222')
metadata_template = client.metadata_template('enterprise', 'securityClassiciation')

cascade_policy = folder.cascade_metadata(metadata_template)
print('Folder {0} has a metadata cascade policy for {1} template "{2}"'.format(
    cascade_policy.parent.id,
    cascade_policy.scope,
    cascade_policy.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'
		}
		*/
	});

Response Example

{
  "id": "6fd4ff89-8fc1-42cf-8b29-1890dedd26d7",
  "type": "metadata_cascade_policy",
  "owner_enterprise": {
    "id": 690678,
    "type": "enterprise"
  },
  "parent": {
    "id": 1234567,
    "type": "folder"
  },
  "scope": "global",
  "templateKey": "productInfo"
}