# 工作流作业的 REST API 终结点

使用 REST API 与工作流 GitHub Actions作业进行交互。

## 关于 GitHub Actions 中的工作流作业

可以使用 REST API 查看日志和工作流作业。GitHub Actions

工作流程作业是在同一运行服务器上执行的一组步骤。 有关详细信息，请参阅 [GitHub Actions 的工作流语法](/zh/enterprise-server@3.22/actions/reference/workflows-and-actions/workflow-syntax)。

> \[!NOTE]
> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.

## Get a job for a workflow run

```
GET /repos/{owner}/{repo}/actions/jobs/{job_id}
```

Gets a specific job in a workflow run.
Anyone with read access to the repository can use this endpoint.
If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`job_id`** (integer) (required)
  The unique identifier of the job.

### HTTP response status codes

* **200** - OK

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/jobs/JOB_ID
```

**Response schema (Status: 200):**

* `id`: required, integer
* `run_id`: required, integer
* `run_url`: required, string
* `run_attempt`: integer
* `node_id`: required, string
* `head_sha`: required, string
* `url`: required, string
* `html_url`: required, string or null
* `status`: required, string, enum: `queued`, `in_progress`, `completed`, `waiting`, `requested`, `pending`
* `conclusion`: required, string or null, enum: `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, `action_required`, `null`
* `created_at`: required, string, format: date-time
* `started_at`: required, string, format: date-time
* `completed_at`: required, string or null, format: date-time
* `name`: required, string
* `steps`: array of objects:
  * `status`: required, string, enum: `queued`, `in_progress`, `completed`
  * `conclusion`: required, string or null
  * `name`: required, string
  * `number`: required, integer
  * `started_at`: string or null, format: date-time
  * `completed_at`: string or null, format: date-time
* `check_run_url`: required, string
* `labels`: required, array of string
* `runner_id`: required, integer or null
* `runner_name`: required, string or null
* `runner_group_id`: required, integer or null
* `runner_group_name`: required, string or null
* `workflow_name`: required, string or null
* `head_branch`: required, string or null

## Download job logs for a workflow run

```
GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs
```

Gets a redirect URL to download a plain text file of logs for a workflow job. This link expires after 1 minute. Look
for Location: in the response header to find the URL for the download.
Anyone with read access to the repository can use this endpoint.
If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`job_id`** (integer) (required)
  The unique identifier of the job.

### HTTP response status codes

* **302** - Found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/jobs/JOB_ID/logs
```

**Response schema (Status: 302):**

## List jobs for a workflow run attempt

```
GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs
```

Lists jobs for a specific workflow run attempt. You can use parameters to narrow the list of results. For more information
about using parameters, see Parameters.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint  with a private repository.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`run_id`** (integer) (required)
  The unique identifier of the workflow run.

* **`attempt_number`** (integer) (required)
  The attempt number of the workflow run.

* **`per_page`** (integer)
  The number of results per page (max 100). For more information, see "Using pagination in the REST API."
  Default: `30`

* **`page`** (integer)
  The page number of the results to fetch. For more information, see "Using pagination in the REST API."
  Default: `1`

### HTTP response status codes

* **200** - OK

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/runs/RUN_ID/attempts/ATTEMPT_NUMBER/jobs
```

**Response schema (Status: 200):**

* `total_count`: required, integer
* `jobs`: required, array of `Job`:
  * `id`: required, integer
  * `run_id`: required, integer
  * `run_url`: required, string
  * `run_attempt`: integer
  * `node_id`: required, string
  * `head_sha`: required, string
  * `url`: required, string
  * `html_url`: required, string or null
  * `status`: required, string, enum: `queued`, `in_progress`, `completed`, `waiting`, `requested`, `pending`
  * `conclusion`: required, string or null, enum: `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, `action_required`, `null`
  * `created_at`: required, string, format: date-time
  * `started_at`: required, string, format: date-time
  * `completed_at`: required, string or null, format: date-time
  * `name`: required, string
  * `steps`: array of objects:
    * `status`: required, string, enum: `queued`, `in_progress`, `completed`
    * `conclusion`: required, string or null
    * `name`: required, string
    * `number`: required, integer
    * `started_at`: string or null, format: date-time
    * `completed_at`: string or null, format: date-time
  * `check_run_url`: required, string
  * `labels`: required, array of string
  * `runner_id`: required, integer or null
  * `runner_name`: required, string or null
  * `runner_group_id`: required, integer or null
  * `runner_group_name`: required, string or null
  * `workflow_name`: required, string or null
  * `head_branch`: required, string or null

## List jobs for a workflow run

```
GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs
```

Lists jobs for a workflow run. You can use parameters to narrow the list of results. For more information
about using parameters, see Parameters.
Anyone with read access to the repository can use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`run_id`** (integer) (required)
  The unique identifier of the workflow run.

* **`filter`** (string)
  Filters jobs by their completed\_at timestamp. latest returns jobs from the most recent execution of the workflow run. all returns all jobs for a workflow run, including from old executions of the workflow run.
  Default: `latest`
  Can be one of: `latest`, `all`

* **`per_page`** (integer)
  The number of results per page (max 100). For more information, see "Using pagination in the REST API."
  Default: `30`

* **`page`** (integer)
  The page number of the results to fetch. For more information, see "Using pagination in the REST API."
  Default: `1`

### HTTP response status codes

* **200** - OK

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/actions/runs/RUN_ID/jobs
```

**Response schema (Status: 200):**

Same response schema as [List jobs for a workflow run attempt](#list-jobs-for-a-workflow-run-attempt).