Skip to content
post

Create function

Endpoint

posthttps://<REGION>.cloud.appwrite.io/v1/functions

Description

Required scopes

functions.write

Authentication

Initialize the Appwrite client with setProject() and a server API key (setKey()). For direct REST calls, send X-Appwrite-Project and X-Appwrite-Key.

Parameters

string
Required
string
Required
enum
Required
array
array
string
integer
boolean
boolean
string
string
enum
string
string
string
boolean
string
array
array
string
string
integer
integer
Status
Content type
201
application/json

Function

Name
Type
Description
string
string
string
arrayof string
string
boolean
boolean
boolean
string
integer
string
string
string
string
string
arrayof string
arrayof Variable

Object type

arrayof string
string
integer
integer
string
string
string
string
string
string
string
boolean
arrayof string
arrayof string
string
string
Python
from appwrite.client import Client
from appwrite.services.functions import Functions
from appwrite.models import Function
from appwrite.enums.runtime import Runtime
from appwrite.enums.project_key_scopes import ProjectKeyScopes
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_key('<YOUR_API_KEY>') # Your secret API key
functions = Functions(client)
result: Function = functions.create(
function_id = '<FUNCTION_ID>',
name = '<NAME>',
runtime = Runtime.NODE_14_5,
execute = ["any"], # optional
events = [], # optional
schedule = '0 0 * * *', # optional
timeout = 1, # optional
enabled = False, # optional
logging = False, # optional
entrypoint = '<ENTRYPOINT>', # optional
commands = '<COMMANDS>', # optional
scopes = [ProjectKeyScopes.PROJECT_READ], # optional
installation_id = '<INSTALLATION_ID>', # optional
provider_repository_id = '<PROVIDER_REPOSITORY_ID>', # optional
provider_branch = '<PROVIDER_BRANCH>', # optional
provider_silent_mode = False, # optional
provider_root_directory = '<PROVIDER_ROOT_DIRECTORY>', # optional
provider_branches = [], # optional
provider_paths = [], # optional
build_specification = 's-1vcpu-512mb', # optional
runtime_specification = 's-1vcpu-512mb', # optional
deployment_retention = 0, # optional
interval = 0 # optional
)
print(result.model_dump())