Manage Applications

    Update metadata template

    put
    https://api.box.com/2.0
    /metadata_templates/:scope/:template_key/schema

    Updates a metadata template.

    The metadata template can only be updated if the template already exists.

    The update is applied atomically. If any errors occur during the application of the operations, the metadata template remains unchanged.

    Request

    application/json

    Path Parameters

    stringin pathrequired
    enterprise_27335

    The scope of the metadata template

    Value is one of "global", "enterprise_<id>"

    stringin pathrequired
    blueprintTemplate

    The name of the metadata template

    Response

    application/jsonMetadata Template

    Returns the updated metadata template, with the custom template data included.

    application/jsonClient Error

    The request body contains an invalid metadata schema.

    application/jsonClient Error

    The request body contains a scope that the user is not allowed to create templates for.

    application/jsonClient Error

    The requested template could not be found

    You can now try out some of our APIs live, right here in the documentation.
    Log In

    Request Example

    cURL
    curl -X PUT https://api.box.com/2.0/metadata_templates/enterprise_27335/blueprintTemplate/schema \
         -H "Authorization: Bearer <ACCESS_TOKEN>" \
         -H "Content-Type: application/json" \
         -d '[
           {
             "op": "editField",
             "fieldKey": "category",
             "data": {
               "displayName": "Customer Group"
             }
           }
         ]'
    .NET
    var updates = new List<BoxMetadataTemplateUpdate>()
    {
        new BoxMetadataTemplateUpdate()
        {
            Op = MetadataTemplateUpdateOp.addEnumOption,
            FieldKey = "fy",
            Data = new {
                key = "FY20"
            }
        },
        new BoxMetadataTemplateUpdate()
        {
            Op = MetadataTemplateUpdateOp.editTemplate,
            Data = new {
                hidden = false
            }
        }
    };
    BoxMetadataTemplate updatedTemplate = await client.MetadataManager
        .UpdateMetadataTemplate(updates, "enterprise", "marketingCollateral");
    Java
    List<MetadataTemplate.FieldOperation> updates = new ArrayList<MetadataTemplate.FieldOperation>();
    
    String addCategoryFieldJSON = "{\"op\":\"addField\","\"data\":{"
        + "\"displayName\":\"Category\",\"key\":\"category\",\"hidden\":false,\"type\":\"string\"}}";
    updates.add(new MetadataTemplate.FieldOperation(addCategoryFieldJSON));
    
    String changeTemplateNameJSON = "{\"op\":\"editTemplate\",\"data\":{"
        + "\"displayName\":\"My Metadata\"}}";
    updates.add(new MetadataTemplate.FieldOperation(changeTemplateNameJSON));
    
    MetadataTemplate.updateMetadataTemplate(api, "enterprise", "myData", updates);
    Python
    template = client.metadata_template('enterprise', 'employeeRecord')
    updates = template.start_update()
    updates.add_enum_option('state', 'WI')
    updates.edit_template({'hidden': False})
    updated_template = template.update_info(updates)
    Node
    // Add a new option to the Fiscal Year field, and un-hide the template
    var operations = [
    	{
    		op: 'addEnumOption',
    		fieldKey: 'fy',
    		data: { key: 'FY20' }
    	},
    	{
    		op: 'editTemplate',
    		data: { hidden: false }
    	}
    ];
    client.metadata.updateTemplate('enterprise', 'vcontract', operations)
    	.then(template => {
    		/* template -> {
    			templateKey: 'vcontract',
    			scope: 'enterprise_12345',
    			displayName: 'Vendor Contract',
    			hidden: false,
    			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' },
    					{ key: 'FY20' } ],
    				hidden: false } ] }
    		*/
    	});

    Response Example

    {
      "scope": "enterprise_123456",
      "templateKey": "productInfo",
      "displayName": "Product Info",
      "hidden": true,
      "fields": [
        {
          "type": "string",
          "key": "category",
          "displayName": "Category",
          "description": "The category",
          "hidden": true,
          "options": [
            {
              "id": "f7a9895f",
              "key": "category1"
            }
          ]
        }
      ],
      "id": "f7a9891f"
    }