Use this API to retrieve project-specific templates, in addition to the templates common to the entire instance:

These endpoints supersede the instance template endpoints, which are scheduled for removal in API version 5. File templates for groups are also supported.

List all templates of a particular type

GET /api/v4/projects/{id}/templates/{type}

Lists all templates of a specified type for a project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
type
Path, required
StringThe type (dockerfiles|gitignores|gitlab_ci_ymls|licenses|issues|merge_requests) of the template
Allowed values: dockerfiles, gitignores, gitlab_ci_ymls, licenses, issues, merge_requests
Minimum length: 1
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesTemplatesList
400Bad Request—
401Unauthorized—
404Not found—

Retrieve a template of a particular type

GET /api/v4/projects/{id}/templates/{type}/{name}

Retrieves a template of a specified type for a project.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
type
Path, required
StringThe type (dockerfiles|gitignores|gitlab_ci_ymls|licenses|issues|merge_requests) of the template
Allowed values: dockerfiles, gitignores, gitlab_ci_ymls, licenses, issues, merge_requests
Minimum length: 1
name
Path, required
StringThe key of the template, as obtained from the collection endpoint
Example: MIT
source_template_project_id
Query
IntegerThe project id where a given template is being stored. This is useful when multiple templates from different projects have the same name
Example: 1
project
Query
StringThe project name to use when expanding placeholders in the template. Only affects licenses
Example: GitLab
fullname
Query
StringThe full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses
Example: GitLab B.V.

Responses

CodeDescriptionSchema
200OKAPIEntitiesLicense
400Bad Request—
401Unauthorized—
404Not found—

Schemas

Objects returned by the operations above and objects nested in their request bodies.

APIEntitiesLicense

PropertyTypeDescription
conditionsArray of stringsExample: ["include-copyright"]
contentStringExample: GNU GENERAL PUBLIC LICENSE
descriptionStringExample: A simple license
html_urlStringExample: http://choosealicense.com/licenses/gpl-3.0
keyStringExample: gpl-3.0
limitationsArray of stringsExample: ["liability"]
nameStringExample: GNU General Public License v3.0
nicknameStringExample: GNU GPLv3
permissionsArray of stringsExample: ["commercial-use"]
popularBoolean—
source_urlString—

APIEntitiesTemplatesList

PropertyTypeDescription
keyStringExample: mit
nameStringExample: MIT License