メインコンテンツへスキップ
POST
/
files
/
{file_id}
/
metadata
/
{scope}
/
{template_key}
cURL
curl -i -X POST "https://api.box.com/2.0/files/12345/metadata/enterprise_27335/blueprintTemplate" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "audience": "internal",
       "documentType": "Q1 plans",
       "competitiveDocument": "no",
       "status": "active",
       "author": "Jones",
       "currentState": "proposal"
     }'
client.file_metadata.create_file_metadata_by_id(
file.id,
CreateFileMetadataByIdScope.ENTERPRISE,
template_key,
{
"name": "John",
"age": 23,
"birthDate": "2001-01-03T02:20:50.520Z",
"countryCode": "US",
"sports": ["basketball", "tennis"],
},
)
await client.fileMetadata.createFileMetadataById(
file.id,
'enterprise' as CreateFileMetadataByIdScope,
templateKey,
{
['name']: 'John',
['age']: 23,
['birthDate']: '2001-01-03T02:20:50.520Z',
['countryCode']: 'US',
['sports']: ['basketball', 'tennis'],
},
);
try await client.fileMetadata.createFileMetadataById(fileId: file.id, scope: CreateFileMetadataByIdScope.global, templateKey: "properties", requestBody: ["abc": "xyz"])
client.getFileMetadata().createFileMetadataById(file.getId(), CreateFileMetadataByIdScope.ENTERPRISE, templateKey, mapOf(entryOf("name", "John"), entryOf("age", 23), entryOf("birthDate", "2001-01-03T02:20:50.520Z"), entryOf("countryCode", "US"), entryOf("sports", Arrays.asList("basketball", "tennis"))))
await client.FileMetadata.CreateFileMetadataByIdAsync(fileId: file.Id, scope: CreateFileMetadataByIdScope.Enterprise, templateKey: templateKey, requestBody: new Dictionary<string, object>() { { "name", "John" }, { "age", 23 }, { "birthDate", "2001-01-03T02:20:50.520Z" }, { "countryCode", "US" }, { "sports", Array.AsReadOnly(new [] {"basketball","tennis"}) } });
{
  "$parent": "folder_59449484661,",
  "$template": "marketingCollateral",
  "$scope": "enterprise_27335",
  "$version": 1,
  "$canEdit": true,
  "$id": "01234500-12f1-1234-aa12-b1d234cb567e",
  "$type": "properties-6bcba49f-ca6d-4d2a-a758-57fe6edf44d0",
  "$typeVersion": 2
}
{
"code": "bad_request",
"message": "Encountered invalid value for template field key=someKey field type=properties",
"request_id": "abcdef123456"
}
{
"type": "error",
"status": 400,
"code": "item_name_invalid",
"message": "Method Not Allowed",
"context_info": {
"message": "Something went wrong"
},
"help_url": "https://developer.box.com/guides/api-calls/permissions-and-errors/common-errors/",
"request_id": "abcdef123456"
}
{
"code": "bad_request",
"message": "Encountered invalid value for template field key=someKey field type=properties",
"request_id": "abcdef123456"
}
{
"type": "error",
"status": 400,
"code": "item_name_invalid",
"message": "Method Not Allowed",
"context_info": {
"message": "Something went wrong"
},
"help_url": "https://developer.box.com/guides/api-calls/permissions-and-errors/common-errors/",
"request_id": "abcdef123456"
}
このリソースは、バージョン2024.0のエンドポイントで使用されています。 詳細については、 Box APIのバージョン管理を参照してください。Box SDKのバージョニング戦略について詳しく学ぶ。」

承認

Authorization
string
header
必須

The access token received from the authorization server in the OAuth 2.0 flow.

パスパラメータ

file_id
string
必須

ファイルを表す一意の識別子。

ファイルIDを確認するには、ウェブアプリケーションでファイルにアクセスして、URLからIDをコピーします。たとえば、URLがhttps://*.app.box.com/files/123の場合、file_id123です。

scope
enum<string>
必須

メタデータテンプレートのスコープ。

利用可能なオプション:
global,
enterprise
template_key
string
必須

メタデータテンプレートの名前。

ボディ

application/json
{key}
any

メタデータテンプレートに存在する各フィールドの値。global.propertiesテンプレートの場合、汎用的なキー/値ペアをテンプレートに保存できるため、0個以上のフィールドのリストにすることができます。メタデータ階層フィールドの場合、複数選択がサポートされるため、値は選択したメタデータ階層ノードのノード識別子のリストになります。設定されている選択対象のメタデータ階層フィールドが1つだけである場合、リストには単一のノード識別子が含まれます。

:

"Aaron Levie"

レスポンス

テンプレートに適用されたデータを含む、ファイルに適用されたテンプレートのインスタンスを返します。

ファイルまたはフォルダに適用された、メタデータテンプレートのインスタンス。

$parent
string

このメタデータインスタンスが追加されている項目の識別子。これは、親のtypeid{type}_{id}という形式で組み合わせたものです。

:

"folder_59449484661,"

$template
string

テンプレートの名前。

:

"marketingCollateral"

$scope
string

このテンプレートが適用されているスコープのID。これは、この会社で使用するために定義されたテンプレートの場合はenterprise_{enterprise_id}、Boxを使用するすべての会社が利用できる一般的なテンプレートの場合はglobalになります。

:

"enterprise_27335"

$version
integer

メタデータインスタンスのバージョン。このバージョンは0から始まり、ユーザー定義プロパティが変更されるたびに増加します。

:

1

$canEdit
boolean

このメタデータインスタンスをユーザーが編集できるかどうか。

:

true

$id
string<uuid>

メタデータインスタンスを識別するためのUUID。

Maximum string length: 36
:

"01234500-12f1-1234-aa12-b1d234cb567e"

$type
string

このインスタンスの「タイプ」に対応する一意の識別子。これは内部システムプロパティであるため、クライアントアプリケーションでは使用しないでください。

:

"properties-6bcba49f-ca6d-4d2a-a758-57fe6edf44d0"

$typeVersion
integer

オブジェクトテンプレートの既知の最新バージョン。これは内部システムプロパティであるため、クライアントアプリケーションでは使用しないでください。

:

2

{key}
any

メタデータテンプレートに存在する各フィールドの値。global.propertiesテンプレートの場合、汎用的なキー/値ペアをテンプレートに保存できるため、0個以上のフィールドのリストにすることができます。

:

"Aaron Levie"

最終更新日 2026年1月23日