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”].
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
This API uses OAuth2 with the Client Credential flow. Client Credentials must be sent in the BODY, not the headers. For an example of how to implement this, refer to the c1TokenSource.Token() function.
Body
The FunctionsServiceCreateFunctionRequest message.
The commit message describing the initial code submission.
A description of what the function does.
The human-readable name for the function.
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.
FUNCTION_TYPE_UNSPECIFIED, FUNCTION_TYPE_ANY, FUNCTION_TYPE_CODE_MODE 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 { return { ok: true, echo: input }; }
The handler MUST return a JSON object — not a primitive, array, or null.