Box Developer Documentation

Apply metadata to a file

Apply metadata to a file

With your new customerData template in hand you can now apply this template to a file or folder. To apply this template you will need the scope and templateKey of the template, as well as the ID of the item to apply the template to.

cURL
curl -X POST https://api.box.com/2.0/files/12345/metadata/enterprise/customerInfo \
    -H "authorization: Bearer <ACCESS_TOKEN>" \
    -H "content-type: application/json" \
    -d '{
      "name": "Box, Inc",
      "industry": "Technology",
      "tav": 1000000
    }'

The industry field in this example is an enum field and therefore the value needs to be one of the available options on the field. Any other value will result in an error.

The API will return the newly created metadata instance.

{
  "name": "Box, Inc",
  "industry": "Technology",
  "tav": 1000000,
  "$id": "01234500-12f1-1234-aa12-b1d234cb567e",
  "$parent": "folder_12345,",
  "$scope": "enterprise_34567",
  "$template": "customerInfo",
  "$type": "customerInfo-6bcba49f-ca6d-4d2a-a758-57fe6edf44d0",
  "$typeVersion": 2,
  "$version": 1,
  "$canEdit": true
}