Execution_
Understand serverless function execution in Appwrite. Explore how triggers, events, and data flow enable dynamic execution of your code.
5 min read
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.
Execution modes
Appwrite Functions support two execution modes: synchronous and asynchronous.
Synchronous executions
Synchronous executions are those where Appwrite makes the request to the function runtime synchronously and waits for the response. The client making the request will wait until the function completes and receives the response directly.
Synchronous executions are created via:
- The Create execution endpoint where the
asyncparameter isfalse - Requests to custom or auto-generated domains
Synchronous executions:
- Return response bodies and headers directly to the client
- Have a 30-second hard timeout limit to discourage slow API calls that cause poor user experience in apps
- Are ideal for short-running operations where you need response data quickly
Asynchronous executions
Asynchronous executions are added to a queue and processed by the function worker as background jobs.
Asynchronous executions are created via:
- The Create execution endpoint where the
asyncparameter istrue - Event triggers (when functions are triggered by platform events)
- Scheduled executions (cron jobs or delayed executions)
Asynchronous executions:
- Have no timeout limitations beyond your function's configured timeout
- Are ideal for background processing and event-driven workflows
Response bodies and headers are not stored anywhere, so they are only ever returned via synchronous executions.
Domains
You can execute a function through HTTP requests, using a browser or by sending an HTTP request.
- In the Appwrite Console's sidebar, click Functions.
- Under Execute access, set the access to
Anyso that anyone can execute the function. You will use JWTs to authenticate users. - Under the Domains tab, you'll find the generated domain from Appwrite and your custom domains. Learn about adding a custom domain.
https://64d4d22db370ae41a32e.fra.appwrite.runWhen requests are made to this domain, whether through a browser or through an HTTP request, the request information like request URL, request headers, and request body will be passed to the function.
curl -X POST https://64d4d22db370ae41a32e.fra.appwrite.run \-H "X-Custom-Header: 123" \-H "x-appwrite-user-jwt: <YOUR_JWT_KEY>" \-H "Content-Type: application/json" \-d '{"data":"this is json data"}'Notice how a x-appwrite-user-jwt header is passed in the request, you will use this to authenticate users. Learn more about JWTs.
This unlocks the ability for you to develop custom HTTP endpoints with Appwrite Functions. It also allows accepting incoming webhooks for handling online payments, hosting social platform bots, and much more.
SDK
You can invoke your Appwrite Functions directly from 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 a modal below.
You'll be able to mock executions by configuring the path, method, headers, and body.

Events
Changes in Appwrite emit events. You can configure Functions to be executed in response to these events.
- In Appwrite Console, navigate to Functions.
- Click to open a function you wish to configure.
- Under the Settings tab, navigate to Events.
- Add one or multiple events as triggers for the function.
- 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.
In these executions, the event that triggered the function will be passed as the header x-appwrite-event to the function. The request.body parameter will contain the event data. Learn more about events.
You can use one of the following events.
Was this page helpful?
Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.