Updated on 2025-12-25 GMT+08:00

Creating a Graph (2.2.2)

Function

This API is used to create a graph.

URI

POST /v2/{project_id}/graphs

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain up to 64 characters. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. It is used to obtain the permission to call APIs. For how to obtain the token, see Authentication. (The token is the value of X-Subject-Token in the response header.)

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameter

Parameter

Mandatory

Type

Description

graph

Yes

graph object

Definition

Graph type.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 graph

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

Graph name.

Constraints

The value must contain 4 to 50 characters and must start with a letter. Only letters, digits, and underscores (_) are allowed.

Range

N/A

Default Value

N/A

graph_size_type_index

Yes

String

Definition

Graph size type.

Constraints

N/A

Range

  • 0: Ten-thousand-edge
  • 1: Million-edge
  • 2: Ten-million-edge
  • 3: Hundred-million-edge
  • 4: Billion-edge
  • 5: Ten-billion-edge
  • 6: Hundred-billion-edge
  • 401: Billion-edge-pro

Default Value

N/A

arch

No

String

Definition

CPU architecture of a graph instance.

Constraints

N/A

Range

  • x86_64: x86 64-bit architecture
  • aarch64: Arm 64-bit architecture

Default Value

x86_64

vpc_id

Yes

String

Definition

VPC ID.

Constraints

N/A

Range

N/A

Default Value

N/A

subnet_id

Yes

String

Definition

Subnet ID in the VPC.

Constraints

N/A

Range

N/A

Default Value

N/A

security_group_id

Yes

String

Definition

Security group ID.

Constraints

N/A

Range

N/A

Default Value

N/A

public_ip

No

public_ip object

Definition

Public IP address. If unspecified, a public connection will not be used by default.

Constraints

N/A

Range

N/A

Default Value

N/A

enable_multi_az

No

Boolean

Definition

Whether the graph supports cross-AZ deployment.

Constraints

N/A

Range

  • true: The ECSs in the graph are deployed across two AZs.
  • false: The ECSs in the graph are deployed in a single AZ.

Default Value

false

sys_tags

No

Array of sys_tags objects

Definition

Enterprise project information.

Constraints

N/A

Range

N/A

Default Value

N/A

tags

No

Array of tags objects

Definition

Whether to support TMS for cost allocation.

Constraints

N/A

Range

N/A

Default Value

N/A

enable_rbac

No

Boolean

Definition

Whether to enable fine-grained permission control for the graph.

If set to true, all users will have no permissions by default after the graph is created. Access to the graph can only be granted by calling the service-plane fine-grained permission control API to authorize specific operations or users.

Constraints

N/A

Range

  • true: enabled.
  • false: disabled.

Default Value

false

enable_full_text_index

No

Boolean

Definition

Whether to enable full-text indexing control for the graph.

If set to true, full-text indexes are available for Billion-edge-pro graphs, and a Cloud Search Service (CSS) cluster will be created when you create a graph.

Constraints

N/A

Range

  • true: enabled.
  • false: disabled.

Default Value

false

enable_hyg

No

Boolean

Definition

Whether to enable HyG for the graph. This parameter is available only for database edition graphs.

Constraints

N/A

Range

N/A

Default Value

N/A

crypt_algorithm

No

String

Definition

Cryptographic algorithm of a graph instance.

Constraints

N/A

Range

  • generalCipher: Chinese cryptographic algorithm.
  • SMcompatible: Commercial cryptographic algorithm (compatible with international ones).

Default Value

N/A

enable_https

No

Boolean

Definition

Whether the security mode is enabled. Enabling the security mode will have a significant impact on performance.

Constraints

N/A

Range

  • true: enabled.
  • false: disabled.

Default Value

true

product_type

No

String

Definition

Graph product type.

Constraints

N/A

Range

  • InMemory: memory edition.
  • Persistence: database edition.

Default Value

The default value is Persistence when graph_size_type_index is 6.

vertex_id_type

No

vertex_id_type object

Definition

ID type of a vertex.

Constraints

This parameter is mandatory only for database edition graphs.

The vertex ID type cannot be changed once set. Exercise caution when setting this parameter.

Range

N/A

Default Value

N/A

capacity_ratio

No

Integer

Definition

Capacity rate of a graph.

Constraints

This parameter is only available for Ten-billion-edge graphs of the database edition since version 2.3.18.

Range

N/A

Default Value

N/A

is_dynamic_graph

No

Boolean

Definition

Whether a graph is a dynamic one.

Constraints

N/A

Range

N/A

Default Value

N/A

sort_key_type

No

String

Definition

Type of the sort key for a database edition graph. Different sort key values are configured to distinguish duplicate edges (edges with the same source vertex, end vertex, and label).

Constraints

This parameter is mandatory only for database edition graphs.

Range

  • int: an integer.
  • string: a string of less than 40 bytes.
  • varString: The length is not limited. However, if the value is too long, the read and write performance is affected. It is recommended that the length be within 1 KB bytes, with a maximum of 2 KB bytes.

Default Value

N/A

Table 5 public_ip

Parameter

Mandatory

Type

Description

public_bind_type

No

String

Definition

EIP binding type.

Constraints

N/A

Range

  • auto_assign
  • bind_existing

Default Value

N/A

eip_id

No

String

Definition

ID of an EIP. When publicBindType is set to bind_existing, the value is the ID of a user's existing EIP that has been created but not yet bound. When publicBindType is set to auto_assign, this value should be left empty.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 6 sys_tags

Parameter

Mandatory

Type

Description

key

No

String

Definition

Key of an enterprise project. The value is _sys_enterprise_project_id.

Constraints

N/A

Range

N/A

Default Value

N/A

value

No

String

Definition

Enterprise project ID. You can obtain it from the enterprise project.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 7 tags

Parameter

Mandatory

Type

Description

key

No

String

Definition

Tag key.

Constraints

N/A

Range

N/A

Default Value

N/A

value

No

String

Definition

Tag value.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 8 vertex_id_type

Parameter

Mandatory

Type

Description

id_type

Yes

String

Definition

ID type.

Constraints

When creating a HyG graph, id_type can only be fixedLengthString.

Range

  • fixedLengthString: In the variable length string format, vertex IDs are used for internal storage and compute. Specify the length limit. If the IDs are too long, the query performance can be reduced. Specify the length limit based on your dataset vertex IDs. If you cannot determine the maximum length, set the ID type to hash.
  • varString: In the variable length string format, the length of the vertex IDs written by the user is not limited. However, if the IDs are too long, the read and write performance is affected. It is recommended that the length be within 1 KB, with a maximum of 4 KB.
  • hash: Vertex IDs are converted into hash code for storage and compute. There is no limit on the ID length. However, there is an extremely low probability, approximately 10^(-43), that the vertex IDs will conflict. If you cannot determine the maximum length of a vertex ID, set this parameter to Hash.

Default Value

N/A

id_length

No

Integer

Definition

ID length.

Constraints

This parameter is mandatory when id_type is fixedLengthString.

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 9 Response body parameters

Parameter

Type

Description

id

String

Definition

Graph ID.

Range

N/A

name

String

Definition

Graph name.

Range

N/A

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

error_msg

String

Definition

System prompt.

  • If the execution succeeds, this parameter may be left blank.
  • If the execution fails, this parameter is used to display the error message.

Range

N/A

error_code

String

Definition

System prompt.

  • If the execution succeeds, this parameter may be left blank.
  • If the execution fails, this parameter is used to display the error code.

Range

N/A

Example Request

Create a graph. The graph name is demo, the graph size is Million-edge, the graph instance CPU architecture type is x86 64-bit, the VPC ID is 2d8af840-fd57-4e3b-a8f1-cda0f55ccd99, the subnet ID is dc018ec3-67d1-46c9-b2fc-19d83367f4e2, and the security group ID is 11d27338-8649-4076-8579-5ebc1a60f79e.

POST https://{Endpoint}/v2/{project_id}/graphs

{
  "graph" : {
    "name" : "demo",
    "graph_size_type_index" : "1",
    "arch" : "x86_64",
    "vpc_id" : "2d8af840-fd57-4e3b-a8f1-cda0f55ccd99",
    "subnet_id" : "dc018ec3-67d1-46c9-b2fc-19d83367f4e2",
    "security_group_id" : "11d27338-8649-4076-8579-5ebc1a60f79e",
    "public_ip" : {
      "public_bind_type" : "bind_existing",
      "eip_id" : "30ef2d58-08a9-4481-b526-b2cbe67d020d"
    },
    "enable_multi_az" : false,
    "sys_tags" : [ {
      "key" : "_sys_enterprise_project_id",
      "value" : "54c0b33c-8627-462f-948e-bae08c0887b4"
    } ],
    "crypt_algorithm" : "generalCipher",
    "enable_https" : false
  }
}

Example Response

Status code: 200

Example response for a successful request

{
  "id" : "f1529b88-c958-493e-8452-fccfe932cde1",
  "name" : "demo"
}

Status code: 400

Example response for a failed request

{
  "error_code" : "GES.7016",
  "error_msg" : "The parameter [subnetId] is not exist."
}

Status Codes

Return Value

Description

400 Bad Request

Request error.

401 Unauthorized

Authorization failed.

403 Forbidden

No operation permissions.

404 Not Found

No resources found.

500 Internal Server Error

Internal server error.

503 Service Unavailable

Service unavailable.