Box - How To Post Custom Fields

There is a specific order in which custom fields can be posted through API calls to files in Box. The following is an example using sample payload data that can be used as a reference when verifying the necessary API calls to make.

  1. GET /folders/content or utilize another API call to determine the file ID for an example file.
  2. GET /custom-fields/enterprise-templates

    or

    POST /custom-fields/templates  

    {
    "displayName": "Example Template",
    "fields": [
    {
    "description": "Custom Field Example",
    "displayName": "CustomField",
    "hidden": false,
    "key": "custom1",
    "type": "string"
    }
    ],
    "hidden": false,
    "scope": "enterprise",
    "templateKey": "customTemplate"
    }
    Note the template key
  3. POST /files/{id}/custom-fields/{templateKey}/templates
    {
    "scope": "enterprise"
    }
    Note: This will associate the customTemplate template with the selected file.
  4. POST /files/{id}/custom-fields
    {
    "path": "/custom1",
    "scope": "enterprise",
    "template": "customTemplate",
    "value": "Custom Field Value"
    }
    Note: this adds a custom field value to the template. The 'path' field in this POST must reference the fields.key from GET /custom-fields/enterprise-templates with a preceding forward slash.