All Products
Search
Document Center

API Gateway:CreateApi

Last Updated:Mar 01, 2024

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.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
apigateway:CreateApiWrite
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
GroupIdstringYes

The ID of the API group.

08ae4aa0f95e4321849ee57f4e0b3077
ApiNamestringYes

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
VisibilitystringYes

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
DescriptionstringNo

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

Api description
AuthTypestringNo

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

For more information, see RequestConfig .

APP
RequestConfigstringYes

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":""}
ServiceConfigstringYes

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]"}
RequestParametersstringNo

The common parameters of APIs in JSON format.

\[{\\"demoValue\\":\\"12345678\\",\\"description\\":\\"ConsumerAppKey\\",\\"location\\":\\"HEAD\\",\\"parameterName\\":\\"CaAppKey\\",\\"serviceParameterName\\":\\"X-Ca-Key\\"}]
SystemParametersstringNo

The parameters of the API.

[{\"demoValue\":\"12345678\",\"description\":\"ConsumerAppKey\",\"location\":\"HEAD\",\"parameterName\":\"CaAppKey\",\"serviceParameterName\":\"X-Ca-Key\"}]
ConstantParametersstringNo

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

For more information, see ServiceParameter .

\[{"ServiceParameterName":"age","Location":"Head","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"sex","Location":"Query","Type":"String","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"userId","Location":"Path","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"clientIp","Location":"Head","Type":"String","ParameterCatalog":"SYSTEM"},{"ServiceParameterName":"constance","Location":"Head","Type":"String","ParameterCatalog":"CONSTANT"}]
ServiceParametersstringNo

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":"age","Location":"Head","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"sex","Location":"Query","Type":"String","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"userId","Location":"Path","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"clientIp","Location":"Head","Type":"String","ParameterCatalog":"SYSTEM"},{"ServiceParameterName":"constance","Location":"Head","Type":"String","ParameterCatalog":"CONSTANT"}]
ServiceParametersMapstringNo

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

[{"ServiceParameterName":"age","RequestParameterName":"age"},{"ServiceParameterName":"sex","RequestParameterName":"sex"},{"ServiceParameterName":"userId","RequestParameterName":"userId"},{"ServiceParameterName":"clientIp","RequestParameterName":"CaClientIp"},{"ServiceParameterName":"constance","RequestParameterName":"constance"}]
ResultTypestringNo

The sample response from the backend service.

HTML
ResultSamplestringNo

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

200
FailResultSamplestringNo

The sample error codes returned by the backend service.

For more information, see ErrorCodeSample .

{"errorCode":"fail","errorMessage":"param invalid"}
ErrorCodeSamplesstringNo

The return description of the API.

\[]
ResultDescriptionsstringNo

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

[]
OpenIdConnectConfigstringNo

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}
AllowSignatureMethodstringNo

The type of the two-way communication API.

  • COMMON: normal APIs
  • REGISTER: registered APIs
  • UNREGISTER: unregistered APIs
  • NOTIFY: downstream notification APIs
HmacSHA256
WebSocketApiTypestringNo

The return description of the API.

COMMON
ResultBodyModelstringNo
  • 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.
{}
ForceNonceCheckbooleanNo
  • 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
DisableInternetbooleanNo

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
AppCodeAuthTypestringNo

The IDof the backend service

HEADER
BackendIdstringNo

Specifies whether to enable backend services.

a0305308908c4740aba9cbfd63ba99b7
BackendEnablebooleanNo

Specifies whether to enable backend services.

true
Tagobject []No

The list of tags.

KeystringNo

The key of the tag.

env
ValuestringNo

The value of the tag.

value

Response parameters

ParameterTypeDescriptionExample
object
ApiIdstring

The ID of the API.

8afff6c8c4c6447abb035812e4d66b65
RequestIdstring

The ID of the request.

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

Examples

Sample success responses

JSONformat

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

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-12-07The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: Tag
2023-05-30The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.