Creating and using API and Product definitions templates

You can use template files when creating OpenAPI 2.0 and OpenAPI 3.0 APIs, and when creating Product definitions. Template files are Handlebars templates containing variables of the form {{variable-name}} that are substituted with values when you create the API or Product definition.

Before you begin

To complete the steps that are described in this topic, you must have installed the IBM® API Connect developer toolkit. For more information, see Installing the toolkit.


  1. Create a Product or API definition template, either from scratch, or by copying one of the examples provided in API and Product definition template examples. The template file must have .hbs filename extension, and may contain any of the handlebars variables described in Template variables for API and Product definitions.
  2. To create a Product or API definition from a template, enter the following command:
    apic create:[api | product] --template template_file --title [api_title | product_title] options

    where template_file is the template .hbs file to use, api_title or product_title is the title of the API or Product to create, and options is any additional command-line options. The path to the template file can be either an absolute path or relative to the location where the command is executed.

    When the Product or API definition is created, the value of each command-line option is substituted for the corresponding handlebars template variable. For example, the value of the required --title option is substituted for the info.title field in the template file. The command creates an API or Product definition YAML file with the name specified in the --name option. If you don't supply the --name option, the command derives the name of the API or Product YAML file from the specified title by down-casing the title and replacing spaces with dashes.