Docs

Functions API


Client integration with  

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.

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 and user account. We use rate limits to avoid service abuse by users and as a security practice. Learn more about rate limiting.

HTTP Request

Name Type Description
functionId required string

Function ID.

data optional string

String of custom data to send to function.

async optional boolean

Execute code in the background. Default value is false.

HTTP Response

Status Code Content Type Payload
201  Created application/json Execution Object
Example Request
  • import { Client, Functions } from "appwrite";
    
    const client = new Client();
    
    const functions = new Functions(client);
    
    client
        .setEndpoint('https://cloud.appwrite.io/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
    });
  • import 'package:appwrite/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
      ;
      Future result = functions.createExecution(
        functionId: '[FUNCTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let functions = Functions(client)
    
    let execution = try await functions.createExecution(
        functionId: "[FUNCTION_ID]"
    )
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Functions
    
    val client = Client(context)
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val functions = Functions(client)
    
    val response = functions.createExecution(
        functionId = "[FUNCTION_ID]",
    )
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Functions;
    
    Client client = new Client(context)
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Functions functions = new Functions(client);
    
    functions.createExecution(
        "[FUNCTION_ID]",
        new CoroutineCallback<>((result, error) -> {
            if (error != null) {
                error.printStackTrace();
                return;
            }
    
            Log.d("Appwrite", result.toString());
        })
    );
    
  • mutation {
        functionsCreateExecution(
            functionId: "[FUNCTION_ID]"
        ) {
            _id
            _createdAt
            _updatedAt
            _permissions
            functionId
            trigger
            status
            statusCode
            response
            stdout
            stderr
            duration
        }
    }
    
  • POST /v1/functions/{functionId}/executions HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    {
      "data": "[DATA]",
      "async": false
    }
    

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.

HTTP Request

Name Type Description
functionId required string

Function ID.

queries optional 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, statusCode, duration

search optional string

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

HTTP Response

Status Code Content Type Payload
200  OK application/json Executions List Object
Example Request
  • import { Client, Functions } from "appwrite";
    
    const client = new Client();
    
    const functions = new Functions(client);
    
    client
        .setEndpoint('https://cloud.appwrite.io/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
    });
  • import 'package:appwrite/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
      ;
      Future result = functions.listExecutions(
        functionId: '[FUNCTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let functions = Functions(client)
    
    let executionList = try await functions.listExecutions(
        functionId: "[FUNCTION_ID]"
    )
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Functions
    
    val client = Client(context)
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val functions = Functions(client)
    
    val response = functions.listExecutions(
        functionId = "[FUNCTION_ID]",
    )
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Functions;
    
    Client client = new Client(context)
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Functions functions = new Functions(client);
    
    functions.listExecutions(
        "[FUNCTION_ID]",
        new CoroutineCallback<>((result, error) -> {
            if (error != null) {
                error.printStackTrace();
                return;
            }
    
            Log.d("Appwrite", result.toString());
        })
    );
    
  • query {
        functionsListExecutions(
            functionId: "[FUNCTION_ID]"
        ) {
            total
            executions {
                _id
                _createdAt
                _updatedAt
                _permissions
                functionId
                trigger
                status
                statusCode
                response
                stdout
                stderr
                duration
            }
        }
    }
    
  • GET /v1/functions/{functionId}/executions HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    

Get Execution

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

Get a function execution log by its unique ID.

HTTP Request

Name Type Description
functionId required string

Function ID.

executionId required string

Execution ID.

HTTP Response

Status Code Content Type Payload
200  OK application/json Execution Object
Example Request
  • import { Client, Functions } from "appwrite";
    
    const client = new Client();
    
    const functions = new Functions(client);
    
    client
        .setEndpoint('https://cloud.appwrite.io/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
    });
  • import 'package:appwrite/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
      ;
      Future result = functions.getExecution(
        functionId: '[FUNCTION_ID]',
        executionId: '[EXECUTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let functions = Functions(client)
    
    let execution = try await functions.getExecution(
        functionId: "[FUNCTION_ID]",
        executionId: "[EXECUTION_ID]"
    )
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Functions
    
    val client = Client(context)
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val functions = Functions(client)
    
    val response = functions.getExecution(
        functionId = "[FUNCTION_ID]",
        executionId = "[EXECUTION_ID]"
    )
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Functions;
    
    Client client = new Client(context)
        .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Functions functions = new Functions(client);
    
    functions.getExecution(
        "[FUNCTION_ID]",
        "[EXECUTION_ID]"
        new CoroutineCallback<>((result, error) -> {
            if (error != null) {
                error.printStackTrace();
                return;
            }
    
            Log.d("Appwrite", result.toString());
        })
    );
    
  • query {
        functionsGetExecution(
            functionId: "[FUNCTION_ID]",
            executionId: "[EXECUTION_ID]"
        ) {
            _id
            _createdAt
            _updatedAt
            _permissions
            functionId
            trigger
            status
            statusCode
            response
            stdout
            stderr
            duration
        }
    }
    
  • GET /v1/functions/{functionId}/executions/{executionId} HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...