tcb fn invoke
Invoke a deployed cloud function.
Prerequisites
tcb loginhas 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
| Flag | Required | Description | Default |
|---|---|---|---|
[name] | No | Function name | All functions in the configuration file |
-d, --data <data> | No | Request data as a JSON string or @filename | — |
--params <params> | No | Request data as a JSON string. Supported for compatibility; -d is recommended | — |
-X, --method <method> | No | HTTP method: GET, POST, PUT, DELETE, PATCH. HTTP functions only | — |
-H, --header <header> | No | Custom request header in "Key: Value" form. Repeatable. HTTP functions only | — |
-i, --include | No | Include response headers in the output. HTTP functions only | — |
--api-key <apiKey> | No | Admin API key that skips the access_token exchange. HTTP functions only | — |
--json | No | Output in JSON format | — |
-e, --env-id <envId> | No | Environment ID | Current 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-iapply only to HTTP functions and are ignored for event functions.--paramsexists for compatibility. New scripts should use-d.- A
-dvalue starting with@is read as a file path; other values are parsed as JSON strings.
Related commands
tcb fn deploy: deploy a functiontcb fn detail: check the function type and configuration