Updated on 2025-08-20 GMT+08:00

Querying Job Execution Status

Function

This API is used to query the execution status of an asynchronous job.

After an asynchronous job is issued, for example, creating or deleting an ECS, performing operations on ECSs in a batch, or performing operations on ECS NICs, a job ID (job_id) will be returned, based on which you can query the execution status of the job.

For details about how to obtain job_id, see Responses (Task).

URI

GET /v1/{project_id}/jobs/{job_id}

Table 1 describes the parameters in the URI.
Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

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

job_id

Yes

Specifies the ID of an asynchronous job.

Request

None

Response

Table 2 describes the response parameters.
Table 2 Response parameters

Parameter

Type

Description

status

String

Specifies the job status.

  • SUCCESS: The job is successfully executed.
  • RUNNING: The job is in progress.
  • FAIL: The job failed.
  • INIT: The job is being initialized.
  • PENDING_PAYMENT: indicates a yearly/monthly order is pending payment.
    NOTE:

    The PENDING_PAYMENT status is displayed after the request for creating a yearly/monthly ECS or modifying the specifications of a yearly/monthly ECS has been submitted and before the order is paid. If the order is canceled, the status will not be automatically updated. The job will be automatically deleted 14 days later.

entities

Object

Specifies the object of the job.

The value of this parameter varies depending on the type of the job. If the job is an ECS-related operation, the value is server_id. If the job is a NIC operation, the value is nic_id. If a sub-Job is available, details about the sub-job are displayed.

For details, see Table 3.

job_id

String

Specifies the ID of an asynchronous job.

job_type

String

Specifies the type of an asynchronous job.

begin_time

String

Specifies the time when the job was started.

end_time

String

Specifies the time when the job was finished.

error_code

String

Specifies the returned error code when the job execution fails.

After the job is executed successfully, the value of this parameter is null.

fail_reason

String

Specifies the cause of the job execution failure.

After the job is executed successfully, the value of this parameter is null.

message

String

Specifies the error message returned when an error occurs in the request to query a job.

code

String

Specifies the error code returned when an error occurs in the request to query a job.

For details about the error code, see Returned Values for General Requests.

Table 3 entities field description

Parameter

Type

Description

server_id

String

If the job is an ECS-related operation, the value is server_id.

nic_id

String

If the job is a NIC-related operation, the value is nic_id.

sub_jobs_total

Integer

Specifies the number of sub-jobs.

sub_jobs

Array of objects

Specifies the execution information of a sub-job.

For details, see Table 4.

Table 4 sub_jobs field description

Parameter

Type

Description

status

String

Specifies the job status.

  • SUCCESS: indicates the job is successfully executed.
  • RUNNING: indicates that the job is in progress.
  • FAIL: indicates that the job failed.
  • INIT: indicates that the job is being initialized.

entities

Object

Specifies the object of the job. The value of this parameter varies depending on the type of the job. If the job is an ECS-related operation, the value is server_id. If the job is a NIC operation, the value is nic_id. For details, see Table 5.

job_id

String

Specifies the sub-job ID.

job_type

String

Specify the sub-job type.

begin_time

String

Specifies the time when the job was started.

end_time

String

Specifies the time when the job was finished.

error_code

String

Specifies the returned error code when the job execution fails.

After the job is executed successfully, the value of this parameter is null.

fail_reason

String

Specifies the cause of the job execution failure.

After the job is executed successfully, the value of this parameter is null.

Table 5 sub_jobs.entities field description

Parameter

Type

Description

server_id

String

If the job is an ECS-related operation, the value is server_id.

nic_id

String

If the job is a NIC-related operation, the value is nic_id.

errorcode_message

String

Indicates the cause of a sub-job execution failure.

Example Request

Query the execution status of a specified asynchronous job.

GET https://{endpoint}/v1/{project_id}/jobs/{job_id}

Example Response

{
    "status": "SUCCESS",
    "entities": {
        "sub_jobs_total": 1,
        "sub_jobs": [
            {
                "status": "SUCCESS",
                "entities": {
                    "server_id": "bae51750-0089-41a1-9b18-5c777978ff6d"
                },
                "job_id": "2c9eb2c5544cbf6101544f0635672b60",
                "job_type": "createSingleServer",
                "begin_time": "2016-04-25T20:04:47.591Z",
                "end_time": "2016-04-25T20:08:21.328Z",
                "error_code": null,
                "fail_reason": null
            }
        ]
    },
    "job_id": "2c9eb2c5544cbf6101544f0602af2b4f",
    "job_type": "createServer",
    "begin_time": "2016-04-25T20:04:34.604Z",
    "end_time": "2016-04-25T20:08:41.593Z",
    "error_code": null,
    "fail_reason": null
}

Error Codes

See Error Codes.