The Functions service allows you to create custom behaviour that can be triggered by any supported Appwrite system events or by a predefined schedule.
Appwrite Cloud Functions lets you automatically run backend code in response to events triggered by Appwrite or by setting it to be executed in a predefined schedule. Your code is stored in a secure way on your Appwrite instance and is executed in an isolated environment.
You can learn more by following our Cloud Functions tutorial.
https://cloud.appwrite.io/v1
List functions
Get a list of all the project's functions. You can use the query params to filter your results.
Request
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /functions
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.List(
functions.WithListQueries([]interface{}{}),
functions.WithListSearch("<SEARCH>"),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Create function
Create a new function. You can pass a list of permissions to allow different project users or team with access to execute the function using the client API.
Request
functionId requiredFunction ID. Choose a custom ID or generate a random ID with
ID.unique()
. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.name requiredFunction name. Max length: 128 chars.
runtime requiredExecution runtime.
execute An array of role strings with execution permissions. By default no user is granted with any execute permissions. learn more about roles. Maximum of 100 roles are allowed, each 64 characters long.
events Events list. Maximum of 100 events are allowed.
schedule Schedule CRON syntax.
timeout Function maximum execution time in seconds.
enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.
logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.
entrypoint Entrypoint File. This path is relative to the "providerRootDirectory".
commands Build Commands.
scopes List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed.
installationId Appwrite Installation ID for VCS (Version Control System) deployment.
providerRepositoryId Repository ID of the repo linked to the function.
providerBranch Production branch for the repo linked to the function.
providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
providerRootDirectory Path to function code in the linked repo.
templateRepository Repository name of the template.
templateOwner The name of the owner of the template.
templateRootDirectory Path to function code in the template repo.
templateVersion Version (tag) for the repo linked to the function template.
specification Runtime specification for the function and builds.
Response
201
POST /functions
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.Create(
"<FUNCTION_ID>",
"<NAME>",
"node-14.5",
functions.WithCreateExecute(interface{}{"any"}),
functions.WithCreateEvents([]interface{}{}),
functions.WithCreateSchedule(""),
functions.WithCreateTimeout(1),
functions.WithCreateEnabled(false),
functions.WithCreateLogging(false),
functions.WithCreateEntrypoint("<ENTRYPOINT>"),
functions.WithCreateCommands("<COMMANDS>"),
functions.WithCreateScopes([]interface{}{}),
functions.WithCreateInstallationId("<INSTALLATION_ID>"),
functions.WithCreateProviderRepositoryId("<PROVIDER_REPOSITORY_ID>"),
functions.WithCreateProviderBranch("<PROVIDER_BRANCH>"),
functions.WithCreateProviderSilentMode(false),
functions.WithCreateProviderRootDirectory("<PROVIDER_ROOT_DIRECTORY>"),
functions.WithCreateTemplateRepository("<TEMPLATE_REPOSITORY>"),
functions.WithCreateTemplateOwner("<TEMPLATE_OWNER>"),
functions.WithCreateTemplateRootDirectory("<TEMPLATE_ROOT_DIRECTORY>"),
functions.WithCreateTemplateVersion("<TEMPLATE_VERSION>"),
functions.WithCreateSpecification(""),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
GET /functions/runtimes
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.ListRuntimes(
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
List available function runtime specifications
List allowed function specifications for this instance.
Response
GET /functions/specifications
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.ListSpecifications(
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
GET /functions/{functionId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.Get(
"<FUNCTION_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Update function
Update function by its unique ID.
Request
functionId requiredFunction ID.
name requiredFunction name. Max length: 128 chars.
runtime Execution runtime.
execute An array of role strings with execution permissions. By default no user is granted with any execute permissions. learn more about roles. Maximum of 100 roles are allowed, each 64 characters long.
events Events list. Maximum of 100 events are allowed.
schedule Schedule CRON syntax.
timeout Maximum execution time in seconds.
enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.
logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.
entrypoint Entrypoint File. This path is relative to the "providerRootDirectory".
commands Build Commands.
scopes List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed.
installationId Appwrite Installation ID for VCS (Version Controle System) deployment.
providerRepositoryId Repository ID of the repo linked to the function
providerBranch Production branch for the repo linked to the function
providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
providerRootDirectory Path to function code in the linked repo.
specification Runtime specification for the function and builds.
Response
200
PUT /functions/{functionId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.Update(
"<FUNCTION_ID>",
"<NAME>",
functions.WithUpdateRuntime("node-14.5"),
functions.WithUpdateExecute(interface{}{"any"}),
functions.WithUpdateEvents([]interface{}{}),
functions.WithUpdateSchedule(""),
functions.WithUpdateTimeout(1),
functions.WithUpdateEnabled(false),
functions.WithUpdateLogging(false),
functions.WithUpdateEntrypoint("<ENTRYPOINT>"),
functions.WithUpdateCommands("<COMMANDS>"),
functions.WithUpdateScopes([]interface{}{}),
functions.WithUpdateInstallationId("<INSTALLATION_ID>"),
functions.WithUpdateProviderRepositoryId("<PROVIDER_REPOSITORY_ID>"),
functions.WithUpdateProviderBranch("<PROVIDER_BRANCH>"),
functions.WithUpdateProviderSilentMode(false),
functions.WithUpdateProviderRootDirectory("<PROVIDER_ROOT_DIRECTORY>"),
functions.WithUpdateSpecification(""),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Delete function
Delete a function by its unique ID.
Request
functionId requiredFunction ID.
Response
204
DELETE /functions/{functionId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.Delete(
"<FUNCTION_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
List deployments
Get a list of all the project's code deployments. You can use the query params to filter your results.
Request
functionId requiredFunction ID.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: size, buildId, activate, entrypoint, commands, type, size
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /functions/{functionId}/deployments
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.ListDeployments(
"<FUNCTION_ID>",
functions.WithListDeploymentsQueries([]interface{}{}),
functions.WithListDeploymentsSearch("<SEARCH>"),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Create deployment
Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID.
This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the Appwrite Cloud Functions tutorial.
Use the "command" param to set the entrypoint used to execute your code.
Request
functionId requiredFunction ID.
code requiredGzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.
activate requiredAutomatically activate the deployment when it is finished building.
entrypoint Entrypoint File.
commands Build Commands.
Response
202
POST /functions/{functionId}/deployments
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.CreateDeployment(
"<FUNCTION_ID>",
file.NewInputFile("/path/to/file.png", "file.png"),
false,
functions.WithCreateDeploymentEntrypoint("<ENTRYPOINT>"),
functions.WithCreateDeploymentCommands("<COMMANDS>"),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Get deployment
Get a code deployment by its unique ID.
Request
functionId requiredFunction ID.
deploymentId requiredDeployment ID.
Response
200
GET /functions/{functionId}/deployments/{deploymentId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.GetDeployment(
"<FUNCTION_ID>",
"<DEPLOYMENT_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Update deployment
Update the function code deployment ID using the unique function ID. Use this endpoint to switch the code deployment that should be executed by the execution endpoint.
Request
functionId requiredFunction ID.
deploymentId requiredDeployment ID.
Response
200
PATCH /functions/{functionId}/deployments/{deploymentId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.UpdateDeployment(
"<FUNCTION_ID>",
"<DEPLOYMENT_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Delete deployment
Delete a code deployment by its unique ID.
Request
functionId requiredFunction ID.
deploymentId requiredDeployment ID.
Response
204
DELETE /functions/{functionId}/deployments/{deploymentId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.DeleteDeployment(
"<FUNCTION_ID>",
"<DEPLOYMENT_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Rebuild deployment
Request
functionId requiredFunction ID.
deploymentId requiredDeployment ID.
buildId Build unique ID.
Response
204
POST /functions/{functionId}/deployments/{deploymentId}/build
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.CreateBuild(
"<FUNCTION_ID>",
"<DEPLOYMENT_ID>",
functions.WithCreateBuildBuildId("<BUILD_ID>"),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Cancel deployment
Request
functionId requiredFunction ID.
deploymentId requiredDeployment ID.
Response
200
PATCH /functions/{functionId}/deployments/{deploymentId}/build
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.UpdateDeploymentBuild(
"<FUNCTION_ID>",
"<DEPLOYMENT_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Download deployment
Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download.
Request
functionId requiredFunction ID.
deploymentId requiredDeployment ID.
Response
200
GET /functions/{functionId}/deployments/{deploymentId}/download
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.GetDeploymentDownload(
"<FUNCTION_ID>",
"<DEPLOYMENT_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
List executions
Get a list of all the current user function execution logs. You can use the query params to filter your results.
Request
functionId requiredFunction ID.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /functions/{functionId}/executions
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetSession("") // The user session to authenticate with
service := functions.NewFunctions(client)
response, error := service.ListExecutions(
"<FUNCTION_ID>",
functions.WithListExecutionsQueries([]interface{}{}),
functions.WithListExecutionsSearch("<SEARCH>"),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Create execution
Trigger a function execution. The returned object will return you the current execution status. You can ping the Get Execution
endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.
Request
functionId requiredFunction ID.
body HTTP body of execution. Default value is empty string.
async Execute code in the background. Default value is false.
path HTTP path of execution. Path can include query params. Default value is /
method HTTP method of execution. Default value is GET.
headers HTTP headers of execution. Defaults to empty.
scheduledAt Scheduled execution time in ISO 8601 format. DateTime value must be in future with precision in minutes.
Response
201
POST /functions/{functionId}/executions
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetSession("") // The user session to authenticate with
service := functions.NewFunctions(client)
response, error := service.CreateExecution(
"<FUNCTION_ID>",
functions.WithCreateExecutionBody("<BODY>"),
functions.WithCreateExecutionAsync(false),
functions.WithCreateExecutionPath("<PATH>"),
functions.WithCreateExecutionMethod("GET"),
functions.WithCreateExecutionHeaders(map[string]interface{}{}),
functions.WithCreateExecutionScheduledAt(""),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Get execution
Get a function execution log by its unique ID.
Request
functionId requiredFunction ID.
executionId requiredExecution ID.
Response
200
GET /functions/{functionId}/executions/{executionId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetSession("") // The user session to authenticate with
service := functions.NewFunctions(client)
response, error := service.GetExecution(
"<FUNCTION_ID>",
"<EXECUTION_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Delete execution
Delete a function execution by its unique ID.
Request
functionId requiredFunction ID.
executionId requiredExecution ID.
Response
204
DELETE /functions/{functionId}/executions/{executionId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.DeleteExecution(
"<FUNCTION_ID>",
"<EXECUTION_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
List variables
Get a list of all variables of a specific function.
Request
functionId requiredFunction unique ID.
Response
200
GET /functions/{functionId}/variables
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.ListVariables(
"<FUNCTION_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Create variable
Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables.
Request
functionId requiredFunction unique ID.
key requiredVariable key. Max length: 255 chars.
value requiredVariable value. Max length: 8192 chars.
Response
201
POST /functions/{functionId}/variables
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.CreateVariable(
"<FUNCTION_ID>",
"<KEY>",
"<VALUE>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Get variable
Get a variable by its unique ID.
Request
functionId requiredFunction unique ID.
variableId requiredVariable unique ID.
Response
200
GET /functions/{functionId}/variables/{variableId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.GetVariable(
"<FUNCTION_ID>",
"<VARIABLE_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Update variable
Update variable by its unique ID.
Request
functionId requiredFunction unique ID.
variableId requiredVariable unique ID.
key requiredVariable key. Max length: 255 chars.
value Variable value. Max length: 8192 chars.
Response
200
PUT /functions/{functionId}/variables/{variableId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.UpdateVariable(
"<FUNCTION_ID>",
"<VARIABLE_ID>",
"<KEY>",
functions.WithUpdateVariableValue("<VALUE>"),
)
if error != nil {
panic(error)
}
fmt.Println(response)
}
Delete variable
Delete a variable by its unique ID.
Request
functionId requiredFunction unique ID.
variableId requiredVariable unique ID.
Response
204
DELETE /functions/{functionId}/variables/{variableId}
package main
import (
"fmt"
"github.com/appwrite/sdk-for-go/client"
"github.com/appwrite/sdk-for-go/functions"
)
func main() {
client := client.NewClient()
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetProject("<YOUR_PROJECT_ID>") // Your project ID
client.SetKey("<YOUR_API_KEY>") // Your secret API key
service := functions.NewFunctions(client)
response, error := service.DeleteVariable(
"<FUNCTION_ID>",
"<VARIABLE_ID>",
)
if error != nil {
panic(error)
}
fmt.Println(response)
}