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
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /functions
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.list(
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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 strings with execution roles. By default no user is granted with any execute permissions. learn more about permissions. 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?
Response
201
POST /functions
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.create(
functionId: '[FUNCTION_ID]',
name: '[NAME]',
runtime: 'node-14.5',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
GET /functions/runtimes
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.listRuntimes();
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
GET /functions/{functionId}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.get(
functionId: '[FUNCTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Update Function
Update function by its unique ID.
Request
functionId requiredFunction ID.
name requiredFunction name. Max length: 128 chars.
execute An array of strings with execution roles. By default no user is granted with any execute permissions. learn more about permissions. 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?
Response
200
PUT /functions/{functionId}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.update(
functionId: '[FUNCTION_ID]',
name: '[NAME]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Delete Function
Delete a function by its unique ID.
Request
functionId requiredFunction ID.
Response
204
DELETE /functions/{functionId}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.delete(
functionId: '[FUNCTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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: entrypoint, size, buildId, activate
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /functions/{functionId}/deployments
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.listDeployments(
functionId: '[FUNCTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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 entry point used to execute your code.
Request
functionId requiredFunction ID.
entrypoint requiredEntrypoint File.
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.
Response
202
POST /functions/{functionId}/deployments
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.createDeployment(
functionId: '[FUNCTION_ID]',
entrypoint: '[ENTRYPOINT]',
code: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'),
activate: false,
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.getDeployment(
functionId: '[FUNCTION_ID]',
deploymentId: '[DEPLOYMENT_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Update Function 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}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.updateDeployment(
functionId: '[FUNCTION_ID]',
deploymentId: '[DEPLOYMENT_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.deleteDeployment(
functionId: '[FUNCTION_ID]',
deploymentId: '[DEPLOYMENT_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Create Build
Request
functionId requiredFunction ID.
deploymentId requiredDeployment ID.
buildId requiredBuild unique ID.
Response
204
POST /functions/{functionId}/deployments/{deploymentId}/builds/{buildId}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.createBuild(
functionId: '[FUNCTION_ID]',
deploymentId: '[DEPLOYMENT_ID]',
buildId: '[BUILD_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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, statusCode, duration
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /functions/{functionId}/executions
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.listExecutions(
functionId: '[FUNCTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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.
data String of custom data to send to function.
async Execute code in the background. Default value is false.
Response
201
Rate limits
This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with
setSession
, these rate limits will still apply. Learn more about SSR rate limits.The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 60 requests IP + USER ID
POST /functions/{functionId}/executions
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.createExecution(
functionId: '[FUNCTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.getExecution(
functionId: '[FUNCTION_ID]',
executionId: '[EXECUTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
List Variables
Get a list of all variables of a specific function.
Request
functionId requiredFunction unique ID.
Response
200
GET /functions/{functionId}/variables
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.listVariables(
functionId: '[FUNCTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Create Variable
Create a new function variable. These variables can be accessed within function in the env
object under the request variable.
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
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.createVariable(
functionId: '[FUNCTION_ID]',
key: '[KEY]',
value: '[VALUE]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.getVariable(
functionId: '[FUNCTION_ID]',
variableId: '[VARIABLE_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.updateVariable(
functionId: '[FUNCTION_ID]',
variableId: '[VARIABLE_ID]',
key: '[KEY]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.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}
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
Future result = functions.deleteVariable(
functionId: '[FUNCTION_ID]',
variableId: '[VARIABLE_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}