Help Center> ImageSearch> API Reference> APIs> Creating an Instance
Updated on 2023-12-13 GMT+08:00

Creating an Instance

Function

You can use the API to create an instance. An image library is created in the instance to store image features.

URI

POST /v1/{project_id}/service

Table 1 Path parameters

Name

Mandatory

Type

Description

project_id

Yes

String

Project ID. See Obtaining a Project ID and Name.

Request Message

Table 2 Request header parameters

Name

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token

Used to obtain the permission to call APIs. For details about how to obtain the token, see Authentication. The value of X-Subject-Token in the response header is the token.

Table 3 Request body parameters

Name

Mandatory

Type

Description

name

Yes

String

Instance name

  • Only lowercase letters, digits, hyphens (-), and underscores (_) are allowed.
  • The value starts with a letter and contains a maximum of 16 characters.

model

Yes

String

Model name. The following model names are supported: - common-search: searches for images of similar content or categories in the image library.

description

No

String

Instance description

level

No

Integer

Image quantity of an instance. The default value is 30000000. Currently, only the default specifications are supported.

tags

No

Array of strings

Custom image tag. Each instance supports a maximum of 10 tags. Custom tags cannot contain uppercase letters.

Response Parameters

Status code: 200

Table 4 Response body parameter

Name

Type

Description

domain

String

Model name or domain name

desc

String

Service instance description

registerDate

Long

Registration time

expiredDate

Long

Expiration time. The value -1 indicates that the instance will never expire.

level

Integer

Specifications, that is, the image quantity of an instance. The default value is 30000000.

tags

Array of strings

Custom image tag.

status

String

Instance status. Available enumeration values are as follows:

  • NORMAL
  • ARREARAGE
  • CREATION
  • CREATION_FAILD
  • DELETING
  • DELETING_FAILED
  • ABNORMAL

instanceName

String

Instance name

Status code: 400

Table 5 Response body parameter

Name

Type

Description

error_code

String

Error code of a failed API call. For details, see Error Codes.

This parameter is not included when the API is successfully called.

error_msg

String

Error message when the API call fails.

This parameter is not included when the API is successfully called.

Example Requests

Create an instance named test_instance and set the model name to "General image search".

POST https://{endpoint}/v1/{project_id}/service

{
  "name" : "test_instance",
  "model" : "common-search",
  "description" : "register service for user model test.",
  "level" : 30000000,
  "tags" : [ "tag1", "tag2" ]
}

Example Response

Status code: 200

Example of a successful response

{
  "instanceName" : "test_instance ",
  "level" : 30000000,
  "expiredDate" : -1,
  "domain" : "model description",
  "desc" : "register service for user model test.",
  "registerDate" : 1528203334203,
  "tags" : [ "tag1", "tag2" ],
  "status" : "NORMAL"
}

Status code: 400

Example of a failed response

{
  "error_code" : "IS.3000",
  "error_msg" : "TInstance name is already exists."
}

Status Code

Status Code

Description

200

Successful response

400

Failed response

Error Code

For details, see Error Codes.