---
title: "Create new function"
method: POST
path: "/api/functions"
tags: ["Admin"]
---

# Create new function

`POST /api/functions`

Create a new function with code that runs in Deno runtime

## Request body

- object
  - `name` string, required — Display name for the function
  - `slug` string — URL-friendly identifier (auto-generated from name if not provided)
  - `code` string, required — JavaScript/TypeScript code that exports an async function
  - `description` string — Description of what the function does
  - `status` 'draft' | 'active' — Initial status (draft or active/deployed)

## Response `201`

Function created successfully

- object
  - `success` boolean
  - `function` FunctionMetadata
    - `id` string, uuid, required — Unique identifier for the function
    - `slug` string, required — URL-friendly identifier
    - `name` string, required — Display name for the function
    - `description` string, nullable — Description of what the function does
    - `status` 'draft' | 'active' | 'error', required — Current status of the function
    - `created_at` string, date-time, required — When the function was created
    - `updated_at` string, date-time, required — When the function was last updated
    - `deployed_at` string, date-time, nullable — When the function was last deployed (null if never deployed)

## Other responses

- `400` — Invalid request
- `409` — Function slug already exists
- `500` — Failed to create function

---

[API](https://skmtc.net/insforge/apis/insforge-authentication-api.md) · [All operations](https://skmtc.net/insforge/apis/insforge-authentication-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/insforge/insforge-authentication-api/versions/a935bb49f932/schema)
