# API xử lý Bulk

Tạo và điều khiển tập tin dựa trên YouTube làm việc, rồi lấy lại bản kê khai và kết quả là các bộ phận.

Tài liệu tham khảo chính điển: https://flashdata.dev/vi/docs/reference/bulk-processing
Xem lại: 2026-11-05 by FlashData

<a id="playground"></a>

## Sân thử API

Chọn một nguồn và sao chép một nguồn đầy đủ Python hay Bash Dòng chảy công việc, một yêu cầu đơn hoặc một phản ứng mẫu. Mã xem thử sân chơi; nó không gửi công việc. Toàn bộ lưu lượng công việc xử lý việc tải lên, kiểm tra trạng thái và thu hồi lại mọi kết quả.

- [Yêu cầu xác thực và tập tin](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#prepare)
- [Duyệt điểm kết thúc](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#endpoints)
- [Batch hay Bulk?](https://flashdata.dev/vi/docs/reference/batch-and-bulk/reference.md)

<a id="endpoints"></a>

## Điểm kết thúc

Mọi điểm kết thúc được dùng https://api.flashdata.dev/v2. Tạo một công việc  đờn bà tải lên videoID Tập tin _BAR_bắt đầu màn hình _BAR_ tiềm năng truy cập vào bản kê khai và mọi kết quả.

| Phương pháp | Đường dẫn | Hành động |
| --- | --- | --- |
| POST | /v2/bulk-jobs | Tạo một Bulk công việc |
| POST | /v2/bulk-jobs/{bulkId}/start | Tải lên và bắt đầu |
| GET | /v2/bulk-jobs/{bulkId} | Lấy trạng thái công việc |
| GET | /v2/bulk-jobs | Liệt kê các tác vụ |
| POST | /v2/bulk-jobs/{bulkId}/pause | Tạm dừng một công việc |
| PATCH | /v2/bulk-jobs/{bulkId} | Cập nhật tùy chọn công việc |
| POST | /v2/bulk-jobs/{bulkId}/resume | Tiếp tục công việc |
| DELETE | /v2/bulk-jobs/{bulkId} | Hủy bỏ công việc |
| GET | /v2/bulk-jobs/{bulkId}/results | Lấy bản kê kết quả |
| GET | /v2/bulk-jobs/{bulkId}/results/{partNumber} | Tải về các phần kết quả |

- [Batch hay Bulk?](https://flashdata.dev/vi/docs/reference/batch-and-bulk/reference.md)
- [Cuối cùng đến cuối Bulk Hướng dẫn](https://flashdata.dev/vi/docs/guides/bulk/reference.md)
- [Đặc tả OpenAPI](https://flashdata.dev/docs/openapi.json)

<a id="prepare"></a>

## Xác thực và nhập

Đặt FLASHDATA_API_KEY tới một phím có quyền truy cập vào nguồn đã chọn. Dùng lại cùng một chìa khóa và tài khoản cho sự sáng tạo, điều khiển và kết quả. Tiến trình xử lý sử dụng sự số dư của tài khoản và giá cả bình thường cho mỗi nguồn. YouTube Download yêu cầu quyền truy cập và options.storage.

Tạo một thư mục làm việc tên là ob-api / và chạy các ví dụ từ nó. Sân chơi đã hoàn tất Python Dòng chảy công việc sử dụng Python 3.10+ thư viện chuẩn; cá nhân Python Ví dụ điểm cuối bên dưới cần thiết yêu cầu; cURL ví dụ dùng Bash, cURL 7.76+, jq và g tiêu. Chọn một ngôn ngữ cho mỗi hành động để bạn không tạo hoặc bắt đầu làm việc lặp lại.

Nhập là một UTF-8 Tập tin có một 11- Hồ sơ. YouTube ID mỗi dòng, lên đến 2 GiB. Sử dụng IDs, không phải URLs. Gỡ bỏ bản sao IDs trước khi tải lên; lặp lại IDs được xử lý riêng biệt.

| Nguồn | Tùy chọn chia sẻ |
| --- | --- |
| youtube_metadata | include_formats, include_chapters |
| youtube_transcript | ngôn ngữ, tự động |
| youtube_captions | ngôn ngữ, tự động |
| youtube_trainability | tuỳ chọn |
| youtube_download | Tùy chọn phương tiện và đích lưu trữ |

### Phụ thuộc Python

```bash
python -m pip install requests
```

- [API phím và đầu đề](https://flashdata.dev/vi/docs/guides/headers-and-authentication/reference.md)
- [Name](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#storage)

<a id="request-body"></a>

## Tạo trường cầu xin

| Tìm kiếm | Kiểu | Sử dụng |
| --- | --- | --- |
| source | string | Yêu cầu. Một nguồn hỗ trợ cho mỗi dữ liệu ID. |
| options | object | Tùy chọn nguồn chia sẻ. Nguồn dữ liệu có thể đặt result_storage; YouTube Download yêu cầu lưu trữ. |
| callback_url | string | Công chúng tùy chọn HTTPS Gọi lại sau. Gửi sau khi xuất bản xong. |

- [Yêu cầu đầy đủ](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-CreateBulkJobRequest)
- [Giữ móc câu](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#webhooks)

<a id="createBulkJob"></a>

## Tạo một Bulk công việc

Tạo một công việc, tải lên một UTF-8 Tập tin văn bản có một 11- Hồ sơ. YouTube video ID mỗi dòng upload.hrefsau đó gọi cho bắt đầu. Tự tạo ra công việc không bắt đầu xử lý.

Name video-ids.txt và cứu lấy 201 Biên nhận cho bulk-created.json. Giữ biên lai riêng tư và sử dụng lại job.id cho mỗi yêu cầu sau này. Tạo ra một công việc để lại nó trong awaiting_upload; tải lên URL Comment 15 phút

### Điểm kết thúc

```http
POST https://api.flashdata.dev/v2/bulk-jobs
X-API-Key: YOUR_API_KEY
```

### Python

Lưu bulk_create.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### bulk_create.py

```python
import json
import os
from pathlib import Path

import requests

os.umask(0o077)
Path("video-ids.txt").write_bytes(b"jNQXAC9IVRw\ndQw4w9WgXcQ\n")
response = requests.post(
    "https://api.flashdata.dev/v2/bulk-jobs",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    json={"source": "youtube_metadata", "options": {"include_formats": False}},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
receipt = response.json()
Path("bulk-created.json").write_text(json.dumps(receipt, indent=2), encoding="utf-8")
print(json.dumps(receipt["job"], indent=2))
```

#### Chạy từ con số lớn

```bash
python bulk_create.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
umask 077
printf '%s\n' 'jNQXAC9IVRw' 'dQw4w9WgXcQ' > video-ids.txt
curl --fail-with-body --silent --show-error \
  'https://api.flashdata.dev/v2/bulk-jobs' \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data '{"source":"youtube_metadata","options":{"include_formats":false}}' \
  --output bulk-created.json &&
jq '.job | {id, source, status}' bulk-created.json
```


- [CreateBulkJobRequest](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-CreateBulkJobRequest)
- [BulkJobCreated](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobCreated)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="createBulkJob-responses"></a>

### Đáp ứng và yêu cầu

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 201 | Bulk công việc được tạo ra với một 15- Phút trực tiếp tải lên URL |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 422 | Yêu cầu xác thực thất bại |
| 503 | Một quan hệ phụ thuộc hay danh mục cần thiết tạm thời không tồn tại |

#### Nội dung yêu cầu

```json
{
  "$ref": "#/components/schemas/CreateBulkJobRequest"
}
```

#### 201 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobCreated"
}
```


<a id="startBulkJob"></a>

## Tải lên và bắt đầu

Bắt đầu xử lý việc tải lên UTF-8 video ID tập tin, tới 2 GiB (2147483648 byte). Giữ tập tin không thay đổi sau khi bắt đầu.

Đầu PUT video-ids.txt đến biên lai upload.href có upload.contentTypekhông có X-API-Key. Ví dụ gọi điện chỉ khi tải lên thành công. Giữ tập tin tải lên không thay đổi sau đó.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |

### Điểm kết thúc

```http
POST https://api.flashdata.dev/v2/bulk-jobs/{bulkId}/start
X-API-Key: YOUR_API_KEY
```

### Python

Lưu bulk_start.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### bulk_start.py

```python
import json
import os
from pathlib import Path

import requests

receipt = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))
upload = receipt["upload"]
if upload["method"] != "PUT" or not upload["href"].startswith("https://"):
    raise ValueError("Expected an HTTPS PUT upload URL")
# Stream the file to storage without the FlashData key.
with open("video-ids.txt", "rb") as file:
    response = requests.put(
        upload["href"], data=file,
        headers={"Content-Type": upload["contentType"]},
        timeout=300, allow_redirects=False,
    )
    response.raise_for_status()
    if not 200 <= response.status_code < 300:
        raise RuntimeError("Upload did not complete; do not start the job yet")

bulk_id = receipt["job"]["id"]
response = requests.post(
    f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}/start",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
print(json.dumps(response.json()["job"], indent=2))
```

#### Chạy từ con số lớn

```bash
python bulk_start.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
UPLOAD_URL=$(jq -er '.upload.href' bulk-created.json)
CONTENT_TYPE=$(jq -er '.upload.contentType' bulk-created.json)
curl --fail-with-body --silent --show-error --proto '=https' \
  --header "Content-Type: $CONTENT_TYPE" \
  --upload-file video-ids.txt "$UPLOAD_URL" &&
curl --fail-with-body --silent --show-error --request POST \
  "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID/start" \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}"
```


- [BulkJobResponse](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobResponse)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="startBulkJob-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Bulk Công việc bắt đầu hay trạng thái nhận diện hiện tại |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |
| 409 | Tình trạng tài nguyên hoặc xung đột quyền tối thiểu |
| 422 | Yêu cầu xác thực thất bại |
| 503 | Một quan hệ phụ thuộc hay danh mục cần thiết tạm thời không tồn tại |

#### 200 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobResponse"
}
```


<a id="getBulkJob"></a>

## Lấy trạng thái công việc

Đọc job.statusĐầu vào, tính, pauseReason và sai lầm. Kiểm tra lại ID với sự chậm trễ; hoàn tất nghĩa là bản kê khai được xuất bản, chứ không phải mỗi video đều thành công.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |

### Điểm kết thúc

```http
GET https://api.flashdata.dev/v2/bulk-jobs/{bulkId}
X-API-Key: YOUR_API_KEY
```

### Python

Lưu bulk_status.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### bulk_status.py

```python
import json
import os
from pathlib import Path

import requests

bulk_id = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))["job"]["id"]
response = requests.get(
    f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
Path("bulk-job.json").write_text(json.dumps(response.json(), indent=2), encoding="utf-8")
print(json.dumps(response.json()["job"], indent=2))
```

#### Chạy từ con số lớn

```bash
python bulk_status.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
curl --fail-with-body --silent --show-error \
  "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID" \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
  --output bulk-job.json &&
jq '.job | {id, status, counts, pauseReason, error, expiresAt}' bulk-job.json
```


- [BulkJobResponse](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobResponse)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="getBulkJob-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Bulk Tình trạng công việc |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |

#### 200 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobResponse"
}
```


<a id="listBulkJobs"></a>

## Liệt kê các tác vụ

Câu trả lời chứa dữ liệu và sự tạo hình. Qua pagination.nextCursor là tham số truy vấn con chạy tiếp theo cho đến khi nó là null. Dùng giới hạn từ 1 phải 50; mặc định là 20.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| cursor | query | Không bắt buộc · {"type":"string","maxLength":512} |
| limit | query | Không bắt buộc · {"type":"integer","minimum":1,"maximum":50,"default":20} |

### Điểm kết thúc

```http
GET https://api.flashdata.dev/v2/bulk-jobs
X-API-Key: YOUR_API_KEY
```

### Python

Lưu list_bulk_jobs.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### list_bulk_jobs.py

```python
import json
import os
from pathlib import Path

import requests

response = requests.get(
    "https://api.flashdata.dev/v2/bulk-jobs?limit=20",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
```

#### Chạy từ con số lớn

```bash
python list_bulk_jobs.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
curl --fail-with-body --silent --show-error --max-time 30 \
  --request GET \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
  "https://api.flashdata.dev/v2/bulk-jobs?limit=20"
```


- [BulkJobPage](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobPage)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="listBulkJobs-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Trang công việc Bulk |
| 401 | Xác thực cần thiết hay không hợp lệ |

#### 200 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobPage"
}
```


<a id="pauseBulkJob"></a>

## Tạm dừng một công việc

Tạm dừng việc nộp đơn và đóng gói kết quả. Công việc tồn tại tiếp tục với các thiết lập và cáo buộc ban đầu. Hãy tiếp tục công việc khi sẵn sàng.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |

### Điểm kết thúc

```http
POST https://api.flashdata.dev/v2/bulk-jobs/{bulkId}/pause
X-API-Key: YOUR_API_KEY
```

### Python

Lưu pause_bulk_job.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### pause_bulk_job.py

```python
import json
import os
from pathlib import Path

import requests

bulk_id = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))["job"]["id"]
response = requests.post(
    f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}/pause",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
```

#### Chạy từ con số lớn

```bash
python pause_bulk_job.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
curl --fail-with-body --silent --show-error --max-time 30 \
  --request POST \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
  "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID/pause"
```


- [BulkJobResponse](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobResponse)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="pauseBulkJob-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Công việc lớn tạm dừng hoặc trạng thái nhận diện hiện tại của nó |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |

#### 200 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobResponse"
}
```


<a id="updateBulkJob"></a>

## Cập nhật tùy chọn công việc

Cập nhật tùy chọn trong khi chờ tải lên, hoặc tạm dừng trước khi đọc mọi dữ liệu nhập. Công việc tồn tại giữ cho thiết lập của họ. Nếu tạm dừng vẫn đang tiến hành, hãy đợi và thử lại a 409 Trả lời đi. Sau khi đọc tất cả các dữ liệu nhập, chỉ có giấy ủy nhiệm giao hàng mới có thể cập nhật. Đặt callback_url phải null để loại bỏ nó.

Ví dụ này loại bỏ gọi lại hoàn tất. Để thay đổi tùy chọn nguồn, hãy gửi một đối tượng tùy chọn. Tạm dừng đầu tiên và chờ đợi cho các tạm dừng để có hiệu quả; một 409 có nghĩa là cập nhật chưa được áp dụng. Việc tồn tại công việc trẻ em giữ lại những lựa chọn ban đầu của chúng.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |

### Điểm kết thúc

```http
PATCH https://api.flashdata.dev/v2/bulk-jobs/{bulkId}
X-API-Key: YOUR_API_KEY
```

### Python

Lưu update_bulk_job.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### update_bulk_job.py

```python
import json
import os
from pathlib import Path

import requests

bulk_id = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))["job"]["id"]
response = requests.patch(
    f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    json={"callback_url": None},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
```

#### Chạy từ con số lớn

```bash
python update_bulk_job.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
curl --fail-with-body --silent --show-error --max-time 30 \
  --request PATCH \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
  --header 'Content-Type: application/json' --data '{"callback_url":null}' \
  "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID"
```


- [UpdateBulkJobRequest](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-UpdateBulkJobRequest)
- [BulkJobResponse](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobResponse)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="updateBulkJob-responses"></a>

### Đáp ứng và yêu cầu

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Tình trạng khối công việc cập nhật |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |
| 409 | Tình trạng tài nguyên hoặc xung đột quyền tối thiểu |
| 422 | Yêu cầu xác thực thất bại |

#### Nội dung yêu cầu

```json
{
  "$ref": "#/components/schemas/UpdateBulkJobRequest"
}
```

#### 200 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobResponse"
}
```


<a id="resumeBulkJob"></a>

## Tiếp tục công việc

Sửa pauseReason Đầu tiên, như là thêm tín dụng hoặc cập nhật giấy ủy nhiệm lưu trữ, sau đó tiếp tục như cũ Bulk ID.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |

### Điểm kết thúc

```http
POST https://api.flashdata.dev/v2/bulk-jobs/{bulkId}/resume
X-API-Key: YOUR_API_KEY
```

### Python

Lưu resume_bulk_job.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### resume_bulk_job.py

```python
import json
import os
from pathlib import Path

import requests

bulk_id = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))["job"]["id"]
response = requests.post(
    f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}/resume",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
```

#### Chạy từ con số lớn

```bash
python resume_bulk_job.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
curl --fail-with-body --silent --show-error --max-time 30 \
  --request POST \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
  "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID/resume"
```


- [BulkJobResponse](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobResponse)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="resumeBulkJob-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Trạng thái công việc phụ hiện tại |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |

#### 200 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobResponse"
}
```


<a id="cancelBulkJob"></a>

## Hủy bỏ công việc

Dừng lại đi. Việc làm tồn tại vẫn có thể finish và nhận tội bình thường của họ. Một công việc bị hủy không xuất bản danh sách cuối cùng.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |

### Điểm kết thúc

```http
DELETE https://api.flashdata.dev/v2/bulk-jobs/{bulkId}
X-API-Key: YOUR_API_KEY
```

### Python

Lưu cancel_bulk_job.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### cancel_bulk_job.py

```python
import json
import os
from pathlib import Path

import requests

bulk_id = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))["job"]["id"]
response = requests.delete(
    f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
```

#### Chạy từ con số lớn

```bash
python cancel_bulk_job.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
curl --fail-with-body --silent --show-error --max-time 30 \
  --request DELETE \
  --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
  "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID"
```


- [BulkJobResponse](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobResponse)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="cancelBulkJob-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Trạng thái công việc phụ hiện tại |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |

#### 200 · application/json

```json
{
  "$ref": "#/components/schemas/BulkJobResponse"
}
```


<a id="downloadBulkJobManifest"></a>

## Lấy bản kê kết quả

Theo hướng chuyển tiếp để tải về JSON Hiển thị và sử dụng các liên kết của nó để lấy các tập tin kết quả. Đem về kho lưu trữ đã được ký URLs Không có bạn API Chìa khóa. Kết quả vẫn còn sẵn sàng cho 24 Hàng giờ sau toàn bộ Bulk Công việc hoàn tất.

Xác thực API Yêu cầu trả lại 302 với tiêu đề địa điểm. Lấy đi. HTTPS kho URL trong một yêu cầu riêng biệt không X-API-Key. Ví dụ này cứu được manifest.json. A 409 có nghĩa là kết quả chưa sẵn sàng; 410 Nghĩa là chúng đã hết hạn.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |

### Điểm kết thúc

```http
GET https://api.flashdata.dev/v2/bulk-jobs/{bulkId}/results
X-API-Key: YOUR_API_KEY
```

### Python

Lưu bulk_manifest.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### bulk_manifest.py

```python
import json
import os
from pathlib import Path

import requests

bulk_id = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))["job"]["id"]
response = requests.get(
    f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}/results",
    headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
    timeout=30, allow_redirects=False,
)
response.raise_for_status()
if response.status_code != 302:
    raise RuntimeError(f"Expected a manifest redirect, got {response.status_code}")
url = response.headers["Location"]
if not url.startswith("https://"):
    raise ValueError("Expected an HTTPS storage URL")

manifest = requests.get(url, timeout=120)  # No FlashData API key.
manifest.raise_for_status()
Path("manifest.json").write_text(json.dumps(manifest.json(), indent=2), encoding="utf-8")
print(json.dumps(manifest.json(), indent=2))
```

#### Chạy từ con số lớn

```bash
python bulk_manifest.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
# Only send the API key to FlashData; fetch storage URLs separately.
fetch_bulk_result() {
  local storage_url
  storage_url=$(curl --fail-with-body --silent --show-error \
    "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID/results$1" \
    --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
    --output /dev/null --write-out '%{redirect_url}') || return
  curl --fail-with-body --silent --show-error --proto '=https' \
    "${storage_url:?Expected a signed result URL}" --output "$2"
}
fetch_bulk_result '' manifest.json &&
jq '{status, counts, parts, expires_at}' manifest.json
```


- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="downloadBulkJobManifest-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | JSON Name |
| 302 | Chuyển hướng về một nơi riêng tư ngắn hạn R2 URL; API Không được chuyển hồ sơ · Location |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |
| 409 | Tình trạng tài nguyên hoặc xung đột quyền tối thiểu |
| 410 | Kết quả được duy trì đã hết hạn |

#### 200 · application/json

```json
{
  "type": "object",
  "additionalProperties": true
}
```


<a id="downloadBulkJobPart"></a>

## Tải về các phần kết quả

Dùng mỗi parts[].number từ manifest.json. Mỗi điểm kết thúc trở về một 302 cho g tiêu đề NDJSON Tập tin; tải về mà không có API Chìa khóa, giảm áp, sau đó phân tích một JSON đối tượng trên một dòng. Hãy tham gia vào chỉ mục dựa trên số không. Ví dụ này thu thập tất cả các bộ phận và giữ cả hai.ndjson.gz và các hồ sơ.ndjson.

| Tham số | Địa điểm | Cần thiết |
| --- | --- | --- |
| bulkId | path | Bắt buộc · {"type":"string","pattern":"^bulk_[A-Za-z0-9_-]{8,}$"} |
| partNumber | path | Bắt buộc · {"type":"integer","minimum":0} |

### Điểm kết thúc

```http
GET https://api.flashdata.dev/v2/bulk-jobs/{bulkId}/results/{partNumber}
X-API-Key: YOUR_API_KEY
```

### Python

Lưu bulk_parts.py trong đa chiều / bên cạnh bulk-created.json. Sao chép văn lệnh đầy đủ, rồi chạy lệnh bên dưới nó.

#### bulk_parts.py

```python
import json
import os
from pathlib import Path

import requests
import gzip
import shutil

bulk_id = json.loads(Path("bulk-created.json").read_text(encoding="utf-8"))["job"]["id"]
manifest = json.loads(Path("manifest.json").read_text(encoding="utf-8"))
for part in manifest["parts"]:
    number = part["number"]
    response = requests.get(
        f"https://api.flashdata.dev/v2/bulk-jobs/{bulk_id}/results/{number}",
        headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
        timeout=30, allow_redirects=False,
    )
    response.raise_for_status()
    if response.status_code != 302:
        raise RuntimeError(f"Expected a part redirect, got {response.status_code}")
    url = response.headers["Location"]
    if not url.startswith("https://"):
        raise ValueError("Expected an HTTPS storage URL")

    # Save the original gzip bytes; do not decompress twice.
    with requests.get(url, stream=True, timeout=120) as download:
        download.raise_for_status()
        with open(f"part-{number}.ndjson.gz", "wb") as file:
            download.raw.decode_content = False
            shutil.copyfileobj(download.raw, file)
    with gzip.open(f"part-{number}.ndjson.gz", "rt", encoding="utf-8") as rows:
        with open(f"part-{number}.ndjson", "w", encoding="utf-8") as file:
            for line in rows:
                file.write(line)
                print(json.dumps(json.loads(line)))
```

#### Chạy từ con số lớn

```bash
python bulk_parts.py
```


### cURL / Bash

#### Chạy từ con số lớn

```bash
BULK_ID=$(jq -er '.job.id' bulk-created.json)
# Only send the API key to FlashData; fetch storage URLs separately.
fetch_bulk_result() {
  local storage_url
  storage_url=$(curl --fail-with-body --silent --show-error \
    "https://api.flashdata.dev/v2/bulk-jobs/$BULK_ID/results$1" \
    --header "X-API-Key: ${FLASHDATA_API_KEY:?Set FLASHDATA_API_KEY}" \
    --output /dev/null --write-out '%{redirect_url}') || return
  curl --fail-with-body --silent --show-error --proto '=https' \
    "${storage_url:?Expected a signed result URL}" --output "$2"
}
fetch_bulk_result '' manifest.json &&
jq '{status, counts, parts, expires_at}' manifest.json

# Run in the same Bash session as fetch_bulk_result.
jq -r '.parts[].number' manifest.json | while IFS= read -r PART; do
  fetch_bulk_result "/$PART" "part-$PART.ndjson.gz" || exit
  gzip -dc "part-$PART.ndjson.gz" > "part-$PART.ndjson" || exit
  jq -c '{index, video_id, status, results, error}' "part-$PART.ndjson"
done
```


- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)

<a id="downloadBulkJobPart-responses"></a>

### Đáp ứng

| Trạng thái HTTP | Nghĩa là |
| --- | --- |
| 200 | Gzip- bị nén NDJSON Tải về sau khi chuyển tiếp |
| 302 | Chuyển hướng về một nơi riêng tư ngắn hạn R2 URL; API Không được chuyển hồ sơ · Location |
| 401 | Xác thực cần thiết hay không hợp lệ |
| 404 | Không tìm thấy tài nguyên hay không thuộc về người gọi |
| 409 | Tình trạng tài nguyên hoặc xung đột quyền tối thiểu |
| 410 | Kết quả được duy trì đã hết hạn |

#### 200 · application/x-ndjson

```json
{
  "type": "string"
}
```


<a id="states"></a>

## Trạng thái công việc và sự chú ý

Kết quả vẫn còn sẵn sàng cho 24 Hàng giờ sau toàn bộ Bulk Công việc hoàn tất. Hãy cứu họ trước đi. expiresAt. Phương tiện trong đích của bạn làm theo chính sách lưu trữ của xô. Một công việc hoàn tất có thể bao gồm các video thất bại; counts.invalid ghi chép bị từ chối.

| Tình trạng | Hành động tiếp theo |
| --- | --- |
| awaiting_upload | Tải lên tập tin và bắt đầu cuộc gọi. |
| running | Cũng như nhau thôi ID với lùi lại; input.complete hiển thị việc quét xong chưa. |
| paused | Đọc pauseReason, sửa nó, rồi tiếp tục. |
| finalizing | Chờ kết quả của việc đóng gói và xuất bản. |
| completed | Tải về danh sách và mọi phần. Kiểm tra tình trạng và lỗi của mỗi hàng. |
| failed / cancelled | Lỗi kiểm tra và lưu trạng thái. Không có bản kê khai cuối cùng được xuất bản. |

- [Lỗi và mã trạng thái](https://flashdata.dev/vi/docs/errors/reference.md)
- [Phục hồi lại một tạm dừng Bulk công việc](https://flashdata.dev/vi/docs/guides/bulk/reference.md#controls)

<a id="storage"></a>

## Giao hàng

Dùng sân chơi để cấu hình nhà cung cấp và xem thử trường yêu cầu chính xác. Chứng nhận khách hàng thuộc về vật lưu trữ đã được chọn; X-API-Key Chỉ xác thực FlashData API yêu cầu.

| Nguồn | Tạo trường yêu cầu | Giao hàng |
| --- | --- | --- |
| Siêu dữ liệu, ghi chép, chú thích, kiểm tra bằng lái | options.result_storage | Tùy anh thôi. Bản sao NDJSON kết quả là các bộ phận và một bản kê khai cho xô của bạn. |
| youtube_download | options.storage | Yêu cầu. Giao truyền thông cho xô nước của bạn; result_storage và browser_delivery không được chấp nhận. |

- [Nhà cung cấp trường chứng nhận](https://flashdata.dev/vi/docs/sources/youtube_download/reference.md#storage)
- [Cấu hình đích lưu trữ](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#playground)

<a id="storage-layout"></a>

### Tìm các tập tin đã gửi

Bản liệt kê dữ liệu được viết cuối cùng và liệt kê các phím đối tượng, kích cỡ và SHA-256 Quản lý chi phiếu. Nó khác với FlashData Danh sách nào API Giá trị href. YYYYMMD trong các đường dẫn dữ liệu sử dụng UTC Bulk Ngày tạo; trong phương tiện truyền thông, nó sử dụng mỗi video UTC upload ngày. Bulk Cần thiết giao dữ liệu OSS aliyuncs.com điểm cuối.

Truyền thông cá nhân file_url giá trị cần lưu trữ của bạn SDK hay chữ ký URL từ nhà cung cấp đó. A FlashData Chìa khóa không cho phép xô vào. Các tập tin đồng bộ với siêu dữ liệu tùy chọn được cất bên cạnh các tập tin. Các đệ quy giao hàng xuất hiện delivery.retryCount.

#### Name

```text
<prefix>/<source>/<bulkId>/results/part-NNNNNNNN.jsonl.gz
<prefix>/<source>/<bulkId>/manifest.json
```


<a id="webhooks"></a>

## Nhận một trình điều khiển hoàn tất

Hãy công khai HTTPS callback_url những lựa chọn bên ngoài. Bulk gửi tin hoàn tất chỉ sau khi xuất bản bản danh sách; nó không gửi sự kiện per-video và không có sự kiện hoàn thành cho thất bại hoặc hủy bỏ công việc. Cứ tiếp tục thăm dò tình trạng như một hậu quả.

1. Kiên trì và phức tạp delivery_idSau đó trả lại 2x ngay lập tức. Việc giao hàng được thu hồi lại đến 8 lần với việc rút lui.
2. Những sự kiện không được ký. Khớp id và nguồn cho biên nhận đã lưu của bạn; xác nhận hoàn tất thông qua bộ quản lý xác thực API trước khi thu hồi lại. Bỏ qua URLs từ một sự kiện không xác định.

### Tạo yêu cầu với một gọi lại

```json
{
  "source": "youtube_metadata",
  "options": {
    "include_formats": false,
    "include_chapters": false
  },
  "callback_url": "https://your-app.example/webhooks/flashdata"
}
```

### Sự kiện gõ xong

```json
{
  "delivery_id": "bulk-completion:bulk_EXAMPLE123",
  "id": "bulk_EXAMPLE123",
  "source": "youtube_metadata",
  "status": "completed",
  "links": [
    {
      "rel": "self",
      "href": "https://api.flashdata.dev/v2/bulk-jobs/bulk_EXAMPLE123",
      "method": "GET"
    },
    {
      "rel": "results",
      "href": "https://api.flashdata.dev/v2/bulk-jobs/bulk_EXAMPLE123/results",
      "method": "GET"
    }
  ]
}
```

- [Tạo ra bộ nhận kết nối mạng nút](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#playground)

<a id="schemas"></a>

## Định nghĩa sơ đồ

- [BulkJobCreated](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobCreated)
- [BulkJob](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJob)
- [BulkJobPage](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobPage)
- [BulkJobResponse](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJobResponse)
- [CreateBulkJobRequest](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-CreateBulkJobRequest)
- [JobLink](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-JobLink)
- [Pagination](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Pagination)
- [Problem](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Problem)
- [FieldError](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-FieldError)
- [UpdateBulkJobRequest](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-UpdateBulkJobRequest)

<a id="schema-BulkJobCreated"></a>

### BulkJobCreated

#### BulkJobCreated

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "job",
    "upload"
  ],
  "properties": {
    "job": {
      "$ref": "#/components/schemas/BulkJob"
    },
    "upload": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "href",
        "method",
        "expiresAt",
        "contentType"
      ],
      "properties": {
        "href": {
          "type": "string",
          "format": "uri"
        },
        "method": {
          "type": "string",
          "const": "PUT"
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time"
        },
        "contentType": {
          "type": "string",
          "const": "text/plain; charset=utf-8"
        }
      }
    }
  }
}
```

- [BulkJob](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJob)

<a id="schema-BulkJob"></a>

### BulkJob

#### BulkJob

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "source",
    "status",
    "input",
    "counts",
    "delivery",
    "pauseReason",
    "error",
    "createdAt",
    "startedAt",
    "completedAt",
    "expiresAt",
    "links"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^bulk_[A-Za-z0-9_-]{8,}$"
    },
    "source": {
      "type": "string",
      "enum": [
        "youtube_metadata",
        "youtube_transcript",
        "youtube_captions",
        "youtube_trainability",
        "youtube_download"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "awaiting_upload",
        "running",
        "paused",
        "finalizing",
        "completed",
        "failed",
        "cancelled"
      ]
    },
    "input": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "bytes",
        "complete",
        "scannedBytes",
        "scannedLines"
      ],
      "properties": {
        "bytes": {
          "type": "integer",
          "minimum": 0
        },
        "complete": {
          "type": "boolean"
        },
        "scannedBytes": {
          "type": "integer",
          "minimum": 0
        },
        "scannedLines": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "counts": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "accepted",
        "completed",
        "failed",
        "invalid",
        "results"
      ],
      "properties": {
        "accepted": {
          "type": "integer",
          "minimum": 0
        },
        "completed": {
          "type": "integer",
          "minimum": 0
        },
        "failed": {
          "type": "integer",
          "minimum": 0
        },
        "invalid": {
          "type": "integer",
          "minimum": 0
        },
        "results": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "pauseReason": {
      "type": [
        "string",
        "null"
      ]
    },
    "delivery": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "customerStorage",
        "storageType",
        "uploadedParts",
        "retryCount"
      ],
      "properties": {
        "customerStorage": {
          "type": "boolean"
        },
        "storageType": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "s3",
            "s3_compatible",
            "oss",
            "gcs",
            "azure",
            "cos",
            "bos",
            "tos",
            null
          ]
        },
        "uploadedParts": {
          "type": "integer",
          "minimum": 0
        },
        "retryCount": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "error": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "code",
            "detail"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "detail": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "startedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "expiresAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "links": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/JobLink"
      }
    }
  }
}
```

- [JobLink](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-JobLink)

<a id="schema-BulkJobPage"></a>

### BulkJobPage

#### BulkJobPage

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "data",
    "pagination"
  ],
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/BulkJob"
      }
    },
    "pagination": {
      "$ref": "#/components/schemas/Pagination"
    }
  }
}
```

- [BulkJob](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJob)
- [Pagination](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-Pagination)

<a id="schema-BulkJobResponse"></a>

### BulkJobResponse

#### BulkJobResponse

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "job"
  ],
  "properties": {
    "job": {
      "$ref": "#/components/schemas/BulkJob"
    }
  }
}
```

- [BulkJob](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-BulkJob)

<a id="schema-CreateBulkJobRequest"></a>

### CreateBulkJobRequest

#### CreateBulkJobRequest

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "source"
  ],
  "properties": {
    "source": {
      "type": "string",
      "enum": [
        "youtube_metadata",
        "youtube_transcript",
        "youtube_captions",
        "youtube_trainability",
        "youtube_download"
      ]
    },
    "options": {
      "type": "object",
      "additionalProperties": true,
      "description": "Reused for every ID. Metadata accepts include_formats and include_chapters. Transcript and captions accept language (one code or an array of 1–10 distinct codes) and auto (applies to all requested languages). Omit language to prefer en-orig, fall back to en, and return one track. With auto=true, each requested code tries its -orig track first, then the plain code. Explicit -orig codes and auto=false stay exact. languageCode identifies the selected track; requestedLanguageCode is included when it differs from the requested code. A language array returns tracks and per-language errors for each video with at least one retrieved track. If no track is retrieved, the video job fails and its reserved credits are refunded. Bulk exports use one JSONL record per video. Trainability accepts no source options. These four data sources optionally accept result_storage. Supported storage_type values are s3, s3_compatible, oss, gcs, azure, cos, bos, and tos. storage_url is the bucket name (Azure container name); object_prefix is optional. S3, S3-compatible, OSS, COS, BOS, and TOS use access_key and secret_key. S3-compatible and OSS also require a public HTTPS endpoint_url. COS, BOS, and TOS require region and use fixed provider endpoints. COS bucket names include the APPID. BOS S3-compatible HTTPS delivery supports bj, su, and hkg. GCS requires service_account with project_id, client_email, and private_key. Azure requires account_name and a container SAS sas_token with write permission. Default object_prefix is YYYYMMDD, frozen to the UTC bulk creation date. Files are written to <prefix>/<source>/<bulkId>/results/part-NNNNNNNN.jsonl.gz; manifest.json in the same bulk directory is written last. Each JSONL row includes its input index and completed, failed, or invalid status. Internal R2 results remain available through the result links for 24 hours. Download accepts the normal YouTube download parameters, requires customer storage, and does not permit browser_delivery. Download storage supports the same eight provider types and credential shapes listed above under the storage field. Download storage may include object_prefix; YYYYMMDD tokens resolve to the UTC upload date, while literal prefixes are unchanged."
    },
    "callback_url": {
      "type": "string",
      "format": "uri",
      "maxLength": 2048,
      "description": "Optional public HTTPS endpoint notified once after manifest publication."
    }
  }
}
```


<a id="schema-JobLink"></a>

### JobLink

#### JobLink

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "rel",
    "href",
    "method"
  ],
  "properties": {
    "rel": {
      "type": "string",
      "enum": [
        "self",
        "results",
        "content",
        "download"
      ]
    },
    "href": {
      "type": "string",
      "format": "uri"
    },
    "method": {
      "type": "string",
      "const": "GET"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "filename": {
      "type": "string"
    },
    "content_type": {
      "type": "string"
    },
    "size_bytes": {
      "type": "integer",
      "minimum": 1
    }
  }
}
```


<a id="schema-Pagination"></a>

### Pagination

#### Pagination

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "hasMore",
    "limit"
  ],
  "properties": {
    "nextCursor": {
      "type": [
        "string",
        "null"
      ]
    },
    "previousCursor": {
      "type": [
        "string",
        "null"
      ]
    },
    "hasMore": {
      "type": "boolean"
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  }
}
```


<a id="schema-Problem"></a>

### Problem

#### Problem

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "type",
    "title",
    "status",
    "code",
    "requestId"
  ],
  "properties": {
    "type": {
      "type": "string",
      "format": "uri-reference"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer",
      "minimum": 400,
      "maximum": 599
    },
    "code": {
      "type": "string",
      "pattern": "^[a-z0-9_]+$"
    },
    "detail": {
      "type": "string"
    },
    "requestId": {
      "type": "string",
      "pattern": "^req_"
    },
    "fieldErrors": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/FieldError"
      }
    }
  }
}
```

- [FieldError](https://flashdata.dev/vi/docs/reference/bulk-processing/reference.md#schema-FieldError)

<a id="schema-FieldError"></a>

### FieldError

#### FieldError

```json
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "field",
    "code",
    "message"
  ],
  "properties": {
    "field": {
      "type": "string"
    },
    "code": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  }
}
```


<a id="schema-UpdateBulkJobRequest"></a>

### UpdateBulkJobRequest

#### UpdateBulkJobRequest

```json
{
  "type": "object",
  "additionalProperties": false,
  "minProperties": 1,
  "properties": {
    "options": {
      "type": "object",
      "additionalProperties": true,
      "description": "Partial option update. Nested storage fields are merged so unchanged credentials do not need to be resent. Data result_storage fields are merged the same way. After all IDs have been scanned, a paused data bulk job accepts credential updates only: access_key and secret_key, GCS service_account, or Azure sas_token, depending on the storage type. The complete merged configuration is validated before it is stored."
    },
    "callback_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "maxLength": 2048,
      "description": "Replacement completion callback, or null to remove the callback."
    }
  }
}
```

