# Tạo hàng loạt Job

> Tạo nhiều job trong một lời gọi API duy nhất.

Source: https://docs.fleetwork.vn/vi/jobs/jobs-bulk-create

**POST** `https://live.fleetwork.vn/api/v1/workspace/jobs/bulk-create`

## Body yêu cầu

| Trường | Kiểu  | Bắt buộc     | Mô tả                                                                          |
| ------ | ----- | ------------ | ------------------------------------------------------------------------------ |
| `jobs` | array | **Bắt buộc** | Mảng các đối tượng job — cùng schema với [Tạo Job](https://docs.fleetwork.vn/vi/jobs/jobs-create)     |

> Mỗi **Shipment job** (`jobType=1`) trong mảng vẫn phải có **đúng 2 task**
> (1 Pick + 1 Drop). Quy tắc được kiểm tra cho từng job.

```json
{
  "jobs": [
    {
      "jobName": "Job A",
      "jobStatus": 1,
      "jobType": 1,
      "tasks": [
        {
          "taskName": "Pick up at Warehouse",
          "taskType": 1,
          "shipmentProperty": { "shipmentType": 1 },
          "place": {
            "refId": "WH-001",
            "name": "Main Warehouse",
            "address": "100 Warehouse St, D7",
            "lat": 10.74,
            "lng": 106.72
          }
        },
        {
          "taskName": "Deliver to Customer A",
          "taskType": 1,
          "shipmentProperty": { "shipmentType": 2 },
          "place": {
            "refId": "CUST-A-001",
            "name": "Customer A",
            "address": "123 Le Loi, D1",
            "lat": 10.7731,
            "lng": 106.703
          }
        }
      ]
    },
    {
      "jobName": "Job B",
      "jobStatus": 1,
      "jobType": 1,
      "tasks": [
        {
          "taskName": "Pick up at Depot",
          "taskType": 1,
          "shipmentProperty": { "shipmentType": 1 },
          "place": {
            "refId": "DEPOT-002",
            "name": "Depot B",
            "address": "200 Industrial Rd, D12",
            "lat": 10.756,
            "lng": 106.695
          }
        },
        {
          "taskName": "Deliver to Customer B",
          "taskType": 1,
          "shipmentProperty": { "shipmentType": 2 },
          "place": {
            "refId": "CUST-B-001",
            "name": "Customer B",
            "address": "456 Hai Ba Trung, D3",
            "lat": 10.7856,
            "lng": 106.6862
          }
        }
      ]
    }
  ]
}
```

## Ví dụ

### Request

```bash
curl -X POST \
  "https://live.fleetwork.vn/api/v1/workspace/jobs/bulk-create" \
  -H "API-KEY: <your-key>" \
  -H "Content-Type: application/json" \
  -d '{"jobs":[{"jobName":"Job A","jobStatus":1,"jobType":1,"tasks":[{"taskName":"Pick up","taskType":1,"shipmentProperty":{"shipmentType":1},"place":{"refId":"WH-001","name":"Warehouse","address":"100 Warehouse St","lat":10.74,"lng":106.72}},{"taskName":"Deliver","taskType":1,"shipmentProperty":{"shipmentType":2},"place":{"refId":"CUST-A-001","name":"Customer A","address":"123 Le Loi","lat":10.7731,"lng":106.703}}]}]}'
```

### Response

```json
{
  "code": "OK",
  "message": null,
  "data": {
    "totalJobs": 2,
    "successCount": 2,
    "failedCount": 0,
    "results": [
      {
        "index": 0,
        "jobId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "isSuccess": true,
        "jobName": "Job A"
      },
      {
        "index": 1,
        "jobId": "a1b2c3d4-5717-4562-b3fc-2c963f66afa6",
        "isSuccess": true,
        "jobName": "Job B"
      }
    ]
  }
}
```
