Templates /
Create template
Required permission
Account > Templates > General > Create
Request body
- {object}Create a new template
- name string requiredName of the template.min length3max length100pattern^[a-zA-Z0-9]+((-|\s)[a-zA-Z0-9]+)*$
- description stringDescription of the template.max length200pattern^[a-zA-Z0-9.,?\s\\/'"()[\];`%^&*\-_:!]+$
- apiVersion string requiredThe version of the Northflank API to run the template against.one ofv1.2
- arguments {object}A set of arguments that can be referenced in a template using '${args.argumentName}'.
- gitops {object}
- vcsService string requiredThe VCS provider to use.one ofbitbucket, gitlab, github, self-hosted, azure
- selfHostedVcsId stringIf projectType is self-hosted, the ID of the self-hosted vcs to use.pattern^([A-Za-z0-9-]+\/[A-Za-z0-9-]+)|([0-9a-f]{24})$
- accountLogin stringBy default, if you have multiple version control accounts of the same provider linked, Northflank will pick a linked account that has access to the repository. If `accountLogin` is provided, Northflank will instead use your linked account with that login name.
- vcsLinkId stringLegacy key. Please used accountLogin instead.
- repoUrl string requiredURL of the Git repo to sync the template with.pattern^(https:\/\/)?((www(\.[a-zA-Z0-9\-]{2,})+\.)?[a-zA-Z0-9\-]{2,})(\.([a-zA-Z0-9\-]{2,}))+(\/([a-zA-Z0-9\-._]{2,}))+?$
- branch string requiredThe name of the branch to use.
- filePath string requiredThe file path to the template in the repository. If using an existing template, it should be in JSON format.pattern^\/([a-zA-Z0-9-._]+\/)*[a-zA-Z0-9-._]+$
- spec (multiple options: oneOf) requiredA node representing an action to be performed as part of the template.
- argumentOverrides {object}Argument overrides stored outside of the template. If GitOps is enabled, these will not be saved in version control.
- options {object}Options regarding how the template is run.
- autorun booleanIf true, the template will run automatically whenever a change is made to it.
- concurrencyPolicy stringDefines the concurrency behaviour of the template with respect to parallel runs.one ofallow, queue, forbid
- runOnCreation booleanIf true, the template will be ran immediately after creation.
- runOnCreationArgumentOverrides {object}Argument overrides for the initial run. Valid only if `runOnCreation` is `true`.
- {object}Create a new template with GitOps enabled (use an existing git template)
- name string requiredName of the template.min length3max length100pattern^[a-zA-Z0-9]+((-|\s)[a-zA-Z0-9]+)*$
- description stringDescription of the template.max length200pattern^[a-zA-Z0-9.,?\s\\/'"()[\];`%^&*\-_:!]+$
- arguments {object}A set of arguments that can be referenced in a template using '${args.argumentName}'.
- argumentOverrides {object}Argument overrides stored outside of the template. If GitOps is enabled, these will not be saved in version control.
- options {object}Options regarding how the template is run.
- autorun booleanIf true, the template will run automatically whenever a change is made to it.
- concurrencyPolicy stringDefines the concurrency behaviour of the template with respect to parallel runs.one ofallow, queue, forbid
- runOnCreation booleanIf true, the template will be ran immediately after creation.
- runOnCreationArgumentOverrides {object}Argument overrides for the initial run. Valid only if `runOnCreation` is `true`.
- gitops {object} requiredGitOps data for syncing this template with a file in version control.
- vcsService string requiredThe VCS provider to use.one ofbitbucket, gitlab, github, self-hosted, azure
- selfHostedVcsId stringIf projectType is self-hosted, the ID of the self-hosted vcs to use.pattern^([A-Za-z0-9-]+\/[A-Za-z0-9-]+)|([0-9a-f]{24})$
- accountLogin stringBy default, if you have multiple version control accounts of the same provider linked, Northflank will pick a linked account that has access to the repository. If `accountLogin` is provided, Northflank will instead use your linked account with that login name.
- vcsLinkId stringLegacy key. Please used accountLogin instead.
- repoUrl string requiredURL of the Git repo to sync the template with.pattern^(https:\/\/)?((www(\.[a-zA-Z0-9\-]{2,})+\.)?[a-zA-Z0-9\-]{2,})(\.([a-zA-Z0-9\-]{2,}))+(\/([a-zA-Z0-9\-._]{2,}))+?$
- branch string requiredThe name of the branch to use.
- filePath string requiredThe file path to the template in the repository. If using an existing template, it should be in JSON format.pattern^\/([a-zA-Z0-9-._]+\/)*[a-zA-Z0-9-._]+$
- project {object}
Response body
- {object}Response object.
- data {object} requiredResult data.
- template {object} requiredDetails about the newly created template.
- name string requiredName of the template.min length3max length100pattern^[a-zA-Z0-9]+((-|\s)[a-zA-Z0-9]+)*$
- description stringDescription of the template.max length200pattern^[a-zA-Z0-9.,?\s\\/'"()[\];`%^&*\-_:!]+$
- apiVersion string requiredThe version of the Northflank API to run the template against.one ofv1.2
- arguments {object}A set of arguments that can be referenced in a template using '${args.argumentName}'.
- $schema string
- spec (multiple options: oneOf) requiredA node representing an action to be performed as part of the template.
- id string requiredIdentifier for the templatemin length3max length100pattern^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$
- gitops {object}
- vcsService string requiredThe VCS provider to use.one ofbitbucket, gitlab, github, self-hosted, azure
- selfHostedVcsId stringIf projectType is self-hosted, the ID of the self-hosted vcs to use.pattern^([A-Za-z0-9-]+\/[A-Za-z0-9-]+)|([0-9a-f]{24})$
- accountLogin stringBy default, if you have multiple version control accounts of the same provider linked, Northflank will pick a linked account that has access to the repository. If `accountLogin` is provided, Northflank will instead use your linked account with that login name.
- vcsLinkId stringLegacy key. Please used accountLogin instead.
- repoUrl string requiredURL of the Git repo to sync the template with.pattern^(https:\/\/)?((www(\.[a-zA-Z0-9\-]{2,})+\.)?[a-zA-Z0-9\-]{2,})(\.([a-zA-Z0-9\-]{2,}))+(\/([a-zA-Z0-9\-._]{2,}))+?$
- branch string requiredThe name of the branch to use.
- filePath string requiredThe file path to the template in the repository. If using an existing template, it should be in JSON format.pattern^\/([a-zA-Z0-9-._]+\/)*[a-zA-Z0-9-._]+$
- templateSha string requiredThe SHA of the current commit that is being used for the template.
- concurrencyPolicy stringDefines the concurrency behaviour of the template with respect to parallel runs.one ofallow, queue, forbid
- options {object} required
- autorun boolean requiredWhether autorun is enabled
- createdAt stringtime of creation
- updatedAt stringtime of update
- templateRun {object}
- name string requiredName of the template.min length3max length100pattern^[a-zA-Z0-9]+((-|\s)[a-zA-Z0-9]+)*$
- description stringDescription of the template.max length200pattern^[a-zA-Z0-9.,?\s\\/'"()[\];`%^&*\-_:!]+$
- apiVersion string requiredThe version of the Northflank API to run the template against.one ofv1.2
- options {object}Options regarding how the template is run.
- autorun booleanIf true, the template will run automatically whenever a change is made to it.
- concurrencyPolicy stringDefines the concurrency behaviour of the template with respect to parallel runs.one ofallow, queue, forbid
- arguments {object}A set of arguments that can be referenced in a template using '${args.argumentName}'.
- gitops {object}
- vcsService string requiredThe VCS provider to use.one ofbitbucket, gitlab, github, self-hosted, azure
- selfHostedVcsId stringIf projectType is self-hosted, the ID of the self-hosted vcs to use.pattern^([A-Za-z0-9-]+\/[A-Za-z0-9-]+)|([0-9a-f]{24})$
- accountLogin stringBy default, if you have multiple version control accounts of the same provider linked, Northflank will pick a linked account that has access to the repository. If `accountLogin` is provided, Northflank will instead use your linked account with that login name.
- vcsLinkId stringLegacy key. Please used accountLogin instead.
- repoUrl string requiredURL of the Git repo to sync the template with.pattern^(https:\/\/)?((www(\.[a-zA-Z0-9\-]{2,})+\.)?[a-zA-Z0-9\-]{2,})(\.([a-zA-Z0-9\-]{2,}))+(\/([a-zA-Z0-9\-._]{2,}))+?$
- branch string requiredThe name of the branch to use.
- filePath string requiredThe file path to the template in the repository. If using an existing template, it should be in JSON format.pattern^\/([a-zA-Z0-9-._]+\/)*[a-zA-Z0-9-._]+$
- $schema string
- spec (multiple options: oneOf) requiredA node representing an action to be performed as part of the template.
- refs {object}
- id string requiredIdentifier for the template run
- templateId string requiredIdentifier for the template
- status string requiredStatus of the template runone ofpending, running, success, failure, aborted, aborting, queued, unknown, skipped
- concluded boolean requiredWhether the run has concluded (aborted, success, failed)
- createdAt string requiredTimestamp the run was created at.
- updatedAt string requiredTimestamp the run was last updated at.
POST /v1/templates
Example request
curl --header "Content-Type: application/json" \
  --header "Authorization: Bearer NORTHFLANK_API_TOKEN" \
  --request POST \
  --data '{"name":"Example Template","description":"This is a sample template.","apiVersion":"v1.2","gitops":{"vcsService":"github","accountLogin":"github-user","repoUrl":"https://github.com/northflank-examples/remix-postgres-redis-demo","branch":"main"},"spec":{"kind":"Workflow","spec":{"context":{"projectId":"example-project"},"type":"sequential"}},"options":{"autorun":false,"concurrencyPolicy":"allow","runOnCreation":true}}' \
  https://api.northflank.com/v1/templatescurl --header "Content-Type: application/json" \
  --header "Authorization: Bearer NORTHFLANK_API_TOKEN" \
  --request POST \
  --data '{"name":"Example Template","description":"This is a sample template.","options":{"autorun":false,"concurrencyPolicy":"allow","runOnCreation":true},"gitops":{"vcsService":"github","accountLogin":"github-user","repoUrl":"https://github.com/northflank-examples/remix-postgres-redis-demo","branch":"main"}}' \
  https://api.northflank.com/v1/templatesExample response
200 OK
JSON
{
  "data": {
    "template": {
      "name": "Example Template",
      "description": "This is a sample template.",
      "apiVersion": "v1.2",
      "spec": {
        "kind": "Workflow",
        "spec": {
          "context": {
            "projectId": "example-project"
          },
          "type": "sequential"
        }
      },
      "id": "example-template",
      "gitops": {
        "vcsService": "github",
        "accountLogin": "github-user",
        "repoUrl": "https://github.com/northflank-examples/remix-postgres-redis-demo",
        "branch": "main",
        "templateSha": "8c7e040ee3737ddc3a713363ae72bbe960e9fb16"
      },
      "concurrencyPolicy": "allow"
    },
    "templateRun": {
      "name": "Example Template",
      "description": "This is a sample template.",
      "apiVersion": "v1.2",
      "options": {
        "autorun": false,
        "concurrencyPolicy": "allow"
      },
      "gitops": {
        "vcsService": "github",
        "accountLogin": "github-user",
        "repoUrl": "https://github.com/northflank-examples/remix-postgres-redis-demo",
        "branch": "main"
      },
      "spec": {
        "settings": {
          "maxAttempts": 3,
          "backoff": {
            "type": "fixed",
            "delay": 60
          }
        },
        "kind": "Workflow",
        "response": {
          "status": "success",
          "retries": {
            "attempts": 1,
            "maxAttempts": 3,
            "timestamp": 1657296265
          },
          "startTime": 1657296265,
          "endTime": 1657296265
        }
      },
      "id": "3dd592f6-ce63-45ee-acf8-13dc5ec5235c",
      "templateId": "example-template",
      "status": "success",
      "concluded": true,
      "createdAt": "2021-01-01 12:00:00.000Z",
      "updatedAt": "2021-01-01 12:00:00.000Z"
    }
  }
}