Box Developer Documentation

Join BoxWorks 2024 to discover what's possible with content and AI!

Register now!

Get metadata template by ID

get
https://api.box.com/2.0
/metadata_templates/:template_id

Retrieves a metadata template by its ID.

Request

bearer [ACCESS_TOKEN]
application/json

Path Parameters

stringin pathrequired
f7a9891f

The ID of the template

Response

application/jsonMetadata template

Returns the metadata template that matches the ID.

application/jsonMetadata template

Returned if any of the request parameters are not valid.

  • bad_request: Often returned with a message when the ID of the template is not recognised.
application/jsonClient error

An unexpected client error.

get
Get metadata template by ID
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -i -X GET "https://api.box.com/2.0/metadata_templates/d9671692-3df6-11ea-b77f-2e728ce88125" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
TypeScript Gen
await client.metadataTemplates.getMetadataTemplateById(template.id);
Python Gen
client.metadata_templates.get_metadata_template_by_id(template.id)
.NET Gen
await client.MetadataTemplates.GetMetadataTemplateByIdAsync(templateId: template.Id);
Swift Gen (Beta)
try await client.metadataTemplates.getMetadataTemplateById(templateId: template.id)
Java
MetadataTemplate template = MetadataTemplate.getMetadataTemplateByID(api, "37c0204b-3fe1-4a32-b9da-f28e88f4c4c6");
Python
template = client.metadata_template_by_id(template_id='abcdef-fba434-ace44').get()
print(f'The {template.displayName} template has {len(template.fields)} fields')
.NET
BoxMetadataTemplate template = await client.MetadataManager
    .GetMetadataTemplateById("17f2d715-6acb-45f2-b96a-28b15efc9faa");
Node
client.metadata.getTemplateByID('17f2d715-6acb-45f2-b96a-28b15efc9faa')
	.then(template => {
		/* template -> {
			id: '17f2d715-6acb-45f2-b96a-28b15efc9faa',
			templateKey: 'vcontract',
			scope: 'enterprise_12345',
			displayName: 'Vendor Contract',
			hidden: true,
			fields: 
			[ { type: 'date',
				key: 'signed',
				displayName: 'Date Signed',
				hidden: false },
				{ type: 'string',
				key: 'vendor',
				displayName: 'Vendor',
				hidden: false },
				{ type: 'enum',
				key: 'fy',
				displayName: 'Fiscal Year',
				options: 
					[ { key: 'FY17' },
					{ key: 'FY18' },
					{ key: 'FY19' } ],
				hidden: false } ] }
		*/
	});
iOS
client.metadata.getTemplateById(
    id: "26004e29-7b94-44a1-8a63-f9aa384c7421"
) { (result: Result<MetadataTemplate, BoxSDKError>) in
    guard case let .success(template) = result {
        print("Error retrieving metadata template")
        return
    }

    print("Metadata template has \(template.fields?.count) fields")
}

Response Example

{
  "id": "58063d82-4128-7b43-bba9-92f706befcdf",
  "type": "metadata_template",
  "copyInstanceOnItemCopy": true,
  "displayName": "Product Info",
  "fields": [
    {
      "type": "string",
      "key": "category",
      "displayName": "Category",
      "description": "The category",
      "hidden": true,
      "options": [
        {
          "key": "Category 1",
          "id": "45dc2849-a4a7-40a9-a751-4a699a589190"
        }
      ],
      "id": "822227e0-47a5-921b-88a8-494760b2e6d2"
    }
  ],
  "hidden": true,
  "scope": "enterprise_123456",
  "templateKey": "productInfo"
}