Execution

Appwrite Functions can be executed in several ways. Executions can be invoked through the Appwrite SDK and visiting its REST endpoint. Functions can also be triggered by events and scheduled executions. Here are all the different ways to consume your Appwrite Functions.

Domains

  1. In the Appwrite Console's sidebar, click Functions.

  2. Under the Domains tab, you'll find the generated domain from Appwrite and your custom domains.

Bash
https://64d4d22db370ae41a32e.appwrite.global

Learn about adding a custom domain.

REST API

When requests are made to this domain, whether through a browser or through an HTTP requests, the request information like request URL, request headers, and request body will be passed to the function. This unlocks ability for Appwrite Function to become a full-blown API server on its own. It also allows accepting incoming webhooks for handling online payments, hosting social platform bots, and much more.

Bash
curl -X POST https://64d4d22db370ae41a32e.appwrite.global \
-H "X-Custom-Header: 123" \
-H "Content-Type: application/json" \
-d '{"data":"this is json data"}'

SDK

You can invoke your Appwrite Functions directly from the Appwrite SDKs.

Learn more about using the Appwrite SDKs

Console

Another easy way to test a function is directly in the Appwrite Console. You test a function by hitting the Execute now button, which will display with modal below.

You'll be able to mock executions by configuring the path, method, headers, and body.

Create project screen

Create project screen

Events

Changes in Appwrite emit events. You can configure Functions to be executed in response to these events.

  1. In Appwrite Console, navigate to Functions.

  2. Click to open a function you wish to configure.

  3. Under the Settings tab, navigate to Events.

  4. Add one or multiple events as triggers for the function.

  5. Be careful to avoid selecting events that can be caused by the function itself. This can cause the function to trigger its own execution, resulting in infinite recursions.

Schedule

Appwrite supports scheduled function executions. You can schedule executions using cron expressions in the settings of your function. Cron supports recurring executions as frequently as every minute.

Here are some cron expressions for common intervals:

Cron ExpressionSchedule
*/15 * * * *Every 15 minutes
0 * * * *Every Hour
0 0 * * *Every day at 00:00
0 0 * * 1Every Monday at 00:00

Permissions

Appwrite Functions can be executed using Client or Server SDKs. Client SDKs must be authenticated with an account that has been granted execution permissions on the function's settings page. Server SDKs require an API key with the correct scopes.

If your function has a generated or custom domain, executions are not authenticated. Anyone visiting the configured domains will be considered a guest, so make sure to give Any execute permission in order for domain executions to work. If you need to enforce permissions for functions with a domain, use authentication methods like JWT.

Logs and results

You can view the logs of your function executions in the Appwrite Console. Navigate to Functions and click on a function to view its executions.

For security reasons, Appwrite does not store the response of function executions. If you need to debug, we recommend logging the response in your function code.