custom_templates

Create a custom template

Changed on

Create a custom template. Access policy: authenticated

post/custom_templates/create/file

Request

  • Base URL
    /api (relative, and the document was published on a file host, not at the API’s origin)
  • URL
    /api/custom_templates/create/file
  • Auth
    • API key in header X-API-KEY
    • or API key in header Authorization

Request body multipart/form-data

Titlestring required

Title of the template

Descriptionstring required

Description of the template

Notestring required

A note that will be displayed in the UI. Supports HTML content

Platform1 | 2 required

Platform associated to the template (1 - 'linux', 2 - 'windows')

Type1 | 2 | 3 required

Type of created stack (1 - swarm, 2 - compose, 3 - kubernetes)

Filestring binary required

File

Logostring

URL of the template's logo

Variablesstring

A json array of variables definitions

Response

OK

CreatedByUserIdinteger

User identifier who created this template

Descriptionstring

Description of the template

EdgeTemplateboolean

EdgeTemplate indicates if this template purpose for Edge Stack

EntryPointstring

Path to the Stack file

Idinteger

CustomTemplate Identifier

IsComposeFormatboolean

IsComposeFormat indicates if the Kubernetes template is created from a Docker Compose file

Logostring

URL of the template's logo

Notestring

A note that will be displayed in the UI. Supports HTML content

Platform0 | 1 | 2
ProjectPathstring

Path on disk to the repository hosting the Stack file

Titlestring

Title of the template

Type0 | 1 | 2 | 3

Example response

{
  "CreatedByUserId": 3,
  "Description": "High performance web server",
  "EntryPoint": "docker-compose.yml",
  "GitConfig": {
    "ConfigFilePath": "docker-compose.yml",
    "ConfigHash": "bc4c183d756879ea4d173315338110b31004b8e0",
    "ReferenceName": "refs/heads/branch_name",
    "URL": "https://github.com/portainer/portainer.git"
  },
  "Id": 1,
  "Logo": "https://portainer.io/img/logo.svg",
  "Note": "This is my <b>custom</b> template",
  "ProjectPath": "/data/custom_template/3",
  "ResourceControl": {
    "AdministratorsOnly": true,
    "Id": 1,
    "Public": true,
    "ResourceId": "617c5f22bb9b023d6daab7cba43a57576f83492867bc767d1c59416b065e5f08",
    "SubResourceIds": [
      "617c5f22bb9b023d6daab7cba43a57576f83492867bc767d1c59416b065e5f08"
    ]
  },
  "Title": "Nginx",
  "Variables": [
    {
      "defaultValue": "default value",
      "description": "Description",
      "label": "My Variable",
      "name": "MY_VAR"
    }
  ],
  "artifact": {
    "files": [
      {
        "hash": "abc123",
        "path": "portainer.yaml",
        "ref": "refs/heads/main"
      }
    ]
  }
}

Changes

    • info

      added the optional property ////// to the response with the status