Functions

SERVER

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.

Base URL
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

      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 string

      Search term to filter your list results. Max length: 256 chars.

  • Response
Endpoint
GET /functions
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.list(
    listOf(), // queries (optional)
    "<SEARCH>", // search (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

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 string
      required

      Function 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 string
      required

      Function name. Max length: 128 chars.

    • runtime string
      required

      Execution runtime.

    • execute array

      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 array

      Events list. Maximum of 100 events are allowed.

    • schedule string

      Schedule CRON syntax.

    • timeout integer

      Function maximum execution time in seconds.

    • enabled boolean

      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 boolean

      Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.

    • entrypoint string

      Entrypoint File. This path is relative to the "providerRootDirectory".

    • commands string

      Build Commands.

    • scopes array

      List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed.

    • installationId string

      Appwrite Installation ID for VCS (Version Control System) deployment.

    • providerRepositoryId string

      Repository ID of the repo linked to the function.

    • providerBranch string

      Production branch for the repo linked to the function.

    • providerSilentMode boolean

      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 string

      Path to function code in the linked repo.

    • templateRepository string

      Repository name of the template.

    • templateOwner string

      The name of the owner of the template.

    • templateRootDirectory string

      Path to function code in the template repo.

    • templateVersion string

      Version (tag) for the repo linked to the function template.

    • specification string

      Runtime specification for the function and builds.

  • Response
Endpoint
POST /functions
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;
import io.appwrite.enums.Runtime;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.create(
    "<FUNCTION_ID>", // functionId
    "<NAME>", // name
    .NODE_14_5, // runtime
    listOf("any"), // execute (optional)
    listOf(), // events (optional)
    "", // schedule (optional)
    1, // timeout (optional)
    false, // enabled (optional)
    false, // logging (optional)
    "<ENTRYPOINT>", // entrypoint (optional)
    "<COMMANDS>", // commands (optional)
    listOf(), // scopes (optional)
    "<INSTALLATION_ID>", // installationId (optional)
    "<PROVIDER_REPOSITORY_ID>", // providerRepositoryId (optional)
    "<PROVIDER_BRANCH>", // providerBranch (optional)
    false, // providerSilentMode (optional)
    "<PROVIDER_ROOT_DIRECTORY>", // providerRootDirectory (optional)
    "<TEMPLATE_REPOSITORY>", // templateRepository (optional)
    "<TEMPLATE_OWNER>", // templateOwner (optional)
    "<TEMPLATE_ROOT_DIRECTORY>", // templateRootDirectory (optional)
    "<TEMPLATE_VERSION>", // templateVersion (optional)
    "", // specification (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

List runtimes

Get a list of all runtimes that are currently active on your instance.

Endpoint
GET /functions/runtimes
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.listRuntimes(new CoroutineCallback<>((result, error) -> {
    if (error != null) {
        error.printStackTrace();
        return;
    }

    System.out.println(result);
}));

List available function runtime specifications

List allowed function specifications for this instance.

Endpoint
GET /functions/specifications
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.listSpecifications(new CoroutineCallback<>((result, error) -> {
    if (error != null) {
        error.printStackTrace();
        return;
    }

    System.out.println(result);
}));

Get function

Get a function by its unique ID.

  • Request
    • functionId string
      required

      Function ID.

  • Response
Endpoint
GET /functions/{functionId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.get(
    "<FUNCTION_ID>", // functionId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Update function

Update function by its unique ID.

  • Request
    • functionId string
      required

      Function ID.

    • name string
      required

      Function name. Max length: 128 chars.

    • runtime string

      Execution runtime.

    • execute array

      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 array

      Events list. Maximum of 100 events are allowed.

    • schedule string

      Schedule CRON syntax.

    • timeout integer

      Maximum execution time in seconds.

    • enabled boolean

      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 boolean

      Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.

    • entrypoint string

      Entrypoint File. This path is relative to the "providerRootDirectory".

    • commands string

      Build Commands.

    • scopes array

      List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed.

    • installationId string

      Appwrite Installation ID for VCS (Version Controle System) deployment.

    • providerRepositoryId string

      Repository ID of the repo linked to the function

    • providerBranch string

      Production branch for the repo linked to the function

    • providerSilentMode boolean

      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 string

      Path to function code in the linked repo.

    • specification string

      Runtime specification for the function and builds.

  • Response
Endpoint
PUT /functions/{functionId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.update(
    "<FUNCTION_ID>", // functionId
    "<NAME>", // name
    .NODE_14_5, // runtime (optional)
    listOf("any"), // execute (optional)
    listOf(), // events (optional)
    "", // schedule (optional)
    1, // timeout (optional)
    false, // enabled (optional)
    false, // logging (optional)
    "<ENTRYPOINT>", // entrypoint (optional)
    "<COMMANDS>", // commands (optional)
    listOf(), // scopes (optional)
    "<INSTALLATION_ID>", // installationId (optional)
    "<PROVIDER_REPOSITORY_ID>", // providerRepositoryId (optional)
    "<PROVIDER_BRANCH>", // providerBranch (optional)
    false, // providerSilentMode (optional)
    "<PROVIDER_ROOT_DIRECTORY>", // providerRootDirectory (optional)
    "", // specification (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Delete function

Delete a function by its unique ID.

  • Request
    • functionId string
      required

      Function ID.

  • Response
    • 204 application/json
Endpoint
DELETE /functions/{functionId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.delete(
    "<FUNCTION_ID>", // functionId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

List deployments

Get a list of all the project's code deployments. You can use the query params to filter your results.

  • Request
    • functionId string
      required

      Function ID.

    • queries array

      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 string

      Search term to filter your list results. Max length: 256 chars.

  • Response
Endpoint
GET /functions/{functionId}/deployments
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.listDeployments(
    "<FUNCTION_ID>", // functionId
    listOf(), // queries (optional)
    "<SEARCH>", // search (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

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 string
      required

      Function ID.

    • code string
      required

      Gzip 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 boolean
      required

      Automatically activate the deployment when it is finished building.

    • entrypoint string

      Entrypoint File.

    • commands string

      Build Commands.

  • Response
Endpoint
POST /functions/{functionId}/deployments
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.models.InputFile;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.createDeployment(
    "<FUNCTION_ID>", // functionId
    InputFile.fromPath("file.png"), // code
    false, // activate
    "<ENTRYPOINT>", // entrypoint (optional)
    "<COMMANDS>", // commands (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Get deployment

Get a code deployment by its unique ID.

  • Request
    • functionId string
      required

      Function ID.

    • deploymentId string
      required

      Deployment ID.

  • Response
Endpoint
GET /functions/{functionId}/deployments/{deploymentId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.getDeployment(
    "<FUNCTION_ID>", // functionId
    "<DEPLOYMENT_ID>", // deploymentId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

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 string
      required

      Function ID.

    • deploymentId string
      required

      Deployment ID.

  • Response
Endpoint
PATCH /functions/{functionId}/deployments/{deploymentId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.updateDeployment(
    "<FUNCTION_ID>", // functionId
    "<DEPLOYMENT_ID>", // deploymentId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Delete deployment

Delete a code deployment by its unique ID.

  • Request
    • functionId string
      required

      Function ID.

    • deploymentId string
      required

      Deployment ID.

  • Response
    • 204 application/json
Endpoint
DELETE /functions/{functionId}/deployments/{deploymentId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.deleteDeployment(
    "<FUNCTION_ID>", // functionId
    "<DEPLOYMENT_ID>", // deploymentId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Rebuild deployment

  • Request
    • functionId string
      required

      Function ID.

    • deploymentId string
      required

      Deployment ID.

    • buildId string

      Build unique ID.

  • Response
    • 204 application/json
Endpoint
POST /functions/{functionId}/deployments/{deploymentId}/build
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.createBuild(
    "<FUNCTION_ID>", // functionId
    "<DEPLOYMENT_ID>", // deploymentId
    "<BUILD_ID>", // buildId (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Cancel deployment

  • Request
    • functionId string
      required

      Function ID.

    • deploymentId string
      required

      Deployment ID.

  • Response
    • 200 application/json
Endpoint
PATCH /functions/{functionId}/deployments/{deploymentId}/build
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.updateDeploymentBuild(
    "<FUNCTION_ID>", // functionId
    "<DEPLOYMENT_ID>", // deploymentId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Download deployment

Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download.

  • Request
    • functionId string
      required

      Function ID.

    • deploymentId string
      required

      Deployment ID.

  • Response
    • 200 application/json
Endpoint
GET /functions/{functionId}/deployments/{deploymentId}/download
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.getDeploymentDownload(
    "<FUNCTION_ID>", // functionId
    "<DEPLOYMENT_ID>", // deploymentId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

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 string
      required

      Function ID.

    • queries array

      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 string

      Search term to filter your list results. Max length: 256 chars.

  • Response
Endpoint
GET /functions/{functionId}/executions
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setSession(""); // The user session to authenticate with

Functions functions = new Functions(client);

functions.listExecutions(
    "<FUNCTION_ID>", // functionId
    listOf(), // queries (optional)
    "<SEARCH>", // search (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

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 string
      required

      Function ID.

    • body string

      HTTP body of execution. Default value is empty string.

    • async boolean

      Execute code in the background. Default value is false.

    • path string

      HTTP path of execution. Path can include query params. Default value is /

    • method string

      HTTP method of execution. Default value is GET.

    • headers string

      HTTP headers of execution. Defaults to empty.

    • scheduledAt string

      Scheduled execution time in ISO 8601 format. DateTime value must be in future with precision in minutes.

  • Response
    • 201 application/json
Endpoint
POST /functions/{functionId}/executions
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setSession(""); // The user session to authenticate with

Functions functions = new Functions(client);

functions.createExecution(
    "<FUNCTION_ID>", // functionId
    "<BODY>", // body (optional)
    false, // async (optional)
    "<PATH>", // path (optional)
    ExecutionMethod.GET, // method (optional)
    mapOf( "a" to "b" ), // headers (optional)
    "", // scheduledAt (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Get execution

Get a function execution log by its unique ID.

  • Request
    • functionId string
      required

      Function ID.

    • executionId string
      required

      Execution ID.

  • Response
Endpoint
GET /functions/{functionId}/executions/{executionId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setSession(""); // The user session to authenticate with

Functions functions = new Functions(client);

functions.getExecution(
    "<FUNCTION_ID>", // functionId
    "<EXECUTION_ID>", // executionId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Delete execution

Delete a function execution by its unique ID.

  • Request
    • functionId string
      required

      Function ID.

    • executionId string
      required

      Execution ID.

  • Response
    • 204 application/json
Endpoint
DELETE /functions/{functionId}/executions/{executionId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.deleteExecution(
    "<FUNCTION_ID>", // functionId
    "<EXECUTION_ID>", // executionId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

List variables

Get a list of all variables of a specific function.

  • Request
    • functionId string
      required

      Function unique ID.

  • Response
Endpoint
GET /functions/{functionId}/variables
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.listVariables(
    "<FUNCTION_ID>", // functionId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Create variable

Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables.

  • Request
    • functionId string
      required

      Function unique ID.

    • key string
      required

      Variable key. Max length: 255 chars.

    • value string
      required

      Variable value. Max length: 8192 chars.

  • Response
Endpoint
POST /functions/{functionId}/variables
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.createVariable(
    "<FUNCTION_ID>", // functionId
    "<KEY>", // key
    "<VALUE>", // value
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Get variable

Get a variable by its unique ID.

  • Request
    • functionId string
      required

      Function unique ID.

    • variableId string
      required

      Variable unique ID.

  • Response
Endpoint
GET /functions/{functionId}/variables/{variableId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.getVariable(
    "<FUNCTION_ID>", // functionId
    "<VARIABLE_ID>", // variableId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Update variable

Update variable by its unique ID.

  • Request
    • functionId string
      required

      Function unique ID.

    • variableId string
      required

      Variable unique ID.

    • key string
      required

      Variable key. Max length: 255 chars.

    • value string

      Variable value. Max length: 8192 chars.

  • Response
Endpoint
PUT /functions/{functionId}/variables/{variableId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.updateVariable(
    "<FUNCTION_ID>", // functionId
    "<VARIABLE_ID>", // variableId
    "<KEY>", // key
    "<VALUE>", // value (optional)
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);

Delete variable

Delete a variable by its unique ID.

  • Request
    • functionId string
      required

      Function unique ID.

    • variableId string
      required

      Variable unique ID.

  • Response
    • 204 application/json
Endpoint
DELETE /functions/{functionId}/variables/{variableId}
Java
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Functions;

Client client = new Client()
    .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
    .setProject("<YOUR_PROJECT_ID>") // Your project ID
    .setKey("<YOUR_API_KEY>"); // Your secret API key

Functions functions = new Functions(client);

functions.deleteVariable(
    "<FUNCTION_ID>", // functionId
    "<VARIABLE_ID>", // variableId
    new CoroutineCallback<>((result, error) -> {
        if (error != null) {
            error.printStackTrace();
            return;
        }

        System.out.println(result);
    })
);