List all metadata templates

Step 1 of 714%

List all metadata templates

It's likely your enterprise already has a list of metadata templates that you can use right off-the-shelve without having to create your own.

In general, metadata templates are either available to only your enterprise o to every enterprise using Box. The scope of a template defines if a template is available to everyone (global) or only to your enterprise (enterprise).

Learn more about metadata scopes

Listing templates

A few global templates are available to all customers.

cURL
curl -X GET https://api.box.com/2.0/metadata_templates/global \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
.NET
BoxEnterpriseMetadataTemplateCollection<BoxMetadataTemplate> templates = await client.MetadataManager
    .GetEnterpriseMetadataAsync("global");
Java
Iterable<MetadataTemplate> templates = MetadataTemplate.getEnterpriseMetadataTemplates('global', api);
for (MetadataTemplate templateInfo : templates) {
    // Do something with the metadata template.
}
Python
templates = client.get_metadata_templates(scope='global)
for template in templates:
    print('Metadata template {0} is in global scope'.format(template.templateKey))
Node
client.metadata.getTemplates('global')
	.then(templates => {
		// ...
	});
iOS
client.metadata.listEnterpriseTemplates(scope: "global") { results in
    switch results {
    case let .success(iterator):
        for i in 1 ... 10 {
            iterator.next { result in
                switch result {
                case let .success(template):
                    print("Template name: \(template.displayName)")
                case let .failure(error):
                    print(error)
                }
            }
        }
    case let .failure(error):
        print(error)
    }
}

Many of these templates are for Box's internal use, yet your application can use and apply these. More useful are templates created by applications and admins within your enterprise to hold data specific to your enterprise's needs.

cURL
curl -X GET https://api.box.com/2.0/metadata_templates/enterprise \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
.NET
BoxEnterpriseMetadataTemplateCollection<BoxMetadataTemplate> templates = await client.MetadataManager
    .GetEnterpriseMetadataAsync();
Java
Iterable<MetadataTemplate> templates = MetadataTemplate.getEnterpriseMetadataTemplates(api);
for (MetadataTemplate templateInfo : templates) {
    // Do something with the metadata template.
}
Python
templates = client.get_metadata_templates()
for template in templates:
    print('Metadata template {0} is in enterprise scope'.format(template.templateKey))
Node
client.metadata.getTemplates('enterprise')
	.then(templates => {
		/* templates -> {
			limit: 100,
			entries: 
			[ { templateKey: 'documentFlow',
				scope: 'enterprise_12345',
				displayName: 'Document Flow',
				hidden: false,
				fields: 
					[ { type: 'string',
						key: 'currentDocumentStage',
						displayName: 'Current Document Stage',
						hidden: false }
					{ type: 'string',
						key: 'needsApprovalFrom',
						displayName: 'Needs Approval From',
						hidden: false },
					{ type: 'string',
						key: 'nextDocumentStage',
						displayName: 'Next Document Stage',
						hidden: false }
					{ type: 'float',
						key: 'maximumDaysAllowedInCurrentStage',
						displayName: 'Maximum Days Allowed In Current Stage',
						hidden: false }
				{ templateKey: 'marketingCollateral',
				scope: 'enterprise_12345',
				displayName: 'Marketing Collateral',
				hidden: false,
				fields: 
					[ { type: 'string',
						key: 'audience1',
						displayName: 'Audience',
						hidden: false },
					{ type: 'string',
						key: 'previousState',
						displayName: 'Previous State',
						hidden: false } ] },
				{ templateKey: 'productInfo',
				scope: 'enterprise_12345',
				displayName: 'Product Info',
				hidden: false,
				fields: 
					[ { type: 'float',
						key: 'skuNumber',
						displayName: 'SKU Number',
						hidden: false },
					{ type: 'enum',
						key: 'department',
						displayName: 'Department',
						hidden: false,
						options: 
						[ { key: 'Beauty' },
						{ key: 'Shoes' },
						{ key: 'Accessories' },
						{ key: 'Clothing' },
						{ key: 'Handbags' },
						{ key: 'Bedding' },
						{ key: 'Watches' } ] },
					{ type: 'date',
						key: 'displayDate',
						displayName: 'Display Date',
						hidden: false } ] } ],
			next_marker: null,
			prev_marker: null }
		*/
	});
iOS
client.metadata.listEnterpriseTemplates(scope: "enterprise") { results in
    switch results {
    case let .success(iterator):
        for i in 1 ... 10 {
            iterator.next { result in
                switch result {
                case let .success(template):
                    print("Template name: \(template.displayName)")
                case let .failure(error):
                    print(error)
                }
            }
        }
    case let .failure(error):
        print(error)
    }
}

A metadata template

A metadata template describes a set of key/value pairs that can be assigned to a file or folder.

For example, an customerInfo template might hold data about an customer, having a field for the customer name as well as the customer's industry.

{
  "id": "100ac693-a468-4b37-9535-05984b804dc2",
  "type": "metadata_template",
  "templateKey": "customerInfo",
  "scope": "enterprise_12345",
  "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
    }
  ]
}