tencent cloud

Feedback

CreateApi

Last updated: 2024-10-10 21:41:00

    1. API Description

    Domain name for API request: apigateway.tencentcloudapi.com.

    This API is used to create an API. Before creating an API, you need to create a service, as each API belongs to a certain service.

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: CreateApi.
    Version Yes String Common Params. The value used for this API: 2018-08-08.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    ServiceId Yes String Unique service ID of API.
    ServiceType Yes String API backend service type. Valid values: HTTP, MOCK, TSF, SCF, WEBSOCKET, TARGET (in beta test).
    ServiceTimeout Yes Integer API backend service timeout period in seconds.
    Protocol Yes String API frontend request protocol. Valid values: HTTPS, WEBSOCKET.
    RequestConfig Yes ApiRequestConfig Request frontend configuration.
    ApiName No String Custom API name.
    ApiDesc No String Custom API description.
    ApiType No String API type. Valid values: NORMAL (general API), TSF (microservice API). Default value: NORMAL.
    AuthType No String API authentication type. Valid values: SECRET (key pair authentication), NONE (no authentication), OAUTH, APP (application authentication). Default value: NONE.
    EnableCORS No Boolean Whether to enable CORS.
    ConstantParameters.N No Array of ConstantParameter Constant parameter.
    RequestParameters.N No Array of RequestParameter Frontend request parameter.
    ApiBusinessType No String This field is valid if AuthType is OAUTH. NORMAL: business API; OAUTH: authorization API.
    ServiceMockReturnMessage No String Returned message of API backend Mock, which is required if ServiceType is Mock.
    MicroServices.N No Array of MicroServiceReq List of microservices bound to API.
    ServiceTsfLoadBalanceConf No TsfLoadBalanceConfResp Load balancing configuration of microservice.
    ServiceTsfHealthCheckConf No HealthCheckConf Health check configuration of microservice.
    TargetServices.N No Array of TargetServicesReq target type backend resource information (in beta test).
    TargetServicesLoadBalanceConf No Integer target type load balancing configuration (in beta test).
    TargetServicesHealthCheckConf No HealthCheckConf target health check configuration (in beta test).
    ServiceScfFunctionName No String SCF function name, which takes effect if the backend type is SCF.
    ServiceWebsocketRegisterFunctionName No String SCF WebSocket registration function, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceWebsocketCleanupFunctionName No String SCF WebSocket cleanup function, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceWebsocketTransportFunctionName No String SCF WebSocket transfer function, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceScfFunctionNamespace No String SCF function namespace, which takes effect if the backend type is SCF.
    ServiceScfFunctionQualifier No String SCF function version, which takes effect if the backend type is SCF.
    ServiceWebsocketRegisterFunctionNamespace No String SCF WebSocket registration function namespace, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceWebsocketRegisterFunctionQualifier No String SCF WebSocket transfer function version, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceWebsocketTransportFunctionNamespace No String SCF WebSocket transfer function namespace, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceWebsocketTransportFunctionQualifier No String SCF WebSocket transfer function version, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceWebsocketCleanupFunctionNamespace No String SCF WebSocket cleanup function namespace, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceWebsocketCleanupFunctionQualifier No String SCF WebSocket cleanup function version, which takes effect if the frontend type is WEBSOCKET and the backend type is SCF.
    ServiceScfIsIntegratedResponse No Boolean Whether to enable response integration, which takes effect if the backend type is SCF.
    IsDebugAfterCharge No Boolean Billing after debugging starts (reserved field for marketplace).
    IsDeleteResponseErrorCodes No Boolean Whether to delete the error codes for custom response configuration. If the value is left empty or False, the error codes will not be deleted. If the value is True, all custom response configuration error codes of the API will be deleted.
    ResponseType No String Return type.
    ResponseSuccessExample No String Sample response for successful custom response configuration.
    ResponseFailExample No String Sample response for failed custom response configuration.
    ServiceConfig No ServiceConfig API backend service configuration.
    AuthRelationApiId No String Unique ID of associated authorization API, which takes effect only if AuthType is OAUTH and ApiBusinessType is NORMAL. It is the unique ID of the OAuth 2.0 authorization API bound to the business API.
    ServiceParameters.N No Array of ServiceParameter API backend service parameter.
    OauthConfig No OauthConfig OAuth configuration, which takes effect if AuthType is OAUTH.
    ResponseErrorCodes.N No Array of ResponseErrorCodeReq Custom error code configuration.
    TargetNamespaceId No String TSF Serverless namespace ID (in beta test).
    UserType No String User type.
    IsBase64Encoded No Boolean Whether to enable Base64 encoding. This parameter takes effect only when the backend is SCF.
    EventBusId No String Event bus ID.
    ServiceScfFunctionType No String SCF function type, which takes effect if the backend type is SCF. Valid values: EVENT and HTTP.
    EIAMAppType No String EIAM application type.
    EIAMAuthType No String EIAM application authentication type. Valid values: AuthenticationOnly, Authentication, Authorization.
    TokenTimeout No Integer Validity of the EIAM application token. Unit: second. Default value: 7200.
    EIAMAppId No String EIAM application ID.
    Owner No String Owner of the resource

    3. Output Parameters

    Parameter Name Type Description
    Result CreateApiResultInfo API information
    Note: this field may return null, indicating that no valid values can be obtained.
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 CreateApi

    CreateApi

    Input Example

    https://apigateway.tencentcloudapi.com/?Action=CreateApi
    &ServiceId=service-ody35h5e
    &ApiName=name
    &ApiDesc=desc
    &ApiType=NORMAL
    &AuthType=NONE
    &ServiceType=MOCK
    &ServiceTimeout=15
    &Protocol=HTTP
    &RequestConfig.Path=/test
    &RequestConfig.Method=GET
    &EnableCORS=false
    &ApiBusinessType=NORMAL
    &ServiceMockReturnMessage=mock
    &<Common Request Parameters>
    

    Output Example

    {
        "Response": {
            "Result": {
                "ApiId": "abc",
                "Path": "abc",
                "Method": "abc",
                "CreatedTime": "2020-09-22T00:00:00+00:00"
            },
            "RequestId": "abc"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation.ApiInOperation The API is being manipulated. Please try again later.
    FailedOperation.BackendDomainError
    FailedOperation.DomainNeedBeian The domain name does not have an ICP filing through Tencent Cloud. Please get the ICP filing before binding the domain name.
    FailedOperation.EIAMError Error form EIAM
    FailedOperation.EbError Failed to bind/unbind EventBridge.
    FailedOperation.GetRoleError Failed to get the role. Please make sure that relevant API Gateway service APIs have been authorized.
    FailedOperation.ScfError Failed to bind/unbind SCF trigger.
    FailedOperation.ServiceError Service error.
    FailedOperation.ServiceInOperation The service is in use. Please try again later.
    InternalError.ApigwException API Gateway internal request error. Please try again later. If the problem persists, please contact the smart customer service or submit a ticket.
    InternalError.CauthException CAuth internal request error. Please try again later. If the problem persists, please submit a ticket.
    InternalError.ClbException CLB internal request error. Please try again. If the problem persists, please submit a ticket.
    InternalError.OssException OSS internal request error. Please try again. If the problem persists, please contact the smart customer service or submit a ticket.
    InternalError.ScfException SCF internal request error. Please try again. If the problem persists, please contact the smart customer service or submit a ticket.
    InternalError.TsfException TSF internal request error. Please try again. If the problem persists, please contact the smart customer service or submit a ticket.
    InternalError.VpcException VPC internal request error. Please try again. If the problem persists, please contact the smart customer service or submit a ticket.
    InvalidParameter.FormatError Incorrect parameter format.
    InvalidParameterValue.IllegalProxyIp Invalid backend IP address.
    InvalidParameterValue.InvalidApiBusinessType The API business type passed in must be OAUTH.
    InvalidParameterValue.InvalidApiRequestConfig Invalid API configuration.
    InvalidParameterValue.InvalidApiType The API type is incorrect. The microservice API only supports the TSF backend service type.
    InvalidParameterValue.InvalidBackendPath The backend service path configuration is incorrect.
    InvalidParameterValue.InvalidClb Invalid CLB configuration.
    InvalidParameterValue.InvalidIPAddress The value of the backend address parameter is incorrect.
    InvalidParameterValue.InvalidPort The backend service port is incorrect.
    InvalidParameterValue.InvalidPublicKey The OAUTH 2.0 API public key parameter is in an incorrect format.
    InvalidParameterValue.InvalidRegion Incorrect region.
    InvalidParameterValue.InvalidRequestParameters Invalid request parameter.
    InvalidParameterValue.InvalidScfConfig The SCF API parameters are invalid.
    InvalidParameterValue.InvalidServiceConfig Invalid service configuration.
    InvalidParameterValue.InvalidServiceMockReturnMessage The ServiceMockReturnMessage parameter is incorrect.
    InvalidParameterValue.InvalidServiceParam The parameter configuration is incorrect, as the parameter is not configured in the backend parameter configuration list.
    InvalidParameterValue.InvalidServiceParameters The ServiceParameters parameter is incorrect.
    InvalidParameterValue.InvalidServiceType The backend service type is incorrect. For backend services in WEBSOCKET type, the frontend protocol should be configured as WEBSOCKET.
    InvalidParameterValue.InvalidTsfConfig Incorrect configuration of the TSF-type API.
    InvalidParameterValue.InvalidUpstream The backend channel does not exist or is invalid.
    InvalidParameterValue.InvalidUrl The URL parameters are invalid.
    InvalidParameterValue.InvalidVpcConfig Invalid VPC information
    InvalidParameterValue.InvalidWSMethod The method is incorrect. For backend services in the WEBSOCKET type, the frontend method should be configured as GET.
    InvalidParameterValue.LimitExceeded The number of parameters has reached the limit (100).
    InvalidParameterValue.NotInOptions The parameter value is incorrect, as it is not an available option.
    InvalidParameterValue.ParameterNotMatch The backend parameter configuration is incorrect, as the related frontend parameters are not configured.
    InvalidParameterValue.RangeExceeded The parameter value is incorrect, as it is not within the valid value range.
    LimitExceeded.ApiCountLimitExceeded The number of APIs exceeds the limit.
    MissingParameter Missing parameter.
    ResourceNotFound.InvalidOauthApi Error with the OAuth service API.
    ResourceNotFound.InvalidService The corresponding service is invisible.
    UnsupportedOperation.BasicServiceNoMoreApi You are using the basic edition and only one API can be created.
    UnsupportedOperation.InvalidAction API error.
    UnsupportedOperation.InvalidEndpointType Backend type not supported
    UnsupportedOperation.ServiceExist
    UnsupportedOperation.UnpackError
    UnsupportedOperation.UnsupportedNetType Unsupported network type
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support