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://<REGION>.cloud.appwrite.io/v1
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 requiredFunction ID.
data string String of custom data to send to function.
async boolean Execute code asynchronously. Default value is true.
Response
201 application/json
Rate limits
This endpoint is rate limited. You can only make a limited number of request to his endpoint within a specific time frame.
The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 60 requests URL + IP
POST /functions/{functionId}/executions
import { Client, Functions } from "appwrite";
const client = new Client();
const functions = new Functions(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
const promise = functions.createExecution('[FUNCTION_ID]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
Get Execution
Get a function execution log by its unique ID.
Request
functionId string requiredFunction ID.
executionId string requiredExecution ID.
Response
200 application/json
GET /functions/{functionId}/executions/{executionId}
import { Client, Functions } from "appwrite";
const client = new Client();
const functions = new Functions(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
const promise = functions.getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
List Executions
Get a list of all the current user function execution logs. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's executions. Learn more about different API modes.
Request
functionId string requiredFunction ID.
limit integer Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
offset integer Offset value. The default value is 0. Use this value to manage pagination. learn more about pagination
search string Search term to filter your list results. Max length: 256 chars.
cursor string ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. learn more about pagination
cursorDirection string Direction of the cursor, can be either 'before' or 'after'.
Response
200 application/json
GET /functions/{functionId}/executions
import { Client, Functions } from "appwrite";
const client = new Client();
const functions = new Functions(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
const promise = functions.listExecutions('[FUNCTION_ID]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
Retry Build
Request
functionId string requiredFunction ID.
deploymentId string requiredDeployment ID.
buildId string requiredBuild unique ID.
Response
204 application/json
POST /functions/{functionId}/deployments/{deploymentId}/builds/{buildId}
import { Client, Functions } from "appwrite";
const client = new Client();
const functions = new Functions(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
const promise = functions.retryBuild('[FUNCTION_ID]', '[DEPLOYMENT_ID]', '[BUILD_ID]');
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});