All Products
Document Center

Configure API

Last Updated: Apr 13, 2022

After registering an API (especially an HTTP API), you need to perform related configuration to use it. Only APIs in enabled state can be called. For HTTP APIs, you need to manually enable them.

About this task

You can complete the following configurations for an API:

For more information about related parameters and configuration rules, click the links above.


To configure an API, perform the following steps:

  1. Log in to the mPaaS console. In the left-side navigation pane, click Mobile Gateway Service.

  2. In the API list, click Configure in the Operations column of the target API. The API details page is displayed.

  3. In different API configuration areas, click Edit and edit the corresponding parameters. For more information, see Configuration information below.

  4. Click Save.

Configuration information

Basic information

Set the following parameters for HTTP API.

  • API name: The name of the API. This parameter is required and will be used for subsequent maintenance.

  • Description: The description of the API. This parameter is optional.

  • System: The business system to which the API belongs. This parameter is required.

  • Request path: The URL of the request. This parameter is required. You can enclose the path with${}, for example, /pets/${id}.

  • Request method: This parameter is required. Valid values include GET, POST, PUT, DELETE, and HEAD.

  • Message charset: This parameter is required. Valid values include UTF-8 and GBK.

    Advanced settings

    • Signature verification: Enable signature verification as required. If it is enabled, signatures in client requests will be verified.

    • Timeout period (ms): Set the API timeout interval, in ms. The timeout period settings sorted by priority are as follows: API timeout period > system timeout period > Default timeout period (3000 ms).

    • Open JSONP: Whether to allow cross-domain HTTP requests. JSONP allows the system to call APIs across multiple domains.

    Header settings

    MPS allows you to add or delete headers for all requests. In the Header settings area, click Modify to enter the edit mode. You can add or delete rules. Each rule contains four attributes: Location, Type, headerKey, and value.

    • Location: Valid values include request and response.

      • If you select request header, a header will be automatically added to the request. The business system can obtain the header from MobileRpcHolder.

      • If you select response header, a header will be automatically added to the response. The client can obtain the header from the response.

    • Type: Valid values include add and delete.

      • add: Add a header, which will overwrite the existing header (if any) in the original request.

      • delete: Delete a header. If this option is selected, value is optional. If value is set, the header will be deleted only when the specified value is matched.

    • headerKey: The value can be any string that complies with the RFC definition, except for headers exclusive to HTTP (such as host and content-Type) or exclusive to mPaaSGW (such as operation-Type).

    • value: The value can be any string.


    Don’t use underscores “_” when defining an HTTP header.

    Traffic limit configuration

    Traffic limit configuration includes traffic limit mode, traffic limit value, and traffic limit response:

    • Traffic limit mode

      • Disabled: API calls are not restricted.

      • Intercept: When the call frequency exceeds the traffic limit threshold, the request is intercepted.

    • Traffic limit value

      Set a reasonable traffic limit threshold (in seconds) according to business requirements. When the traffic limit mode is Intercept and exceeds this value, the request will be restricted.

    • Traffic limit response

      The default response for traffic limiting is: {"resultStatus":1002,"tips":"Too many customers, please wait for a moment"} .

      To customize the traffic limit response, use the following format:

            "result": "==This is the customized response content, please fill in==",
            "tips": "ok",
            "resultStatus": 1000

      Among them,

      • result is customized response data, in JSON format. The client only take this field for processing when resultStatus is 1000.

      • tips is customized traffic limit tips. If resultStatus is 1002, this field will be used to prompt the user.

      • resultStatus is the result code returned by the traffic limit. For the specific meaning, please refer to Gateway result codes.

    Cache configuration

    Cache API responses to reduce the business system pressure. For more information, see API cache.

    Parameter settings

    Parameter settings only work on HTTP APIs. You do not need to configure parameters for APIs created through automatic import.
    • Request parameter: Set the dynamic parameters and URL Query parameters in Path, and the parameter name must be unique.

      • Parameter name: Required, the name of the parameter.

        If it is a Path parameter, the parameter name must be consistent with that in the request path. For example, if the request path is /pets/${id}, then the parameter name should be id.

      • Parameter location: Required, it specifies whether the parameter is located in Path or Query String.

      • Type: Required, supported types include String, Int, Long, Float, Double, and Boolean.

      • Default value: Optional, the default value of the parameter.

      • Description: Optional, the description of the parameter.

    • Request body: Specify data model and Content-Type of request body. The request body setting is only available for POST request. Namely, only when the calling method of the API is POST, the request body setting appears.

      • Type of request body: Supported body types include String, Int, Long, Float, Double, Boolean, List, Map, and Object.

      • Message type: Supported message types include application/json, application/x-www-form-urlencoded, and application/protobuf.

    • Response result: Specify the type of response result.

      • Response result type: Refers to the basic data type or custom data model.