Imports HTTP APIs. You can call this operation to import OpenAPI 2.0 and OpenAPI 3.0.x definition files to create REST APIs.
Debugging
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:
- For mandatory resource types, indicate with a prefix of * .
- If the permissions cannot be granted at the resource level,
All Resourcesis 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.
| Operation | Access level | Resource type | Condition key | Associated operation |
|---|---|---|---|---|
| apig:ImportHttpApi | none | *All Resources * |
| none |
Request syntax
POST /v1/http-apis/import HTTP/1.1
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| body | object | No | The request body. | |
| specContentBase64 | string | No | The Base64-encoded API definition (supports OAS 2.0/OAS 3.0 in YAML/JSON). This parameter has higher priority than the specFileUrl parameter. However, if the file size exceeds 10 MB, use the specFileUrl parameter to pass the definition. | b3BlbmFwaTogMy4wLjAKaW5mbzoKICAgIHRpdGxlOiBkZW1vCiAgICBkZXNjcmlwdGlvbjogdGhpc2lzZGVtbwogICAgdmVyc2lvbjogIiIKcGF0aHM6CiAgICAvdXNlci97dXNlcklkfToKICAgICAgICBnZXQ6CiAgICAgICAgICAgIHN1bW1hcnk6IOiOt+WPlueUqOaIt+S/oeaBrwogICAgICAgICAgICBkZXNjcmlwdGlvbjog6I635Y+W55So5oi35L+h5oGvCiAgICAgICAgICAgIG9wZXJhdGlvbklkOiBHZXRVc2VySW5mbwogICAgICAgICAgICByZXNwb25zZXM6CiAgICAgICAgICAgICAgICAiMjAwIjoKICAgICAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbjog5oiQ5YqfCiAgICAgICAgICAgICAgICAgICAgY29udGVudDoKICAgICAgICAgICAgICAgICAgICAgICAgYXBwbGljYXRpb24vanNvbjtjaGFyc2V0PXV0Zi04OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NoZW1hOiBudWxsCnNlcnZlcnM6CiAgICAtIHVybDogaHR0cDovL2FwaS5leGFtcGxlLmNvbS92MQo= |
| specFileUrl | string | No | The download URL of the API definition file. Must be either a publicly accessible Object Storage Service (OSS) URL or an OSS intranet endpoint within the same region. Requires download permissions. For OSS URLs that are not publicly readable, refer to https://www.alibabacloud.com/help/en/oss/user-guide/how-to-obtain-the-url-of-a-single-object-or-the-urls-of-multiple-objects and use URLs with download permissions. Currently, only OSS URLs are supported. | https://my-bucket.oss-cn-hangzhou.aliyuncs.com/my-api/api.yaml |
| name | string | No | The imported API name. If not specified, a name is extracted from the API definition file. If the API name and versioning configuration already exist, this import will update the existing API definition based on the strategy field. | import-test |
| description | string | No | The imported API description (255-byte limit). If not specified, a description is extracted from the API definition file. A maximum of 255 bytes is supported. | API for testing |
| versionConfig | HttpApiVersionConfig | No | The API versioning configuration. If versioning is enabled, an imported API that matches both the version number and the API name of an existing API will update that API. If versioning is disabled, an imported API that matches the API name of an existing API will update it. | |
| dryRun | boolean | No | Specifies whether to perform a precheck. If set to true, a check is performed without actual import. | false |
| strategy | string | No | The conflict resolution strategy when the API to be imported has the same name and version as an existing one. Valid values:
| ExistFirst |
| targetHttpApiId | string | No | The target REST API ID for direct updates. If specified, the import operation will directly update the designated API instead of creating new APIs or updating existing APIs based on the name and version. Only REST APIs can be specified. | api-xxxx |
| resourceGroupId | string | No | The resource group ID. | rg-acfm3q4zjh7fkki |
| specOssConfig | object | No | The OSS configuration details. | |
| regionId | string | No | The region ID. | cn-hangzhou |
| bucketName | string | No | The OSS bucket name. | api-1 |
| objectKey | string | No | The full file path in OSS. | /test/swagger.json |
| deployConfigs | array | No | The API deployment configuration. | |
| HttpApiDeployConfig | No | HttpApiDeployConfig | ||
| mcpRouteId | string | No | The MCP route ID. | xxx |
| gatewayId | string | No | Gateway ID. | gw-xxx |
Response parameters
Examples
Sample success responses
JSONformat
{
"requestId": "CE857A85-251D-5018-8103-A38957D71E20",
"code": "Ok",
"message": "success",
"data": {
"name": "import-test",
"httpApiId": "api-xxx",
"dryRunInfo": {
"successOperations": [
{
"action": "Create",
"name": "CreateUser",
"path": "/v1/users",
"method": "POST"
}
],
"failureOperations": [
{
"path": "/v1/orders",
"method": "GET",
"errorMessage": "Missing response definition.\n"
}
],
"successComponents": [
{
"action": "Create",
"name": "userDTO"
}
],
"failureComponents": [
{
"name": "orderDTO",
"errorMessage": "The data struct is incorrectly defined.\n"
}
],
"errorMessages": [
"OpenAPI 3.1.x is not supported.\n"
],
"warningMessages": [
"Parameter definition is incomplete for GET /v1/orders.\n"
],
"existHttpApiInfo": {
"httpApiId": "api-xxx",
"name": "test",
"basePath": "/v1",
"description": "",
"versionInfo": {
"enable": true,
"scheme": "Query",
"headerName": "my-version",
"queryName": "myVersion",
"version": "v1"
},
"ingressInfo": {
"sourceId": "",
"ingressClass": "",
"watchNamespace": "",
"environmentInfo": {
"environmentId": ""
},
"k8sClusterInfo": {
"clusterId": ""
},
"overrideIngressIp": true
},
"type": "Rest",
"resourceGroupId": "rg-xxx",
"enabelAuth": true,
"authConfig": {
"authType": "",
"authMode": ""
},
"gatewayId": "",
"modelCategory": "",
"protocols": [
"HTTP"
],
"environments": [
{
"environmentId": "env-xxx",
"backendScene": "SingleService",
"backendType": "Service",
"serviceConfigs": [
{
"gatewayServiceId": "gs-xxx",
"name": "demo-service",
"protocol": "HTTP",
"port": 8080,
"weight": 100,
"version": "v1",
"match": {
"default": true,
"conditions": [
{
"type": "Query",
"key": "color",
"value": "gray",
"operator": "equal"
}
]
},
"serviceId": "svc-xxx"
}
],
"customDomains": [
{
"domainId": "d-xxx",
"name": "www.example.com",
"protocol": "HTTP"
}
],
"name": "test",
"alias": "test",
"gatewayInfo": {
"gatewayId": "gw-xxx",
"name": "test"
},
"deployStatus": "Deployed",
"subDomains": [
{
"domainId": "d-xxx",
"name": "www.example.com",
"protocol": "HTTP",
"networkType": "Internet"
}
]
}
],
"aiProtocols": [
""
],
"deployConfigs": [
{
"environmentId": "env-xxx",
"backendScene": "SingleService",
"autoDeploy": true,
"gatewayId": "gw-xx",
"routeBackend": {
"scene": "Single",
"services": [
{
"serviceId": "service-cq2bmmdlhtgj***",
"name": "item-service",
"protocol": "HTTP",
"port": 0,
"weight": 49,
"version": "v1"
}
]
},
"gatewayInfo": {
"gatewayId": "",
"name": "",
"vpcInfo": {
"vpcId": "",
"name": ""
},
"engineVersion": ""
},
"mock": {
"enable": false,
"responseCode": 200,
"responseContent": ""
},
"gatewayType": "API",
"customDomainIds": [
"d-xxx"
],
"serviceConfigs": [
{
"serviceId": "svc-xxx",
"weight": 100,
"modelNamePattern": "qwen-*",
"modelName": "qwen-max",
"intentCode": "",
"match": {
"default": true,
"conditions": [
{
"type": "Query",
"key": "color",
"value": "gray",
"operator": "equal"
}
]
}
}
],
"policyConfigs": [
{
"type": "AiFallback",
"enable": true,
"aiFallbackConfig": {
"serviceConfigs": [
{
"serviceId": "",
"targetModelName": ""
}
]
},
"aiSecurityGuardConfig": {
"serviceAddress": "",
"checkRequest": true,
"checkResponse": true,
"checkRequestImage": true,
"checkResponseImage": true,
"requestCheckService": "",
"responseCheckService": "",
"requestImageCheckService": "",
"responseImageCheckService": "",
"riskAlertLevel": "",
"riskConfig": [
{
"type": "",
"level": "",
"consumerRules": {
"pattern": "",
"matchType": ""
}
}
],
"bufferLimit": 0,
"consumerRequestCheckService": [
{
"name": "",
"requestCheckService": "",
"requestImageCheckService": "",
"matchType": "",
"modalityType": ""
}
],
"consumerResponseCheckService": [
{
"name": "",
"responseCheckService": "",
"responseImageCheckService": "",
"matchType": "",
"modalityType": ""
}
],
"consumerRiskLevel": [
{
"name": "",
"matchType": "",
"type": "",
"level": ""
}
]
},
"aiTokenRateLimitConfig": {
"rules": [
{
"limitType": "",
"matchKey": "",
"matchType": "",
"matchValue": "",
"limitMode": "",
"limitValue": 0
}
],
"globalRules": [
{
"limitType": "",
"matchKey": "",
"matchType": "",
"matchValue": "",
"limitMode": "",
"limitValue": 0
}
],
"enableGlobalRules": true
}
}
],
"customDomainInfos": [
{
"domainId": "",
"name": "",
"protocol": ""
}
],
"subDomains": [
{
"domainId": "",
"name": "",
"protocol": "",
"networkType": ""
}
]
}
],
"deployCntMap": {
"key": {
"deployedCnt": 0,
"Cnt": 0
}
},
"agentProtocols": [
""
]
}
}
}
}Error codes
For a list of error codes, visit the Service error codes.
Change history
| Change time | Summary of changes | Operation |
|---|---|---|
| 2025-08-13 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
| 2025-08-12 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
| 2025-04-25 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
