# deploy-function

Deploy a function using the Appwrite CLI

Skill by Appwrite. Category: Shipping and ops.

## Install

Project (for this project only):

```sh
npx skills add appwrite/codex-plugin --skill deploy-function
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

Global (for every project on this machine):

```sh
npx skills add appwrite/codex-plugin --skill deploy-function -g
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

## Tags

- Runs on your computer: It runs as a program on your machine, with your access.

## Security audits

- Gen Agent Trust Hub: Pass
- Socket: Pass
- Snyk: Fail

Installs: 1. Installs counted by skills.sh. [Open on skills.sh](https://www.skills.sh/appwrite/codex-plugin/deploy-function)

## Source

[Open the source](https://github.com/appwrite/codex-plugin/tree/HEAD/plugins/appwrite/skills/appwrite-deploy-function). Checked 2026-10-10. This summary may contain AI-generated text, so it can be wrong. Check the source before you rely on it.

## SKILL.md

````markdown
---
name: deploy-function
description: Deploy a function using the Appwrite CLI
---

# Deploy a function using the Appwrite CLI

## Prerequisites

- Appwrite CLI installed (`npm install -g appwrite-cli`)
- Authenticated with `appwrite login`
- Project initialized with `appwrite init`

## Quick Deploy

```sh
appwrite push functions
```

## Full Workflow

### 1. Initialize a new function

```sh
appwrite init functions
```

This scaffolds a new function with a starter template and adds it to `appwrite.config.json`.

### 2. Pull existing functions from Console

```sh
appwrite pull functions
```

### 3. Configuration

Functions are configured in `appwrite.config.json`:

```json
{
    "projectId": "<PROJECT_ID>",
    "endpoint": "https://<REGION>.cloud.appwrite.io/v1",
    "functions": [
        {
            "$id": "<FUNCTION_ID>",
            "name": "userAuth",
            "enabled": true,
            "live": true,
            "logging": true,
            "runtime": "node-18.0",
            "deployment": "<DEPLOYMENT_ID>",
            "vars": [],
            "events": [],
            "schedule": "",
            "timeout": 15,
            "entrypoint": "userAuth.js",
            "commands": "npm install",
            "version": "v3",
            "path": "functions/userAuth"
        }
    ]
}
```

### 4. Deploy

```sh
appwrite push functions
```

## CI/CD (Non-Interactive)

Set up headless mode first:

```sh
appwrite client \
    --endpoint https://<REGION>.cloud.appwrite.io/v1 \
    --project-id <PROJECT_ID> \
    --key <API_KEY>
```

Then deploy non-interactively:

```sh
# Push all functions
appwrite push functions --all --force

# Push a specific function
appwrite push functions --function-id <FUNCTION_ID> --force

# Push all resources at once (functions, tables, buckets, teams, topics)
appwrite push all --all --force
```

## Function Management Commands

| Command | Description |
|---------|-------------|
| `appwrite functions list` | List all functions in the project |
| `appwrite functions create` | Create a new function |
| `appwrite functions get --function-id <ID>` | Get a function by ID |
| `appwrite functions update --function-id <ID>` | Update a function |
| `appwrite functions delete --function-id <ID>` | Delete a function |
| `appwrite functions list-runtimes` | List all active runtimes |

## Deployment Commands

| Command | Description |
|---------|-------------|
| `appwrite functions list-deployments --function-id <ID>` | List all deployments |
| `appwrite functions create-deployment --function-id <ID>` | Upload a new deployment |
| `appwrite functions get-deployment --function-id <ID> --deployment-id <ID>` | Get a deployment |
| `appwrite functions update-deployment --function-id <ID> --deployment-id <ID>` | Set active deployment |
| `appwrite functions delete-deployment --function-id <ID> --deployment-id <ID>` | Delete a deployment |
| `appwrite functions download-deployment --function-id <ID> --deployment-id <ID>` | Download deployment contents |

## Execution Commands

| Command | Description |
|---------|-------------|
| `appwrite functions create-execution --function-id <ID>` | Trigger a function execution |
| `appwrite functions list-executions --function-id <ID>` | List execution logs |
| `appwrite functions get-execution --function-id <ID> --execution-id <ID>` | Get an execution log |

### Trigger with body

```sh
appwrite functions create-execution \
    --function-id <FUNCTION_ID> \
    --body '{"key": "value"}'
```

## Environment Variables

| Command | Description |
|---------|-------------|
| `appwrite functions list-variables --function-id <ID>` | List all variables |
| `appwrite functions create-variable --function-id <ID> --key <KEY> --value <VALUE>` | Create a variable |
| `appwrite functions update-variable --function-id <ID> --variable-id <ID> --key <KEY> --value <VALUE>` | Update a variable |
| `appwrite functions delete-variable --function-id <ID> --variable-id <ID>` | Delete a variable |

Variables are accessible at runtime as environment variables.

## Local Development

Run your function locally for quick debugging:

```sh
appwrite run functions
```

This starts a local development server that watches for file changes and automatically rebuilds.
````

- Previous: [webrtc-ios-integration](https://syn4pse.dev/terminal/webrtc-ios-integration.md)
- Next: [deploy-site](https://syn4pse.dev/terminal/appwrite-deploy-site.md)
- [Terminal](https://syn4pse.dev/terminal.md)
- [Suggest a change](mailto:terminal@syn4pse.dev?subject=Terminal%20suggestion)
