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.
"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.
"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
"productInfo"
The key of the targeted metadata template. This template will need to already have an instance applied to the targeted folder.
In many cases the template key is automatically derived
of its display name, for example Contract Template
would
become contractTemplate
. In some cases the creator of the
template will have provided its own template key.
Please list the templates for an enterprise, or get all instances on a file or folder to inspect a template's key.
Returns a new of metadata cascade policy
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.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.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.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.An unexpected client error.
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"
}'
await client.metadataCascadePolicies.createMetadataCascadePolicy({
folderId: folder.id,
scope: 'enterprise' as CreateMetadataCascadePolicyRequestBodyScopeField,
templateKey: templateKey,
} satisfies CreateMetadataCascadePolicyRequestBody);
client.metadata_cascade_policies.create_metadata_cascade_policy(
folder.id, CreateMetadataCascadePolicyScope.ENTERPRISE.value, template_key
)
await client.MetadataCascadePolicies.CreateMetadataCascadePolicyAsync(requestBody: new CreateMetadataCascadePolicyRequestBody(folderId: folder.Id, scope: CreateMetadataCascadePolicyRequestBodyScopeField.Enterprise, templateKey: templateKey));
try await client.metadataCascadePolicies.createMetadataCascadePolicy(requestBody: CreateMetadataCascadePolicyRequestBody(folderId: folder.id, scope: CreateMetadataCascadePolicyRequestBodyScopeField.enterprise, templateKey: templateKey))
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}"')
BoxMetadataCascadePolicy metadataCascadePolicy = await client.MetadataCascadePolicyManager
.CreateCascadePolicyAsync("22222", "enterprise_11111", "templateKey");
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'
}
*/
});
{
"id": "6fd4ff89-8fc1-42cf-8b29-1890dedd26d7",
"type": "metadata_cascade_policy",
"owner_enterprise": {
"id": "690678",
"type": "enterprise"
},
"parent": {
"id": "1234567",
"type": "folder"
},
"scope": "enterprise_123456",
"templateKey": "productInfo"
}