Skip to main content

tcb fn invoke

Invoke a deployed cloud function.

Prerequisites​

  • tcb login has been completed and an environment is specified.
  • The function is deployed. Confirm with tcb fn list.

Usage​

tcb fn invoke [options] [name]

When name is omitted, every function declared in the project configuration file is invoked.

Flags​

FlagRequiredDescriptionDefault
[name]NoFunction nameAll functions in the configuration file
-d, --data <data>NoRequest data as a JSON string or @filename—
--params <params>NoRequest data as a JSON string. Supported for compatibility; -d is recommended—
-X, --method <method>NoHTTP method: GET, POST, PUT, DELETE, PATCH. HTTP functions only—
-H, --header <header>NoCustom request header in "Key: Value" form. Repeatable. HTTP functions only—
-i, --includeNoInclude response headers in the output. HTTP functions only—
--api-key <apiKey>NoAdmin API key that skips the access_token exchange. HTTP functions only—
--jsonNoOutput in JSON format—
-e, --env-id <envId>NoEnvironment IDCurrent default environment

Examples​

Event functions receive an event object:

# Invoke without parameters
tcb fn invoke hello

# Pass JSON parameters
tcb fn invoke hello -d '{"userId":"123","action":"query"}'

# Read parameters from a file
tcb fn invoke hello -d @data.json

HTTP functions follow HTTP semantics:

# POST request
tcb fn invoke myHttpFunc -X POST -d '{"name":"test"}'

# With a request header
tcb fn invoke myHttpFunc -X GET -H "Authorization: Bearer xxx"

# Include response headers
tcb fn invoke myHttpFunc -X GET -i

# Skip the access_token exchange with an API key
tcb fn invoke myHttpFunc -X POST -d '{"name":"test"}' --api-key <apiKey>

Response​

Event functions return the result of the function entry point. HTTP functions return the response body, with response headers added by -i. --json prints a structured result.

Notes​

  • -X, -H, and -i apply only to HTTP functions and are ignored for event functions.
  • --params exists for compatibility. New scripts should use -d.
  • A -d value starting with @ is read as a file path; other values are parsed as JSON strings.