All Products
Search
Document Center

API Gateway:CreateApi

Last Updated:Mar 30, 2026

Creates an API.

Operation description

  • This operation is intended for API providers.

  • The name of an API must be unique within an API group.

  • A request path must be unique within an API group.

  • The QPS limit on this operation is 50 per user.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

apigateway:CreateApi

create

*ApiGroup

acs:apigateway:{#regionId}:{#accountId}:apigroup/{#GroupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

GroupId

string

Yes

The ID of the API group.

08ae4aa0f95e4321849ee57f4e0b3077

ApiName

string

Yes

The name of the API that you want to create. The name must be unique within the API group. The name must be 4 to 50 characters in length. It must start with a letter and can contain letters, digits, and underscores (_).

ApiName

Visibility

string

Yes

Specifies whether to make the API public. Valid values:

  • PUBLIC: Make the API public. If you set this parameter to PUBLIC, this API is displayed on the APIs page for all users after the API is published to the production environment.

  • PRIVATE: Make the API private. Private APIs are not displayed in the Alibaba Cloud Marketplace after the API group to which they belong is made available.

PUBLIC

Description

string

No

The description of the API. The description can be up to 180 characters in length.

Api description

AuthType

string

No

The configuration items of API requests sent by the consumer to API Gateway.

For more information, see RequestConfig.

APP

RequestConfig

string

Yes

The configuration items of API requests sent by API Gateway to the backend service.

For more information, see ServiceConfig.

{"RequestProtocol":"HTTP","RequestHttpMethod":"GET","RequestPath":"/v3/getUserTest/[userId]","BodyFormat":"FORM","PostBodyDescription":""}

ServiceConfig

string

Yes

The parameters of API requests sent by the consumer to API Gateway.

For more information, see RequestParameter.

{"ServiceProtocol":"HTTP","ServiceHttpMethod":"GET","ServiceAddress":"http://www.customerdomain.com","ServiceTimeout":"1000","ServicePath":"/v3/getUserTest/[userId]"}

RequestParameters

string

No

The common parameters of APIs in JSON format.

[ { "ParameterLocation": { "name": "Head", "orderNumber": 2 }, "ParameterType": "String", "Required": "OPTIONAL", "isHide": false, "ApiParameterName": "header1", "DefaultValue": "123124", "Location": "Head" }, { "ParameterLocation": { "name": "Head", "orderNumber": 2 }, "ParameterType": "String", "Required": "REQUIRED", "isHide": false, "ApiParameterName": "header2", "DefaultValue": "", "Location": "Head" }, { "ParameterLocation": { "name": "Query", "orderNumber": 3 }, "ParameterType": "String", "Required": "OPTIONAL", "isHide": false, "ApiParameterName": "query1", "DefaultValue": "1245", "Location": "Query" }, { "ApiParameterName": "CaClientIp", "ParameterLocation": { "name": "Query", "orderNumber": 0 }, "Location": "Query", "ParameterType": "String", "Required": "REQUIRED", "Description": "ClientIP" }, { "ApiParameterName": "testConstant", "ParameterLocation": { "name": "Head", "orderNumber": 0 }, "Location": "Head", "ParameterType": "String", "Required": "REQUIRED", "DefaultValue": "111" } ]

SystemParameters

string

No

The parameters of the API.

[{\"location\":\"HEAD\",\"parameterName\":\"CaDomain\",\"serviceParameterName\":\"host\"}]

ConstantParameters

string

No

The parameters of API requests sent by API Gateway to the backend service.

For more information, see ServiceParameter.

[{\"ConstantValue\":\"123\",\"Description\":\"Constant parameter\",\"Location\":\"HEAD\",\"ServiceParameterName\":\"test\"}]

ServiceParameters

string

No

The mappings between parameters of requests sent by the consumer to API Gateway and parameters of requests sent by API Gateway to the backend service.

For more information, see ServiceParameterMap.

[ { "ServiceParameterName": "header1", "Location": "Head", "Type": "String", "ParameterCatalog": "REQUEST" }, { "ServiceParameterName": "header2", "Location": "Query", "Type": "String", "ParameterCatalog": "REQUEST" }, { "ServiceParameterName": "query1", "Location": "Head", "Type": "String", "ParameterCatalog": "REQUEST" }, { "ServiceParameterName": "ipp", "Location": "Query", "Type": "String", "ParameterCatalog": "SYSTEM" }, { "ServiceParameterName": "testConstant", "Location": "Head", "Type": "String", "ParameterCatalog": "CONSTANT" } ]

ServiceParametersMap

string

No

The format of the response from the backend service. Valid values: JSON, TEXT, BINARY, XML, and HTML. Default value: JSON.

[ { "ServiceParameterName": "header1", "RequestParameterName": "header1" }, { "ServiceParameterName": "header2", "RequestParameterName": "header2" }, { "ServiceParameterName": "query1", "RequestParameterName": "query1" }, { "ServiceParameterName": "ipp", "RequestParameterName": "CaClientIp" }, { "ServiceParameterName": "testConstant", "RequestParameterName": "testConstant" } ]

ResultType

string

No

The sample response from the backend service.

HTML

ResultSample

string

No

An example of a response returned by the backend service. This value is used only to generate documentation. The actually returned result shall prevail.(Support up to 32KB)

{}

FailResultSample

string

No

The sample error codes returned by the backend service.

For more information, see ErrorCodeSample.(Support up to 16KB)

{\"requestId\":\"3b9b8b31-93c3-489e-8ebb-cab35a1aee51\",\"errCode\":500,\"errMsg\":\"connection refused\"}

ErrorCodeSamples

string

No

The return description of the API.

[{\"Code\":\"400\",\"Message\":\"Login failed\",\"Description\":\"Invalid user name or password\"}]

ResultDescriptions

string

No

The switch status of ACL. Valid values:- on and off.

{}

OpenIdConnectConfig

string

No

If the AuthType is APP authentication, you need to pass this value to specify the signature algorithm. If you do not specify this parameter, the default value HmacSHA256 is used. Valid values:

  • HmacSHA256

  • HmacSHA1,HmacSHA256

{\"openIdApiType\":null,\"idTokenParamName\":null,\"publicKeyId\":null,\"publicKey\":null}

AllowSignatureMethod

string

No

The type of the two-way communication API.

  • COMMON: normal APIs

  • REGISTER: registered APIs

  • UNREGISTER: unregistered APIs

  • NOTIFY: downstream notification APIs

HmacSHA256

WebSocketApiType

string

No

The return description of the API.

COMMON

ResultBodyModel

string

No

  • Specifies whether to set ForceNonceCheck to true to force the check of X-Ca-Nonce during the request. This is the unique identifier of the request and is generally identified by UUID. After receiving this parameter, API Gateway verifies the validity of this parameter. The same value can be used only once within 15 minutes. This helps prevent replay attacks.

  • If you set ForceNonceCheck to false, the check is not performed. The default value is false when you create an API.

{}

ForceNonceCheck

boolean

No

  • Specifies whether to set DisableInternet to true to limit API calls to within the VPC.

  • If you set DisableInternet to false, the limit is lifted. The default value is false when you create an API.

true

DisableInternet

boolean

No

If AuthType is set to APP, the valid values are:

  • DEFAULT: The default value that is used if no other values are passed. This value means that the setting of the group is used.

  • DISABLE: The authentication is disabled.

  • HEADER: AppCode can be placed in the Header parameter for authentication.

  • HEADER_QUERY: AppCode can be placed in the Header or Query parameter for authentication.

true

AppCodeAuthType

string

No

The IDof the backend service

HEADER

BackendId

string

No

Specifies whether to enable backend services.

a0305308908c4740aba9cbfd63ba99b7

BackendEnable

boolean

No

Specifies whether to enable backend services.

true

Tag

array<object>

No

The list of tags.

object

No

Key

string

No

The key of the tag.

env

Value

string

No

The value of the tag.

value

Response elements

Element

Type

Description

Example

object

ApiId

string

The ID of the API.

8afff6c8c4c6447abb035812e4d66b65

RequestId

string

The ID of the request.

6C87A26A-6A18-4B8E-8099-705278381A2C

Examples

Success response

JSON format

{
  "ApiId": "8afff6c8c4c6447abb035812e4d66b65",
  "RequestId": "6C87A26A-6A18-4B8E-8099-705278381A2C"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.