Templates
/api/v2/stacksList 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.
Related guides
Parameters
Query parameters
orgID
required
stringAn 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
stringA 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
stringA 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
curl --request GET \
"http://localhost:8086/api/v2/stacks?orgID=ORGID" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
stacks
object[]Bad request. The response body contains detail about the error.
InfluxDB OSS v2
- Returns this error if an incorrect value is passed in the
orgparameter ororgIDparameter.
code
required
stringinternal 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 typeerr
stringmessage
stringop
stringUnauthorized. The error may indicate one of the following:
- The
Authorization: Tokenheader 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
stringunauthorized.unauthorizedmessage
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
string/api/v2/stacksCreate 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
writepermission for the organization
Related guides
Request body required
application/jsondescription
stringname
stringorgID
stringurls
string[]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
createdAt
string <date-time>events
object[]description
stringeventType
stringname
stringresources
object[]apiVersion
stringassociations
object[]kind
stringlinks
objectresourceID
stringtemplateMetaName
stringsources
string[]updatedAt
string <date-time>urls
string[]id
stringorgID
stringUnauthorized. The error may indicate one of the following:
- The
Authorization: Tokenheader 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
stringunauthorized.unauthorizedmessage
stringUnprocessable 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
stringinternal 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 typeerr
stringmessage
stringop
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
string/api/v2/stacks/{stack_id}Retrieve a stack
Parameters
Path parameters
stack_id
required
stringcurl --request GET \
"http://localhost:8086/api/v2/stacks/{stack_id}" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
createdAt
string <date-time>events
object[]description
stringeventType
stringname
stringresources
object[]apiVersion
stringassociations
object[]kind
stringlinks
objectresourceID
stringtemplateMetaName
stringsources
string[]updatedAt
string <date-time>urls
string[]id
stringorgID
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
string/api/v2/stacks/{stack_id}Update a stack
Parameters
Path parameters
stack_id
required
stringRequest body required
application/jsonadditionalResources
object[]kind
required
stringresourceID
required
stringtemplateMetaName
stringdescription
stringname
stringtemplateURLs
string[]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
createdAt
string <date-time>events
object[]description
stringeventType
stringname
stringresources
object[]apiVersion
stringassociations
object[]kind
stringlinks
objectresourceID
stringtemplateMetaName
stringsources
string[]updatedAt
string <date-time>urls
string[]id
stringorgID
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
string/api/v2/stacks/{stack_id}Delete a stack and associated resources
Parameters
Path parameters
stack_id
required
stringQuery parameters
orgID
required
stringcurl --request DELETE \
"http://localhost:8086/api/v2/stacks/{stack_id}?orgID=ORGID" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
code
required
stringinternal 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 typeerr
stringmessage
stringop
string/api/v2/stacks/{stack_id}/uninstallUninstall a stack
Parameters
Path parameters
stack_id
required
stringcurl --request POST \
"http://localhost:8086/api/v2/stacks/{stack_id}/uninstall" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
createdAt
string <date-time>events
object[]description
stringeventType
stringname
stringresources
object[]apiVersion
stringassociations
object[]kind
stringlinks
objectresourceID
stringtemplateMetaName
stringsources
string[]updatedAt
string <date-time>urls
string[]id
stringorgID
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
string/api/v2/templates/applyApply 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
Some templates may contain environment references for custom metadata. To provide custom values for environment references, pass the
envRefsproperty in the request body. For more information and examples, see how to define environment references.Some templates may contain queries that use secrets. To provide custom secret values, pass the
secretsproperty in the request body. Don’t expose secret values in templates. For more information, see how to pass secrets when installing a template.
Required permissions
writepermissions for resource types in the template.
Rate limits (with InfluxDB Cloud)
- Adjustable service quotas apply. For more information, see limits and adjustable quotas.
Related guides
Request body required
application/jsonactions
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
skipKindaction skips template resources of a specifiedkind. - A
skipResourceaction skips template resources with a specifiedmetadata.nameandkind.
dryRun
booleanOnly 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
objectAn 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.namespec.endpointNamespec.associations.name
For more information about including environment references in template fields, see how to include user-definable resource names.
orgID
stringOrganization 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
stringurl
required
stringsecrets
objectAn 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.
Related guides
stackID
stringID 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.
Related guides
template
objectA 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
stringcontents
stringsources
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
stringcontents
stringsources
string[]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
diff
objectbuckets
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringchecks
object[]id
stringkind
stringnew
stringold
stringstateStatus
stringtemplateMetaName
stringdashboards
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringlabelMappings
object[]labelID
stringlabelName
stringlabelTemplateMetaName
stringresourceID
stringresourceName
stringresourceTemplateMetaName
stringresourceType
stringstatus
stringlabels
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringnotificationEndpoints
object[]id
stringkind
stringnew
stringold
stringstateStatus
stringtemplateMetaName
stringnotificationRules
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringtasks
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringtelegrafConfigs
object[]id
stringkind
stringnew
stringold
stringstateStatus
stringtemplateMetaName
stringvariables
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringerrors
object[]fields
string[]indexes
integer[]kind
stringreason
stringsources
string[]stackID
stringsummary
objectbuckets
object[]description
stringenvReferences
stringid
stringkind
stringlabelAssociations
object[]name
stringorgID
stringretentionPeriod
integertemplateMetaName
stringchecks
object[]dashboards
object[]charts
object[]description
stringenvReferences
stringid
stringkind
stringlabelAssociations
object[]name
stringorgID
stringtemplateMetaName
stringlabelMappings
object[]labelID
stringlabelName
stringlabelTemplateMetaName
stringresourceID
stringresourceName
stringresourceTemplateMetaName
stringresourceType
stringstatus
stringlabels
object[]missingEnvRefs
string[]missingSecrets
string[]notificationEndpoints
object[]notificationRules
object[]description
stringendpointID
stringendpointTemplateMetaName
stringendpointType
stringenvReferences
stringevery
stringkind
stringlabelAssociations
object[]messageTemplate
stringname
stringoffset
stringstatus
stringstatusRules
object[]tagRules
object[]templateMetaName
stringtasks
object[]cron
stringdescription
stringenvReferences
stringevery
stringid
stringkind
stringname
stringoffset
stringquery
stringstatus
stringtemplateMetaName
stringtelegrafConfigs
object[]variables
object[]arguments
stringdescription
stringenvReferences
stringid
stringkind
stringlabelAssociations
object[]name
stringorgID
stringtemplateMetaName
stringdiff
objectbuckets
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringchecks
object[]id
stringkind
stringnew
stringold
stringstateStatus
stringtemplateMetaName
stringdashboards
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringlabelMappings
object[]labelID
stringlabelName
stringlabelTemplateMetaName
stringresourceID
stringresourceName
stringresourceTemplateMetaName
stringresourceType
stringstatus
stringlabels
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringnotificationEndpoints
object[]id
stringkind
stringnew
stringold
stringstateStatus
stringtemplateMetaName
stringnotificationRules
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringtasks
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringtelegrafConfigs
object[]id
stringkind
stringnew
stringold
stringstateStatus
stringtemplateMetaName
stringvariables
object[]id
stringkind
stringnew
objectold
objectstateStatus
stringtemplateMetaName
stringerrors
object[]fields
string[]indexes
integer[]kind
stringreason
stringsources
string[]stackID
stringsummary
objectbuckets
object[]description
stringenvReferences
stringid
stringkind
stringlabelAssociations
object[]name
stringorgID
stringretentionPeriod
integertemplateMetaName
stringchecks
object[]dashboards
object[]charts
object[]description
stringenvReferences
stringid
stringkind
stringlabelAssociations
object[]name
stringorgID
stringtemplateMetaName
stringlabelMappings
object[]labelID
stringlabelName
stringlabelTemplateMetaName
stringresourceID
stringresourceName
stringresourceTemplateMetaName
stringresourceType
stringstatus
stringlabels
object[]missingEnvRefs
string[]missingSecrets
string[]notificationEndpoints
object[]notificationRules
object[]description
stringendpointID
stringendpointTemplateMetaName
stringendpointType
stringenvReferences
stringevery
stringkind
stringlabelAssociations
object[]messageTemplate
stringname
stringoffset
stringstatus
stringstatusRules
object[]tagRules
object[]templateMetaName
stringtasks
object[]cron
stringdescription
stringenvReferences
stringevery
stringid
stringkind
stringname
stringoffset
stringquery
stringstatus
stringtemplateMetaName
stringtelegrafConfigs
object[]variables
object[]arguments
stringdescription
stringenvReferences
stringid
stringkind
stringlabelAssociations
object[]name
stringorgID
stringtemplateMetaName
stringUnprocessable entity.
The error may indicate one of the following problems:
- The template failed validation.
- You passed a parameter combination that InfluxDB doesn’t support.
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
stringinternal 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 typeerr
stringmessage
stringop
stringcode
required
stringinternal 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 typeerr
stringmessage
stringop
string/api/v2/templates/exportExport a new template
Request body
application/jsoncurl --request POST \
"http://localhost:8086/api/v2/templates/export" \
--header "Authorization: Bearer INFLUX_TOKEN" \
--header "Content-Type: application/json"Responses
code
required
stringinternal 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 typeerr
stringmessage
stringop
stringWas this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.