Invokable Scripts
/api/v2/scriptsList scripts
Parameters
Query parameters
offset
integerThe offset for pagination. The number of records to skip.
For more information about pagination parameters, see Pagination.
limit
integer100.100name
stringcurl --request GET \
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/scripts" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
scripts
object[]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/scriptsCreate a script
Creates an invokable script and returns the script.
Related guides
Request body required
application/jsondescription
required
stringlanguage
required
stringname
required
stringscript
required
stringcurl --request POST \
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/scripts" \
--header "Authorization: Bearer INFLUX_TOKEN" \
--header "Content-Type: application/json" \
--data-raw '{
"description": "DESCRIPTION",
"language": "flux",
"name": "NAME",
"script": "SCRIPT"
}'Responses
createdAt
string <date-time>description
stringid
stringlanguage
stringname
required
stringorgID
required
stringscript
required
stringupdatedAt
string <date-time>url
stringBad 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
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/scripts/{scriptID}Retrieve a script
Parameters
Path parameters
scriptID
required
stringcurl --request GET \
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/scripts/{scriptID}" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
createdAt
string <date-time>description
stringid
stringlanguage
stringname
required
stringorgID
required
stringscript
required
stringupdatedAt
string <date-time>url
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
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/scripts/{scriptID}Update a script
Updates an invokable script.
Use this endpoint to modify values for script properties (description and script).
To update a script, pass an object that contains the updated key-value pairs.
Limitations
- If you send an empty request body, the script will neither update nor
store an empty script, but InfluxDB will respond with an HTTP
200status code.
Related Guides
Parameters
Path parameters
scriptID
required
stringRequest body required
application/jsondescription
stringscript
stringcurl --request PATCH \
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/scripts/{scriptID}" \
--header "Authorization: Bearer INFLUX_TOKEN" \
--header "Content-Type: application/json" \
--data-raw '{
"description": "DESCRIPTION",
"script": "SCRIPT"
}'Responses
createdAt
string <date-time>description
stringid
stringlanguage
stringname
required
stringorgID
required
stringscript
required
stringupdatedAt
string <date-time>url
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
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/scripts/{scriptID}Delete a script
Deletes a script and all associated records.
Limitations
- You can delete only one script per request.
- If the script ID you provide doesn’t exist for the organization, InfluxDB
responds with an HTTP
204status code.
Related Guides
Parameters
Path parameters
scriptID
required
stringcurl --request DELETE \
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/scripts/{scriptID}" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
Unauthorized. 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/scripts/{scriptID}/invokeInvoke a script
Runs a script and returns the result.
When the script runs, InfluxDB replaces params keys referenced in the script with
params key-values passed in the request body–for example:
The following sample script contains a mybucket parameter :
"script": "from(bucket: params.mybucket)
|> range(start: -7d)
|> limit(n:1)"The following example POST /api/v2/scripts/SCRIPT_ID/invoke request body
passes a value for the mybucket parameter:
{
"params": {
"mybucket": "air_sensor"
}
}Related guides
Parameters
Path parameters
scriptID
required
stringRequest body
application/jsonparams
objectparams contains key-value pairs that map values to the params.keys
in a script.
When you invoke a script with params, InfluxDB passes the values as
invocation parameters to the script.curl --request POST \
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/scripts/{scriptID}/invoke" \
--header "Authorization: Bearer INFLUX_TOKEN" \
--header "Content-Type: application/json" \
--data-raw '{
"params": {}
}'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
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
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/scripts/{scriptID}/paramsFind script parameters.
Analyzes a script and determines required parameters.
Find all params keys referenced in a script and return a list
of keys. If it is possible to determine the type of the value
from the context then the type is also returned – for example:
The following sample script contains a mybucket parameter :
"script": "from(bucket: params.mybucket)
|> range(start: -7d)
|> limit(n:1)"Requesting the parameters using GET /api/v2/scripts/SCRIPT_ID/params
returns the following:
{
"params": {
"mybucket": "string"
}
}The type name returned for a parameter will be one of:
anybooldurationfloatintstringtimeuint
The type name any is used when the type of a parameter cannot
be determined from the context, or the type is determined to
be a structured type such as an array or record.
Related guides
Parameters
Path parameters
scriptID
required
stringcurl --request GET \
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/scripts/{scriptID}/params" \
--header "Authorization: Bearer INFLUX_TOKEN"Responses
params
objectparams keys and value type defined in the script.Unauthorized. 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
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
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.