Docs

Functions API


Client integration with     code examples.

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 enviornment.

You can learn more by following our Cloud Functions tutorial.

Create Execution

POST/v1/functions/{functionId}/executions

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.

Rate Limits

This endpoint is limited to 60 requests in every 1 minutes per IP address. We use rate limits to avoid service abuse by users and as a security practice. Learn more about rate limiting.

Request

Name Type Description
functionId required string

Function unique ID.

Response

Status Code Content Type Payload
201  Created application/json Execution Object
Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.functions.createExecution('[FUNCTION_ID]');
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Functions functions = Functions(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
    
      Future result = functions.createExecution(
        functionId: '[FUNCTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }

List Executions

GET/v1/functions/{functionId}/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 teams. Learn more about different API modes.

Request

Name Type Description
functionId required string

Function unique ID.

search optional string

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

limit optional integer

Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.

offset optional integer

Results offset. The default value is 0. Use this param to manage pagination.

orderType optional string

Order result by ASC or DESC order.

Response

Status Code Content Type Payload
200  OK application/json Executions List Object
Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.functions.listExecutions('[FUNCTION_ID]');
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Functions functions = Functions(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
    
      Future result = functions.listExecutions(
        functionId: '[FUNCTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }

Get Execution

GET/v1/functions/{functionId}/executions/{executionId}

Get a function execution log by its unique ID.

Request

Name Type Description
functionId required string

Function unique ID.

executionId required string

Execution unique ID.

Response

Status Code Content Type Payload
200  OK application/json Execution Object
Example Request
  • let sdk = new Appwrite();
    
    sdk
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.functions.getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Functions functions = Functions(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
    
      Future result = functions.getExecution(
        functionId: '[FUNCTION_ID]',
        executionId: '[EXECUTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }