---
title: "Create function"
method: POST
path: "/api/v1/functions"
tags: ["Functions"]
---

# Create function

`POST /api/v1/functions`

Create a serverless function. The function serves at
`https://{slug}.fn.raffusercloud.com` — the slug is your name plus a
short random suffix, so names never collide across accounts.

Functions unlock after your first top-up of $5 or more (the money
stays in your balance). Deploy code afterwards with a source upload
and a deployment, or use a starter template.

Timeouts above 3600s require `extended_timeout: true` (max 86400s /
24h). Long runs bill wall-clock memory while they execute — there is
no extra fee.

## Headers

- `X-Project-ID` string, uuid, required

## Request body

- CreateFunctionRequest
  - `name` string, required
  - `slug` string — Optional URL label base (a random suffix is always appended)
  - `description` string
  - `runtime` 'python' | 'node' | 'go' | 'docker', required
  - `region` 'us-east'
  - `memory_mb` integer
  - `timeout_seconds` integer
  - `extended_timeout` boolean — Allow timeouts up to 86400s (24h)
  - `min_scale` integer
  - `max_scale` integer
  - `source_type` 'console' | 'cli' | 'github'

## Response `201`

Function created (status `pending` until first deployment)

- object
  - `success` boolean
  - `data` object
    - `function` Function — A serverless function. Handlers are standard (ASGI / Web Fetch / net/http / any container listening on $PORT) — nothing Raff-specific.
      - `id` string, uuid
      - `function_id` string — Short reference id, e.g. `fn-a1b2c3d4`
      - `project_id` string, uuid
      - `name` string — Display name, unique within the account
      - `slug` string — URL label — the name plus a short random suffix (never collides across accounts)
      - `description` string
      - `runtime` 'python' | 'node' | 'go' | 'docker'
      - `handler_kind` string — `asgi`, `fetch`, `net_http` or `container`
      - `region` 'us-east'
      - `memory_mb` integer — One of: 128, 256, 512, 1024, 2048, 4096
      - `timeout_seconds` integer — Up to 3600, or 86400 with `extended_timeout`
      - `extended_timeout` boolean
      - `min_scale` integer — 0 = scale to zero (idle bills nothing); ≥1 keeps warm instances at 30% of the memory rate
      - `max_scale` integer
      - `source_type` 'console' | 'cli' | 'github'
      - `repo_full_name` string — GitHub source only
      - `repo_branch` string
      - `repo_root_dir` string
      - `url` string — `https://{slug}.fn.raffusercloud.com` — HTTPS with automatic TLS
      - `status` 'pending' | 'building' | 'live' | 'paused' | 'error' | 'deleting'
      - `status_message` string
      - `current_revision_number` integer
      - `created_at` string, date-time
      - `updated_at` string, date-time

## Other responses

- `400` — Invalid request parameters
- `401` — Authentication required
- `403` — Account not funded — Functions unlock after the first top-up of $5 or more
- `409` — A function with this name already exists in the account

## Changes

- **2026-08-20** `efd3c11c5c92` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/rafftechnologies/apis/raff-api/changes/api/v1/functions/post.md)

---

[API](https://skmtc.dev/rafftechnologies/apis/raff-api.md) · [All operations](https://skmtc.dev/rafftechnologies/apis/raff-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/rafftechnologies/raff-api/revisions/2f4df56be77c/schema)
