Skip to main content

Overview

The CloudBase HTTP API is a set of interfaces for accessing CloudBase platform features via the HTTP protocol, supporting functionalities such as databases, data models, user authentication, cloud functions, cloud hosting, cloud storage, AI, etc.

API Surface​

Use the OpenAPI definition in this documentation as the API list. Do not treat the self-description returned by the gateway as an API list.

Call only endpoints listed in this documentation or in the OpenAPI definition. Do not probe the gateway or infer unlisted paths from open-source implementations.

DocumentedNot documented
Paths and methods listed on this sitePaths found in gateway responses, error messages, or captured requests
Paths and methods in the OpenAPI definitionPaths that return 200 but have no documentation entry
Parameters and response fields listed hereCapabilities inferred from PostgREST or other open-source projects that CloudBase has not published

⚠️ Undocumented endpoints carry no compatibility commitment or SLA and may change or stop working without notice.

Prerequisites​

Before you begin, make sure you have completed the following preparations:

  1. Enable the CloudBase environment: Enable the CloudBase environment
  2. Security Configuration: If you wish to call from the browser side, ensure that your environment is configured with CloudBase/Security Sources to allow cross-origin calls.
    • Local development samples: localhost:3000, 127.0.0.1:3000
    • Production environment example: Your actual domain
    • Use the online debugging tool: docs.cloudbase.net

⚠️ Note: Browser-side calls must be configured with security sources; otherwise, requests will fail due to cross-origin restrictions.

Authentication and Authorization​

To call the CloudBase HTTP API, authentication and authorization are required. Please select the appropriate authentication method based on your application scenarios:

Applicable Environment: Client/Server
Applicable Identity: User identity

Commonly used in client applications (such as mobile apps, Web front-ends) to access backend services, supporting granular access control for user identities.

Obtaining Method: Refer to Obtaining AccessToken

💡 Note: When using AccessToken to access APIs, you can control user and role permissions for each API via CloudBase Platform/Policy Management.

Call Endpoint​

The CloudBase HTTP API uses a unified domain name for API calls via a domain that varies depending on the region to which the environment belongs.

If your environment is located in Mainland China regions such as Shanghai (ap-shanghai), use the domains below for API calls. Switch to a backup domain when the primary domain has resolution issues or is blocked on your network; API paths and authentication stay the same:

TypeDomain
Primaryhttps://{your-env}.api.tcloudbasegateway.com
Backup 1https://{your-env}.api.tcloudbasegateway.cn
Backup 2https://{your-env}.api.tcloudbasegateway.com.cn

where {your-env} needs to be replaced with the actual environment ID. For example, if the environment ID used is cloud1-abc, the call endpoint would be:

https://cloud1-abc.api.tcloudbasegateway.com

If your environment is located in overseas regions such as Singapore (ap-singapore), the following domain name should be used for API calls:

https://{your-env}.api.intl.tcloudbasegateway.com

where {your-env} needs to be replaced with the actual environment ID. For example, if the environment ID used is cloud1-abc, the call endpoint would be:

https://cloud1-abc.api.intl.tcloudbasegateway.com

Usage Example​

Cloud Function Invocation Sample​

The following sample shows how to invoke a Cloud Function via the HTTP API:

curl -X POST "https://your-env-id.api.tcloudbasegateway.com/v1/functions/YOUR_FUNCTION_NAME" \
-H "Authorization: Bearer <access_token/apikey/publishable_key>" \
-H "Content-Type: application/json" \
-d '{
"name": "Zhang San",
"age": 25
}'

When the Cloud Function is successfully invoked, the API returns a response in the following format:

{
"result": "Function execution result",
"requestId": "request ID",
"timestamp": 1640995200000
}

If the invocation fails, the error response format is as follows:

{
"code": "FUNCTIONS_PARAM_INVALID",
"message": "Parameter error details",
"requestId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

Online Debugging Tool​

The CloudBase Platform provides an online debugging tool that allows you to test API interfaces without writing code:

  1. Access the API documentation page
  2. Find the debugging tool entry
  3. Fill in the environment ID and request parameters
  4. Click to send the request and view the response.