Add initial classifications

post
https://api.box.com/2.0
/metadata_templates/schema

When an enterprise does not yet have any classifications, this API call initializes the classification template with an initial set of classifications.

If an enterprise already has a classification, the template will already exist and instead an API call should be made to add additional classifications.

Request

bearer [ACCESS_TOKEN]
application/json

Request Body

booleanin bodyoptional
false

Determines if classifications are copied along when the file or folder is copied.

stringin bodyrequired
"Classification"

The name of the template as shown in web and mobile interfaces.

Value is always Classification

object arrayin bodyrequired

The classification template requires exactly one field, which holds all the valid classification values.

stringin bodyrequired
"enum"

The type of the field that is always enum.

Value is always enum

stringin bodyrequired
"Classification"

A display name for the classification.

Value is always Classification

booleanin bodyoptional
false

Determines if the classification template is hidden or available on web and mobile devices.

stringin bodyrequired
"Box__Security__Classification__Key"

Defines classifications available in the enterprise.

Value is always Box__Security__Classification__Key

object arrayin bodyrequired

The actual list of classifications that are present on this template.

stringin bodyrequired
"Sensitive"

The display name and key this classification. This will be show in the Box UI.

Additional information about the classification.

Additional information about the classification.

booleanin bodyoptional
false

Determines if the classification template is hidden or available on web and mobile devices.

stringin bodyrequired
"enterprise"

The scope in which to create the classifications. This should be enterprise or enterprise_{id} where id is the unique ID of the enterprise.

Value is always enterprise

stringin bodyrequired
"securityClassification-6VMVochwUWo"

Defines the list of metadata templates.

Value is always securityClassification-6VMVochwUWo

Response

Returns a new securityClassification metadata template, which contains a Box__Security__Classification__Key field that lists all the classifications available to this enterprise.

application/jsonClient error

Returned if any of the request parameters are not valid.

application/jsonClient error

Returned when a template name is not correct. Please make sure the URL for the request is correct.

application/jsonClient error

An unexpected client error.

post
Add initial classifications
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -i -X POST "https://api.box.com/2.0/metadata_templates/schema" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "templateKey": "securityClassification-6VMVochwUWo",
       "scope": "enterprise",
       "displayName": "Classification",
       "hidden": false,
       "copyInstanceOnItemCopy": true,
       "fields": [
         {
           "type": "enum",
           "key": "Box__Security__Classification__Key",
           "displayName": "Classification",
           "hidden": false,
           "options": [
             {
               "key": "Classified",
               "staticConfig": {
                 "classification": {
                   "colorID": 7,
                   "classificationDefinition": "Top Seret"
                 }
               }
             }
           ]
         }
       ]
     }'
.NET
var field = new BoxMetadataTemplateField
{
    DisplayName = "Classification",
    Type = "enum",
    Key = "Box_Security_Classification_Key",
    Options = new List<BoxMetadataTemplateFieldOption>() 
    {
        new BoxMetadataTemplateFieldOption
        {
            Key = "Classified"
        }
    }
};

var metadataTemplate = new BoxMetadataTemplate
{
    DisplayName = "Classification",
    TemplateKey = "securityClassification-6VMVochwUWo",
    Scope = "enterprise",
    Fields = new List<BoxMetadataTemplateField>() { field },
};

var template = await client.MetadataManager.CreateMetadataTemplate(metadataTemplate);
Java
MetadataTemplate.Field classification = new MetadataTemplate.Field();
classification.setType("enum");
classification.setKey(Metadata.CLASSIFICATION_KEY);
classification.setDisplayName("Classification");
classification.setHidden("false");

List<String> options = new ArrayList<String>();
options.add("Top Secret");
classification.setOptions(topSecret)

List<MetadataTemplate.Field> fields = new ArrayList<MetadataTemplate.Field>();
fields.add(classification);

MetadataTemplate template = MetadataTemplate.createMetadataTemplate(api, Metadata.ENTERPRISE_METADATA_SCOPE, Metadata.CLASSIFICATION_TEMPLATE_KEY, "Classification", false, fields);
Python
from boxsdk.object.metadata_template import MetadataField, MetadataFieldType

fields = [
    MetadataField(MetadataFieldType.ENUM, 'Classification', key='Box__Security__Classification__Key', options=['Top Secret'])
]

template = client.create_metadata_template('Classification', fields, template_key='securityClassification-6VMVochwUWo')
Node
client.metadata.createTemplate(
		'Classification',
		[
      {
        type: "enum",
        key: "Box__Security__Classification__Key",
        displayName: "Classification",
        hidden: false,
        options: [
         {
           key: "Classified",
           staticConfig: {
             classification: {
               colorID: 7,
               classificationDefinition: "Top Seret"
             }
           }
         }
       ]
      }
    ],
		{
			hidden: false,
			templateKey: 'securityClassification-6VMVochwUWo'
		}
	)
	.then(template => {
		// the new classification template
	});

Response Example

{
  "id": "58063d82-4128-7b43-bba9-92f706befcdf",
  "type": "metadata_template",
  "copyInstanceOnItemCopy": true,
  "displayName": "Classification",
  "fields": [
    {
      "id": "822227e0-47a5-921b-88a8-494760b2e6d2",
      "type": "enum",
      "key": "Box__Security__Classification__Key",
      "displayName": "Classification",
      "hidden": false,
      "options": [
        {
          "id": "46aea176-3483-4431-856c-6b5b13d1cc50",
          "key": "Sensitive",
          "staticConfig": {
            "classification": {
              "classificationDefinition": "Sensitive information",
              "colorID": 4
            }
          }
        }
      ]
    }
  ],
  "hidden": false,
  "scope": "enterprise_123456",
  "templateKey": "securityClassification-6VMVochwUWo"
}