Skip to main content

HTTP API Invocation (Cross-Language)

HTTP API Access

To access cloud functions via the Cloud Function HTTP API, you need to first obtain an access token (Token), then use this token for API invocation.

Obtain an Access Token

To obtain an access token, see the AccessToken documentation.

API Invocation Format

Request URL:

POST https://{env-id}.api.tcloudbasegateway.com/v1/functions/{function-name}

Request Headers:

Authorization: Bearer {access_token}
Content-Type: application/json

Multi-Language Invocation Sample

# Basic Invocation
curl -L 'https://your-env-id.api.tcloudbasegateway.com/v1/functions/your-function-name' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/json' \
-d '{
"message": "Hello CloudBase",
"timestamp": 1640995200000
}'

# HTTP Cloud Function
curl -L 'https://your-env-id.api.tcloudbasegateway.com/v1/functions/your-web-function?webfn=true' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/json' \
-d '{
"path": "/api/users",
"method": "GET"
}'

HTTP API Parameters Description

Path Parameters

ParameterTypeRequiredDescription
env-idstringYesEnvironment ID
function-namestringYesFunction name

Query Parameters

ParameterTypeRequiredDescription
webfnstringNoSet to true when calling HTTP cloud function

Request Header Parameters

ParameterTypeRequiredDescription
AuthorizationstringYesBearer Token authentication
Content-TypestringYesRequest content type, usually application/json
X-QualifierstringNoSpecifies the version of the function to invoke
X-Tcb-WebfnstringNoSet to true when calling HTTP cloud function