Skip to main content

Cloud Function Call Methods

CloudBase cloud functions support multiple call methods to meet the needs of different scenarios and platforms. You can choose the most suitable call method based on your actual situation.

Call Methods Overview

Call MethodApplicable ScenariosFeatures
HTTP APICross-language calls, third-party system integrationStandard REST API, supports all languages
Web ClientBrowser environment, frontend applicationsSupports CORS, direct HTTP access
SDK Calls (Coming Soon)Mini-programs, Web apps, mobile appsSimple and easy to use, automatic authentication
Mini-Program Calls (Coming Soon)WeChat Mini ProgramsNative support, no additional configuration

Calling cloud functions through HTTP API supports cross-language access, suitable for third-party system integration.

Getting Access Token

For how to get access tokens, please refer to AccessToken Documentation.

API Call Format

Request URL:

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

⚠️ Note: When calling HTTP cloud functions, you must add the webfn=true parameter to the request URL.

Request Headers:

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

Multi-Language Call Examples

cURL

# Call regular cloud function
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
}'

# Call 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"
}'

API Parameter Description

Path Parameters

ParameterTypeRequiredDescription
env-idstringYesEnvironment ID
function-namestringYesFunction name

Query Parameters

ParameterTypeRequiredDescription
webfnstringNoSet to true when calling HTTP cloud functions

Request Header Parameters

ParameterTypeRequiredDescription
AuthorizationstringYesBearer Token authentication
Content-TypestringYesRequest content type, usually application/json
X-QualifierstringNoSpecify the version of the function to call