> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get a metadata template

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const [localizedHref, setLocalizedHref] = useState(href);
  const supportedLocales = useMemo(() => ['ja'], []);
  useEffect(() => {
    const getLocaleFromPath = path => {
      const match = path.match(/^\/([a-z]{2})(?:\/|$)/);
      if (match) {
        const potentialLocale = match[1];
        if (supportedLocales.includes(potentialLocale)) {
          return potentialLocale;
        }
      }
      return null;
    };
    const hasLocalePrefix = path => {
      const match = path.match(/^\/([a-z]{2})(?:\/|$)/);
      return match ? supportedLocales.includes(match[1]) : false;
    };
    const currentPath = window.location.pathname;
    const currentLocale = getLocaleFromPath(currentPath);
    if (href && href.startsWith('/') && !hasLocalePrefix(href)) {
      if (currentLocale) {
        setLocalizedHref(`/${currentLocale}${href}`);
      } else {
        setLocalizedHref(href);
      }
    } else {
      setLocalizedHref(href);
    }
  }, [href, supportedLocales]);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

Information for a metadata template can be retrieved using the template's name
and scope, or the template's identifier.

<Info>
  The authenticated user can only get Information about metadata templates
  <Link href="/guides/metadata/scopes">scoped</Link> within the `global` scope or the `enterprise_:id` scope where
  `:id` is  the ID of their enterprise.
</Info>

## Get a metadata template by name

To get a metadata template by name, call the <Link href="/reference/get-metadata-templates-id-id-schema">`GET
/metadata_templates/:scope/:templateKey/schema`</Link> API endpoint with the
template's `scope` and `templateKey`.

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X GET "https://api.box.com/2.0/metadata_templates/enterprise/blueprintTemplate/schema" \
       -H "authorization: Bearer <ACCESS_TOKEN>"
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.metadataTemplates.getMetadataTemplate(
    'enterprise' as GetMetadataTemplateScope,
    template.templateKey!,
  );
  ```

  ```python Python v10 theme={null}
  client.metadata_templates.get_metadata_template(
      GetMetadataTemplateScope.ENTERPRISE, template.template_key
  )
  ```

  ```csharp .NET v10 theme={null}
  await client.MetadataTemplates.GetMetadataTemplateAsync(scope: GetMetadataTemplateScope.Enterprise, templateKey: NullableUtils.Unwrap(template.TemplateKey));
  ```

  ```swift Swift v10 theme={null}
  try await client.metadataTemplates.getMetadataTemplate(scope: GetMetadataTemplateScope.enterprise, templateKey: template.templateKey!)
  ```

  ```java Java v10 theme={null}
  client.getMetadataTemplates().getMetadataTemplate(GetMetadataTemplateScope.ENTERPRISE, template.getTemplateKey())
  ```

  ```java Java v5 theme={null}
  MetadataTemplate template = MetadataTemplate.getMetadataTemplate(api, "templateName");
  ```

  ```py Python v4 theme={null}
  template = client.metadata_template('enterprise', 'employeeRecord').get()
  print(f'The {template.displayName} template has {len(template.fields)} fields')
  ```

  ```csharp .NET v6 theme={null}
  BoxMetadataTemplate template = await client.MetadataManager
      .GetMetadataTemplate("enterprise", "marketingCollateral");
  ```

  ```js Node v4 theme={null}
  client.metadata.getTemplateSchema('enterprise', 'vcontract')
   .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 } ] }
    */
   });
  ```
</CodeGroup>

<Info>
  To get the `scope` and `templateKey` for a template, either
  <Link href="/guides/metadata/templates/list">list all metadata templates</Link>, or
  <Link href="/guides/metadata/instances/list">list all instances on an item</Link>.
</Info>

## Get a metadata template by ID

To get a metadata template by ID, you will need to pass the template's
`id` to the <Link href="/reference/get-metadata-templates-id">`GET
/metadata_templates/:id`</Link> API endpoint.

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X GET "https://api.box.com/2.0/metadata_templates/d9671692-3df6-11ea-b77f-2e728ce88125" \
       -H "authorization: Bearer <ACCESS_TOKEN>"
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.metadataTemplates.getMetadataTemplateById(template.id);
  ```

  ```python Python v10 theme={null}
  client.metadata_templates.get_metadata_template_by_id(template.id)
  ```

  ```csharp .NET v10 theme={null}
  await client.MetadataTemplates.GetMetadataTemplateByIdAsync(templateId: template.Id);
  ```

  ```swift Swift v10 theme={null}
  try await client.metadataTemplates.getMetadataTemplateById(templateId: template.id)
  ```

  ```java Java v10 theme={null}
  client.getMetadataTemplates().getMetadataTemplateById(template.getId())
  ```

  ```java Java v5 theme={null}
  MetadataTemplate template = MetadataTemplate.getMetadataTemplateByID(api, "37c0204b-3fe1-4a32-b9da-f28e88f4c4c6");
  ```

  ```py Python v4 theme={null}
  template = client.metadata_template_by_id(template_id='abcdef-fba434-ace44').get()
  print(f'The {template.displayName} template has {len(template.fields)} fields')
  ```

  ```csharp .NET v6 theme={null}
  BoxMetadataTemplate template = await client.MetadataManager
      .GetMetadataTemplateById("17f2d715-6acb-45f2-b96a-28b15efc9faa");
  ```

  ```js Node v4 theme={null}
  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 } ] }
    */
   });
  ```
</CodeGroup>

<Info>
  To get the `id` for a template, either
  <Link href="/guides/metadata/templates/list">list all metadata templates</Link>, or
  <Link href="/guides/metadata/instances/list">list all instances on an item</Link>.
</Info>

<RelatedLinks
  title="RELATED APIS"
  items={[
  { label: "Get metadata template by name", href: "/reference/get-metadata-templates-id-id-schema", badge: "GET" },
  { label: "Get metadata template by ID", href: "/reference/get-metadata-templates-id", badge: "GET" }
]}
/>

<RelatedLinks
  title="RELATED GUIDES"
  items={[
  { label: "Metadata template scopes", href: "/guides/metadata/scopes", badge: "GUIDE" },
  { label: "List all metadata templates", href: "/guides/metadata/templates/list", badge: "GUIDE" },
  { label: "Create a metadata template", href: "/guides/metadata/templates/create", badge: "GUIDE" }
]}
/>
