Box Developer Documentation
 

    Update metadata on a file

    Update metadata on a file

    Once metadata has been applied to a file or folder there is often a need to update the metadata at a later date.

    Updating a metadata instance is done by applying a set of operations to the original data. These operations are performed atomically, ensuring that the changes are either all applied or not applied at all.

    Learn more about updating instances

    In this case, let's assume we want to change the name of the customer from Box, Inc to Box. We can apply two operations, firstly, we ensure the value of the name is still Box, Inc before we change it, and secondly we make the change.

    cURL
    curl -X PUT https://api.box.com/2.0/files/12345/metadata/enterprise/customerInfo \
        -H "authorization: Bearer <ACCESS_TOKEN>" \
        -H "content-type: application/json-patch+json" \
        -d '[
          {
            "op": "test",
            "path": "/name",
            "value": "Box, Inc"
          },
          {
            "op": "replace",
            "path": "/name",
            "value": "Box"
          }
        ]'
    

    Learn more about all operations

    The API will return the updated metadata instance.

    {
      "name": "Box",
      "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
    }