Help Center/ ModelArts/ API Reference/ Resource Management/ Creating Network Resources
Updated on 2025-11-19 GMT+08:00

Creating Network Resources

Function

This API is used to create network resources in a system. This API is used when you need to create network resources, such as virtual networks, subnets, or routes, when you need to expand services, plan resources, or adjust the network architecture. Before using this API, ensure that you have the administrator permission and the system has sufficient resources to create network resources. After the creation, the network resources will be added to the system for future service configurations. If you do not have the required permission, the resources are insufficient, or the input parameter is incorrect, the API will return an error message.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST /v1/{project_id}/networks

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition: User project ID. For details, see Obtaining a Project ID and Name.

Constraints: The value can contain 1 to 64 characters. Letters, digits, and hyphens (-) are allowed.

Range: N/A

Default Value: N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

apiVersion

Yes

String

Definition: API version.

Constraints: N/A

Range:

  • v1

Default Value: N/A

kind

Yes

String

Definition: Resource type.

Constraints: N/A

Range:

  • Network

Default Value: N/A

metadata

Yes

NetworkMetadataCreation object

Definition: Metadata of a network resource.

Constraints: N/A

spec

Yes

NetworkSpec object

Definition: Description of a network resource.

Constraints: N/A

Table 3 NetworkMetadataCreation

Parameter

Mandatory

Type

Description

labels

Yes

NetworkMetadataLabels object

Definition: Network resource tags.

Constraints: N/A

Table 4 NetworkMetadataLabels

Parameter

Mandatory

Type

Description

os.modelarts/name

Yes

String

Definition: Displayed name of a resource pool.

*Range: The value can contain 4 to 32 characters. It must start with a lowercase letter and cannot end with a hyphen (-). Digits and hyphens (-) are allowed.

os.modelarts/workspace.id

No

String

Definition: Workspace ID. [For details about how to obtain the ID, see Querying the Workspace List.] (tag:hc)

Range: N/A

Table 5 NetworkSpec

Parameter

Mandatory

Type

Description

cidr

Yes

String

Definition: CIDR value of a network.

Range

  • 172.16.0.0/12 to 172.16.0.0/24

  • 192.168.0.0/16 to 192.168.0.0/24

connection

No

NetworkConnection object

Definition: Connection information between the current network and other resources.

Table 6 NetworkConnection

Parameter

Mandatory

Type

Description

peerConnectionList

No

Array of objects

Definition: Peering connections.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

apiVersion

String

Definition: API version of the resource.

Range:

  • v1: The current resource version is v1.

kind

String

Definition: Resource type.

Range:

  • Network

metadata

NetworkMetadata object

Definition: Metadata of a network resource.

spec

NetworkSpec object

Definition: Specifications of a network resource.

status

NetworkStatus object

Definition: Status of a network resource.

Table 8 NetworkMetadata

Parameter

Type

Description

name

String

Definition: Network resource ID.

Range: N/A

creationTimestamp

String

Definition: Network creation time. For example, 2025-11-01T03:49:41Z.

Range: N/A

labels

NetworkMetadataLabels object

Definition: Network labels.

annotations

NetworkMetadataAnnotations object

Definition: Network annotations.

Table 9 NetworkMetadataLabels

Parameter

Type

Description

os.modelarts/name

String

Definition: Displayed name of a resource pool.

*Range: The value can contain 4 to 32 characters. It must start with a lowercase letter and cannot end with a hyphen (-). Digits and hyphens (-) are allowed.

os.modelarts/workspace.id

String

Definition: Workspace ID. [For details about how to obtain the ID, see Querying the Workspace List.] (tag:hc)

Range: N/A

Table 10 NetworkMetadataAnnotations

Parameter

Type

Description

os.modelarts/description

String

Definition: Network description.

Range: The value cannot contain these characters: !<>=&"'.

Table 11 NetworkSpec

Parameter

Type

Description

cidr

String

Definition: CIDR value of a network.

Range

  • 172.16.0.0/12 to 172.16.0.0/24

  • 192.168.0.0/16 to 192.168.0.0/24

connection

NetworkConnection object

Definition: Connection information between the current network and other resources.

Table 12 NetworkConnection

Parameter

Type

Description

peerConnectionList

Array of objects

Definition: Peering connections.

Table 13 NetworkStatus

Parameter

Type

Description

phase

String

Definition: Current status of a network resource.

Range:

  • Creating: The network is being created.

  • Active: The network is functional.

  • Abnormal: The network is abnormal.

connectionStatus

NetworkConnectionStatus object

Definition: Connection status between the network and other cloud services.

Table 14 NetworkConnectionStatus

Parameter

Type

Description

peerConnectionStatus

Array of PeerConnectionStatus objects

Definition: Status of peering connections.

sfsTurboStatus

Array of SfsTurboConnectionStatus objects

Definition: Status of SFS Turbo accessible to the network.

Table 15 PeerConnectionStatus

Parameter

Type

Description

peerVpcId

String

Definition: VPC ID of the peer end.

Range: N/A

peerSubnetId

String

Definition: Subnet ID of the peer end.

Range: N/A

defaultGateWay

Boolean

Definition: Specifies whether to create a default route.

Range: false (default value, indicating that no default route is created)

phase

String

Definition: Connection status of the network.

Range:

  • Connecting: The network is being connected.

  • Active: The network is connected properly.

  • Abnormal: The network connection is abnormal.

Table 16 SfsTurboConnectionStatus

Parameter

Type

Description

name

String

Definition: Name of the SFS Turbo instance.

Range: N/A

sfsId

String

Definition: ID of the SFS Turbo instance.

Range: N/A

connectionType

String

Definition: association mode.

Range:

  • VpcPort: passthrough through attached NICs

  • Peering: connection through VPC peering

ipAddr

String

Definition: Access address of SFS Turbo.

Range: N/A

status

String

Definition: Connection status of SFS Turbo.

Range:

  • Active: The SFS connection is normal.

  • Abnormal: The SFS connection is abnormal.

  • Creating: The SFS connection is being set up.

  • Deleting: The SFS connection is being deleted.

Status code: 400

Table 17 Response body parameters

Parameter

Type

Description

error_code

String

  • Definition: ModelArts error code.

Range: N/A

error_msg

String

Definition: Error message.

Range: N/A

Example Requests

The following is an example of how to create a network whose resource type is Network, network name is network-7a03, and CIDR block is 192.168.128.0/17.

POST {endpoint}/v1/{project_id}/networks

{
  "apiVersion" : "v1",
  "kind" : "Network",
  "metadata" : {
    "labels" : {
      "os.modelarts/name" : "network-7a03",
      "os.modelarts/workspace.id" : "0"
    }
  },
  "spec" : {
    "cidr" : "192.168.128.0/17"
  }
}

Example Responses

Status code: 200

OK

{
  "kind" : "Network",
  "apiVersion" : "v1",
  "metadata" : {
    "name" : "network-7a03-86c13962597848eeb29c5861153a391f",
    "creationTimestamp" : "2022-09-16T09:44:59Z",
    "labels" : {
      "os.modelarts/name" : "network-7a03",
      "os.modelarts/workspace.id" : "0"
    },
    "annotations" : { }
  },
  "spec" : {
    "cidr" : "192.168.128.0/17",
    "connection" : { }
  },
  "status" : {
    "phase" : ""
  }
}

Status code: 400

Bad request.

{
  "error_code" : "ModelArts.50004000",
  "error_msg" : "Bad request."
}

Status Codes

Status Code

Description

200

OK

400

Bad request.

Error Codes

See Error Codes.