Box Developer Documentation
 

    Create a custom metadata template

    Create a custom metadata template

    To create a custom metadata template for your enterprise you can use our API directly or one of our SDKs to create a new template.

    For this customerInfo template, we're going to create a template with 3 fields. The first field is a text field to hold the customer's name, the second is a dropdown list of the possible values for the industry the customer operates in, and the final field represents the total annual contract value (tav).

    Learn about the different field types

    To create this template we need to pass in the configuration for the fields, as well as a display name for the field.

    cURL
    curl -X POST https://api.box.com/2.0/metadata_templates/schema \
        -H "authorization: Bearer <ACCESS_TOKEN>" \
        -H "content-type: application/json" \
        -d '{
          "scope": "enterprise",
          "displayName": "Customer Info",
          "fields": [
            {
              "type": "string",
              "displayName": "Name"
            },
            {
              "type": "enum",
              "displayName": "Industry",
              "options": [
                {"key": "Technology"},
                {"key": "Healthcare"},
                {"key": "Legal"}
              ]
            },
            {
              "type": "float",
              "displayName": "Total account value",
              "key": "tav"
            }
          ]
        }'
    

    Admin permissions required

    Creating metadata templates is restricted to users with admin permission. This means that only admins, or co-admins who have been granted rights to Create and edit metadata templates for your company by the admin can use the web app or the API to manage templates.

    The API will return the newly created metadata template.

    {
      "id": "100ac693-a468-4b37-9535-05984b804dc2",
      "type": "metadata_template",
      "templateKey": "customerInfo",
      "scope": "enterprise_34567",
      "displayName": "Customer Info",
      "hidden": false,
      "copyInstanceOnItemCopy": false,
      "fields": [
        {
          "id": "5c6a5906-003b-4654-9deb-472583fc2930",
          "type": "string",
          "key": "name",
          "displayName": "Name",
          "hidden": false
        },
        {
          "id": "cf3eb5b8-52ef-456c-b175-44354a27e289",
          "type": "enum",
          "key": "industry",
          "displayName": "Industry",
          "options": [
            {"key": "Technology"},
            {"key": "Healthcare"},
            {"key": "Legal"}
          ],
          "hidden": false
        },
        {
          "id": "5c6a5906-4654-9deb-003b-472583fc2930",
          "type": "float",
          "key": "tav",
          "displayName": "Total account value",
          "hidden": false
        }
      ]
    }
    

    Template key

    Although you did not explicitly set the template key the key is automatically derived from the displayName value. In this case, the templateKey would be customerInfo.