> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Force-apply metadata to all items in a folder

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = href;
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

When a metadata cascade policy already exists on a folder, the metadata instance
can be force-applied to all items in a folder by calling the
<Link href="/reference/post-metadata-cascade-policies-id-apply">`POST /metadata_cascade_policies/:id/apply`</Link> API endpoint with the
`id` of the metadata cascade policy.

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/metadata_cascade_policies/21312/apply" \
       -H "authorization: Bearer <ACCESS_TOKEN>" \
       -H "content-type: application/json" \
       -d '{
         "conflict_resolution": "overwrite"
       }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.metadataCascadePolicies.applyMetadataCascadePolicy(
    cascadePolicyId,
    {
      conflictResolution:
        'overwrite' as ApplyMetadataCascadePolicyRequestBodyConflictResolutionField,
    } satisfies ApplyMetadataCascadePolicyRequestBody,
  );
  ```

  ```python Python v10 theme={null}
  client.metadata_cascade_policies.apply_metadata_cascade_policy(
      cascade_policy_id, ApplyMetadataCascadePolicyConflictResolution.OVERWRITE
  )
  ```

  ```csharp .NET v10 theme={null}
  await client.MetadataCascadePolicies.ApplyMetadataCascadePolicyAsync(metadataCascadePolicyId: cascadePolicyId, requestBody: new ApplyMetadataCascadePolicyRequestBody(conflictResolution: ApplyMetadataCascadePolicyRequestBodyConflictResolutionField.Overwrite));
  ```

  ```swift Swift v10 theme={null}
  try await client.metadataCascadePolicies.applyMetadataCascadePolicy(metadataCascadePolicyId: cascadePolicyId, requestBody: ApplyMetadataCascadePolicyRequestBody(conflictResolution: ApplyMetadataCascadePolicyRequestBodyConflictResolutionField.overwrite))
  ```

  ```java Java v10 theme={null}
  client.getMetadataCascadePolicies().applyMetadataCascadePolicy(cascadePolicyId, new ApplyMetadataCascadePolicyRequestBody(ApplyMetadataCascadePolicyRequestBodyConflictResolutionField.OVERWRITE))
  ```

  ```java Java v5 theme={null}
  String cascadePolicyID = "e4392a41-7de5-4232-bdf7-15e0d6bba067";
  BoxMetadataCascadePolicy policy = new BoxMetadataCascadePolicy(api, cascadePolicyID);
  policy.forceApply("none");
  ```

  ```py Python v4 theme={null}
  from boxsdk.object.metadata_cascade_policy import CascadePolicyConflictResolution

  cascade_policy = client.metadata_cascade_policy(policy_id='84113349-794d-445c-b93c-d8481b223434')
  cascade_policy.force_apply(CascadePolicyConflictResolution.PRESERVE_EXISTING)
  print('Cascade policy was force applied!')
  ```

  ```csharp .NET v6 theme={null}
  string policyId = "11111";
  string conflictResolution = Constants.ConflictResolution.Overwrite
  BoxMetadataCascadePolicy newCascadePolicy = client.MetadataCascadePolicyManager
      .ForceApplyCascadePolicyAsync(policyId, conflictResolution);
  ```

  ```js Node v4 theme={null}
  var policyID = '84113349-794d-445c-b93c-d8481b223434';
  client.metadata.forceApplyCascadePolicy(policyID, client.metadata.cascadeResolution.PRESERVE_EXISTING)
   .then(() => {
    // application started — no value returned
   });
  ```
</CodeGroup>

<Info>
  To get the `id` of the policy,
  <Link href="/guides/metadata/cascades/list">list all policies</Link> for the folder.
</Info>

<Warning>
  The metadata cascade operation will be started off asynchronously. The API
  call will return directly with the `202 Accepted` HTTP status code before
  the cascade operation is complete. There is currently no way to check for when
  this operation is finished.
</Warning>

## Conflict resolution

An additional `conflict_resolution` parameter can be passed to this API to
define how to deal with any existing instances of the template on any of the
items in the folder.

By default, without setting any value for `conflict_resolution` this API will
preserve the existing value on any items. When the value is set to `overwrite`,
it will force-apply the value of the template attached to the cascade policy
over any existing value.

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("Force-apply metadata cascade policy to folder"), href: "/reference/post-metadata-cascade-policies-id-apply", badge: "POST" }
]}
/>

<RelatedLinks
  title="RELATED GUIDES"
  items={[
{ label: translate("List metadata cascade policies"), href: "/guides/metadata/cascades/list", badge: "GUIDE" },
{ label: translate("Force-apply metadata to all items in a folder"), href: "/guides/metadata/cascades/force-apply", badge: "GUIDE" },
{ label: translate("Delete a metadata cascade policy"), href: "/guides/metadata/cascades/delete", badge: "GUIDE" }
]}
/>
