latestOpenAPI 3.1.0raw.githubusercontent.com2026-08-216381,9552.9 MB

f2cf3228f366

Function

Create Function

CreateFunction registers a new serverless function and creates its initial code commit. Functions run as TypeScript modules in a sandboxed runtime; see initial_content for the entry-file signature and SDK import.

The new function is unpublished. To make the commit the default runnable version (and have the function appear as runnable in the Functions UI), call UpdateFunction with function.published_commit_id set and update_mask=["published_commit_id"].

post/api/v1/functions

Request body

commitMessagestring

The commit message describing the initial code submission.

descriptionstring

A description of what the function does.

displayNamestring

The human-readable name for the function.

functionType'FUNCTION_TYPE_UNSPECIFIED' | 'FUNCTION_TYPE_ANY' | 'FUNCTION_TYPE_CODE_MODE'

The type of function to create. Use FUNCTION_TYPE_ANY for user functions — that is the type the Functions UI lists. Do not use any other value.

initialContentobject

File map for the initial code commit. Keys are file paths in the function root (e.g. "main.ts", "main.test.ts"); values are file contents as bytes.

Runtime: TypeScript. The entry file MUST be "main.ts" exporting a default async handler:

import { JSONObject } from "@c1/functions-sdk"; export default async function main(input: JSONObject): Promise<JSONObject> { return { ok: true, echo: input }; }

The handler MUST return a JSON object — not a primitive, array, or null.

Response

Successful response