Templates

Download InfluxDB API Spec
Export and apply InfluxDB templates, and manage template stacks for InfluxDB OSS v2.
GET /api/v2/stacks

List installed stacks

Lists installed InfluxDB stacks.

To limit stacks in the response, pass query parameters in your request. If no query parameters are passed, InfluxDB returns all installed stacks for the organization.

Parameters

Query parameters
orgID required string

An organization ID. Only returns stacks owned by the specified organization.

InfluxDB Cloud

  • Doesn’t require this parameter; InfluxDB only returns resources allowed by the API token.
name string

A stack name. Finds stack events with this name and returns the stacks.

Repeatable. To filter for more than one stack name, repeat this parameter with each name–for example:

  • INFLUX_URL/api/v2/stacks?&orgID=INFLUX_ORG_ID&name=project-stack-0&name=project-stack-1
stackID string

A stack ID. Only returns the specified stack.

Repeatable. To filter for more than one stack ID, repeat this parameter with each ID–for example:

  • INFLUX_URL/api/v2/stacks?&orgID=INFLUX_ORG_ID&stackID=09bd87cd33be3000&stackID=09bef35081fe3000
Example request Ask AI about this
curl --request GET \
  "http://localhost:8086/api/v2/stacks?orgID=ORGID" \
  --header "Authorization: Bearer INFLUX_TOKEN"

Responses

200 Success. The response body contains the list of stacks.
stacks object[]
400

Bad request. The response body contains detail about the error.

InfluxDB OSS v2

  • Returns this error if an incorrect value is passed in the org parameter or orgID parameter.
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
401

Unauthorized. The error may indicate one of the following:

  • The Authorization: Token header is missing or malformed.
  • The API token value is missing from the header.
  • The token doesn’t have sufficient permissions to write to this organization and bucket.
code string
The HTTP status code description. Default is unauthorized.
Allowed: unauthorized
message string
A human-readable message that may contain detail about the error.
500 Internal server error. The server encountered an unexpected situation.
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
POST /api/v2/stacks

Create a stack

Creates or initializes a stack.

Use this endpoint to manually initialize a new stack with the following optional information:

  • Stack name
  • Stack description
  • URLs for template manifest files

To automatically create a stack when applying templates, use the /api/v2/templates/apply endpoint.

Required permissions

  • write permission for the organization

Request body required

The stack to create.
Content-Type: application/json
description string
name string
orgID string
urls string[]
Example request Ask AI about this
curl --request POST \
  "http://localhost:8086/api/v2/stacks" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "description": "DESCRIPTION",
  "name": "NAME",
  "orgID": "ORGID",
  "urls": [
    "example"
  ]
}'

Responses

201 Success. Returns the newly created stack.
createdAt string <date-time>
events object[]
description string
eventType string
name string
resources object[]
apiVersion string
associations object[]
kind string
links object
resourceID string
templateMetaName string
sources string[]
updatedAt string <date-time>
urls string[]
id string
orgID string
401

Unauthorized. The error may indicate one of the following:

  • The Authorization: Token header is missing or malformed.
  • The API token value is missing from the header.
  • The token doesn’t have sufficient permissions to write to this organization and bucket.
code string
The HTTP status code description. Default is unauthorized.
Allowed: unauthorized
message string
A human-readable message that may contain detail about the error.
422

Unprocessable entity.

The error may indicate one of the following problems:

  • The request body isn’t valid–the request is well-formed, but InfluxDB can’t process it due to semantic errors.
  • You passed a parameter combination that InfluxDB doesn’t support.
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
500 Internal server error. The server encountered an unexpected situation.
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
GET /api/v2/stacks/{stack_id}

Retrieve a stack

Parameters

Path parameters
stack_id required string
The identifier of the stack.
Example request Ask AI about this
curl --request GET \
  "http://localhost:8086/api/v2/stacks/{stack_id}" \
  --header "Authorization: Bearer INFLUX_TOKEN"

Responses

200 Returns the stack.
createdAt string <date-time>
events object[]
description string
eventType string
name string
resources object[]
apiVersion string
associations object[]
kind string
links object
resourceID string
templateMetaName string
sources string[]
updatedAt string <date-time>
urls string[]
id string
orgID string
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
PATCH /api/v2/stacks/{stack_id}

Update a stack

Parameters

Path parameters
stack_id required string
The identifier of the stack.

Request body required

The stack to update.
Content-Type: application/json
additionalResources object[]
kind required string
resourceID required string
templateMetaName string
description string
name string
templateURLs string[]
Example request Ask AI about this
curl --request PATCH \
  "http://localhost:8086/api/v2/stacks/{stack_id}" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "additionalResources": [],
  "description": "DESCRIPTION",
  "name": "NAME",
  "templateURLs": [
    "example"
  ]
}'

Responses

200 Returns the updated stack.
createdAt string <date-time>
events object[]
description string
eventType string
name string
resources object[]
apiVersion string
associations object[]
kind string
links object
resourceID string
templateMetaName string
sources string[]
updatedAt string <date-time>
urls string[]
id string
orgID string
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
DELETE /api/v2/stacks/{stack_id}

Delete a stack and associated resources

Parameters

Path parameters
stack_id required string
The identifier of the stack.
Query parameters
orgID required string
The identifier of the organization.
Example request Ask AI about this
curl --request DELETE \
  "http://localhost:8086/api/v2/stacks/{stack_id}?orgID=ORGID" \
  --header "Authorization: Bearer INFLUX_TOKEN"

Responses

204 The stack and its associated resources were deleted.
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
POST /api/v2/stacks/{stack_id}/uninstall

Uninstall a stack

Parameters

Path parameters
stack_id required string
The identifier of the stack.
Example request Ask AI about this
curl --request POST \
  "http://localhost:8086/api/v2/stacks/{stack_id}/uninstall" \
  --header "Authorization: Bearer INFLUX_TOKEN"

Responses

200 Returns the uninstalled stack.
createdAt string <date-time>
events object[]
description string
eventType string
name string
resources object[]
apiVersion string
associations object[]
kind string
links object
resourceID string
templateMetaName string
sources string[]
updatedAt string <date-time>
urls string[]
id string
orgID string
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
POST /api/v2/templates/apply

Apply or dry-run a template

Applies a template to create or update a stack of InfluxDB resources. The response contains the diff of changes and the stack ID.

Use this endpoint to install an InfluxDB template to an organization. Provide template URLs or template objects in your request. To customize which template resources are installed, use the actions parameter.

By default, when you apply a template, InfluxDB installs the template to create and update stack resources and then generates a diff of the changes. If you pass dryRun: true in the request body, InfluxDB validates the template and generates the resource diff, but doesn’t make any changes to your instance.

Custom values for templates

Required permissions

  • write permissions for resource types in the template.

Rate limits (with InfluxDB Cloud)

Request body required

Parameters for applying templates.
Content-Type: application/json
actions object[]

A list of action objects. Actions let you customize how InfluxDB applies templates in the request.

You can use the following actions to prevent creating or updating resources:

  • A skipKind action skips template resources of a specified kind.
  • A skipResource action skips template resources with a specified metadata.name and kind.
dryRun boolean

Only applies a dry run of the templates passed in the request.

  • Validates the template and generates a resource diff and summary.
  • Doesn’t install templates or make changes to the InfluxDB instance.
envRefs object

An object with key-value pairs that map to environment references in templates.

Environment references in templates are envRef objects with an envRef.key property. To substitute a custom environment reference value when applying templates, pass envRefs with the envRef.key and the value.

When you apply a template, InfluxDB replaces envRef objects in the template with the values that you provide in the envRefs parameter. For more examples, see how to define environment references.

The following template fields may use environment references:

  • metadata.name
  • spec.endpointName
  • spec.associations.name

For more information about including environment references in template fields, see how to include user-definable resource names.

orgID string

Organization ID. InfluxDB applies templates to this organization. The organization owns all resources created by the template.

To find your organization, see how to view organizations.

remotes object[]

A list of URLs for template files.

To apply a template manifest file located at a URL, pass remotes with an array that contains the URL.

contentType string
url required string
secrets object

An object with key-value pairs that map to secrets in queries.

Queries may reference secrets stored in InfluxDB–for example, the following Flux script retrieves POSTGRES_USERNAME and POSTGRES_PASSWORD secrets and then uses them to connect to a PostgreSQL database:

import "sql"
import "influxdata/influxdb/secrets"

username = secrets.get(key: "POSTGRES_USERNAME")
password = secrets.get(key: "POSTGRES_PASSWORD")

sql.from(
  driverName: "postgres",
  dataSourceName: "postgresql://${username}:${password}@localhost:5432",
  query: "SELECT * FROM example_table",
)

To define secret values in your /api/v2/templates/apply request, pass the secrets parameter with key-value pairs–for example:

{
  ...
  "secrets": {
    "POSTGRES_USERNAME": "pguser",
    "POSTGRES_PASSWORD": "foo"
  }
  ...
}

InfluxDB stores the key-value pairs as secrets that you can access with secrets.get(). Once stored, you can’t view secret values in InfluxDB.

stackID string

ID of the stack to update.

To apply templates to an existing stack in the organization, use the stackID parameter. If you apply templates without providing a stack ID, InfluxDB initializes a new stack with all new resources.

To find a stack ID, use the InfluxDB /api/v2/stacks API endpoint to list stacks.

template object

A template object to apply. A template object has a contents property with an array of InfluxDB resource configurations.

Pass template to apply only one template object. If you use template, you can’t use the templates parameter. If you want to apply multiple template objects, use templates instead.

contentType string
contents string
sources string[]
templates object[]

A list of template objects to apply. A template object has a contents property with an array of InfluxDB resource configurations.

Use the templates parameter to apply multiple template objects. If you use templates, you can’t use the template parameter.

contentType string
contents string
sources string[]
Example request Ask AI about this
curl --request POST \
  "http://localhost:8086/api/v2/templates/apply" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "actions": [],
  "dryRun": false,
  "envRefs": {},
  "orgID": "ORGID",
  "remotes": [],
  "secrets": {},
  "stackID": "STACKID",
  "template": {},
  "templates": []
}'

Responses

200 Success. The template dry run succeeded. The response body contains a resource diff of changes that the template would have made if installed. No resources were created or updated. The diff and summary won’t contain IDs for resources that didn’t exist at the time of the dry run.
diff object
buckets object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
checks object[]
id string
kind string
new string
old string
stateStatus string
templateMetaName string
dashboards object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
labelMappings object[]
labelID string
labelName string
labelTemplateMetaName string
resourceID string
resourceName string
resourceTemplateMetaName string
resourceType string
status string
labels object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
notificationEndpoints object[]
id string
kind string
new string
old string
stateStatus string
templateMetaName string
notificationRules object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
tasks object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
telegrafConfigs object[]
id string
kind string
new string
old string
stateStatus string
templateMetaName string
variables object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
errors object[]
fields string[]
indexes integer[]
kind string
reason string
sources string[]
stackID string
summary object
buckets object[]
description string
envReferences string
id string
kind string
labelAssociations object[]
name string
orgID string
retentionPeriod integer
templateMetaName string
checks object[]
dashboards object[]
charts object[]
description string
envReferences string
id string
kind string
labelAssociations object[]
name string
orgID string
templateMetaName string
labelMappings object[]
labelID string
labelName string
labelTemplateMetaName string
resourceID string
resourceName string
resourceTemplateMetaName string
resourceType string
status string
labels object[]
missingEnvRefs string[]
missingSecrets string[]
notificationEndpoints object[]
notificationRules object[]
description string
endpointID string
endpointTemplateMetaName string
endpointType string
envReferences string
every string
kind string
labelAssociations object[]
messageTemplate string
name string
offset string
status string
statusRules object[]
tagRules object[]
templateMetaName string
tasks object[]
cron string
description string
envReferences string
every string
id string
kind string
name string
offset string
query string
status string
templateMetaName string
telegrafConfigs object[]
variables object[]
arguments string
description string
envReferences string
id string
kind string
labelAssociations object[]
name string
orgID string
templateMetaName string
201 Success. The template applied successfully. The response body contains the stack ID, a diff, and a summary. The diff compares the initial state to the state after the template installation. The summary contains newly created resources.
diff object
buckets object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
checks object[]
id string
kind string
new string
old string
stateStatus string
templateMetaName string
dashboards object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
labelMappings object[]
labelID string
labelName string
labelTemplateMetaName string
resourceID string
resourceName string
resourceTemplateMetaName string
resourceType string
status string
labels object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
notificationEndpoints object[]
id string
kind string
new string
old string
stateStatus string
templateMetaName string
notificationRules object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
tasks object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
telegrafConfigs object[]
id string
kind string
new string
old string
stateStatus string
templateMetaName string
variables object[]
id string
kind string
new object
old object
stateStatus string
templateMetaName string
errors object[]
fields string[]
indexes integer[]
kind string
reason string
sources string[]
stackID string
summary object
buckets object[]
description string
envReferences string
id string
kind string
labelAssociations object[]
name string
orgID string
retentionPeriod integer
templateMetaName string
checks object[]
dashboards object[]
charts object[]
description string
envReferences string
id string
kind string
labelAssociations object[]
name string
orgID string
templateMetaName string
labelMappings object[]
labelID string
labelName string
labelTemplateMetaName string
resourceID string
resourceName string
resourceTemplateMetaName string
resourceType string
status string
labels object[]
missingEnvRefs string[]
missingSecrets string[]
notificationEndpoints object[]
notificationRules object[]
description string
endpointID string
endpointTemplateMetaName string
endpointType string
envReferences string
every string
kind string
labelAssociations object[]
messageTemplate string
name string
offset string
status string
statusRules object[]
tagRules object[]
templateMetaName string
tasks object[]
cron string
description string
envReferences string
every string
id string
kind string
name string
offset string
query string
status string
templateMetaName string
telegrafConfigs object[]
variables object[]
arguments string
description string
envReferences string
id string
kind string
labelAssociations object[]
name string
orgID string
templateMetaName string
422

Unprocessable entity.

The error may indicate one of the following problems:

  • The template failed validation.
  • You passed a parameter combination that InfluxDB doesn’t support.
500

Internal server error.

InfluxDB Cloud

  • Returns this error if creating one of the template resources (bucket, dashboard, task, user) exceeds your plan’s adjustable service quotas.
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.
POST /api/v2/templates/export

Export a new template

Request body

Export resources as an InfluxDB template.
Content-Type: application/json
Example request Ask AI about this
curl --request POST \
  "http://localhost:8086/api/v2/templates/export" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json"

Responses

200 The template was created successfully. Returns the newly created template.
default Unexpected error
code required string
code is the machine-readable error code.
Allowed: internal error , not implemented , not found , conflict , invalid , unprocessable entity , empty value , unavailable , forbidden , too many requests , unauthorized , method not allowed , request too large , unsupported media type
err string
Stack of errors that occurred during processing of the request. Useful for debugging.
message string
Human-readable message.
op string
Describes the logical code operation when the error occurred. Useful for debugging.

Was this page helpful?

Thank you for your feedback!