{
  "tags": [
    "任务"
  ],
  "description": "提交缓存刷新或预热、IP 解锁、白名单清理、网站访问日志下载等异步任务。需要登录。请求可为一个任务对象或非空任务对象数组；服务端依次校验并在同一事务中创建全部任务，任一项失败会回滚。任务结果和执行状态可通过 GET /v1/jobs 查询。",
  "operationId": "user_post_v1_jobs",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果使用 HTTP 200 返回。成功时返回新建任务申请 ID 的字符串数组；请求格式、任务类型、业务对象归属、限额或参数校验失败时返回业务错误封装。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "integer",
                    "enum": [
                      0
                    ],
                    "description": "成功状态码，固定为 0。"
                  },
                  "msg": {
                    "type": "string",
                    "enum": [
                      "添加成功"
                    ],
                    "description": "提交成功提示。"
                  },
                  "data": {
                    "type": "array",
                    "description": "已创建的 job ID 字符串数组，与请求任务顺序一致。",
                    "items": {
                      "type": "string",
                      "pattern": "^[0-9]+$",
                      "description": "任务申请 ID。"
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "job-1",
                      "job-2",
                      "job-3",
                      "job-5",
                      "job-6",
                      "job-9",
                      "job-15",
                      "job-17",
                      "job-18",
                      "job-19",
                      "job-20",
                      "job-25",
                      "job-26",
                      "job-27",
                      "job-29",
                      "job-30",
                      "job-31",
                      "job-32",
                      "job-33",
                      "job-34",
                      "job-35",
                      "job-36",
                      "job-37",
                      "job-38",
                      "job-39",
                      "job-40",
                      "job-42",
                      "job-43",
                      "job-44",
                      "job-45",
                      "job-46",
                      "job-47",
                      "job-48",
                      "login_required"
                    ],
                    "description": "请求格式、任务类型、任务参数、资源归属、每日限额或登录状态相关的业务错误码。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "具体错误原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "业务错误时固定为空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "examples": {
            "success": {
              "summary": "提交成功",
              "value": {
                "code": 0,
                "msg": "添加成功",
                "data": [
                  "1201"
                ]
              }
            },
            "invalidType": {
              "summary": "不支持的任务类型",
              "value": {
                "code": "job-5",
                "msg": "任务类型不支持",
                "data": ""
              }
            }
          },
          "example": {
            "code": 0,
            "msg": "添加成功",
            "data": [
              "1201"
            ]
          }
        }
      }
    }
  },
  "x-python-handler": "system.JobAPI",
  "x-python-route-line": 660,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "oneOf": [
            {
              "type": "object",
              "required": [
                "type",
                "data"
              ],
              "description": "一个异步任务申请。type 决定 data 中哪些字段必填及其校验规则。",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "clean_url",
                    "clean_dir",
                    "pre_cache_url",
                    "cancel_task",
                    "unlock_ip",
                    "clean_white_ip",
                    "down_http_access_log"
                  ],
                  "description": "任务类型：clean_url 刷新 URL，clean_dir 刷新目录，pre_cache_url 预热 URL，cancel_task 使用与缓存任务相同的 URL 校验流程，unlock_ip 解锁 IP，clean_white_ip 清理网站白名单 IP，down_http_access_log 申请下载网站访问日志。"
                },
                "data": {
                  "type": "object",
                  "description": "任务参数对象。字段是否必填由 type 决定：缓存类任务必须提供 url；IP 解锁和白名单清理必须提供 site_id；访问日志下载必须提供 start 和 end。",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri",
                      "description": "clean_url、clean_dir、pre_cache_url 或 cancel_task 必填。必须是 HTTP/HTTPS URL，域名必须属于当前用户或调用者为管理员；clean_dir 的 URL 必须以 / 结尾。"
                    },
                    "site_id": {
                      "type": "integer",
                      "format": "int64",
                      "description": "unlock_ip 或 clean_white_ip 必填。网站 ID；非管理员只能操作自己的网站。unlock_ip 可传 0 表示不绑定具体网站。"
                    },
                    "ip": {
                      "type": "string",
                      "description": "unlock_ip 可选。以空白字符分隔的一个或多个待解锁 IP，每个必须是合法 IP；未提供时服务端使用 __all__ 表示解锁全部。单次数量受系统 ip-unlock-max-per-limit 配置限制。"
                    },
                    "key1": {
                      "type": "string",
                      "description": "unlock_ip 或 clean_white_ip 可选的业务索引字段名。前端通常传 site_id，服务端会取 data[key1] 写入任务 key1。"
                    },
                    "key2": {
                      "type": "string",
                      "description": "unlock_ip 或 clean_white_ip 可选的第二业务索引字段名。服务端会取 data[key2] 写入任务 key2。"
                    },
                    "start": {
                      "type": "string",
                      "description": "down_http_access_log 必填。日志开始时间，格式必须为 YYYY-MM-DD HH:mm:ss。"
                    },
                    "end": {
                      "type": "string",
                      "description": "down_http_access_log 必填。日志结束时间，格式必须为 YYYY-MM-DD HH:mm:ss；结束与开始的间隔不得超过 25 小时。"
                    },
                    "host": {
                      "type": "string",
                      "description": "down_http_access_log 可选。以空白字符分隔的域名筛选；非管理员提供的每个域名都必须属于自己。"
                    },
                    "addr": {
                      "type": "string",
                      "description": "down_http_access_log 可选。按客户端 IP 筛选，提供时必须为合法 IP。"
                    },
                    "req_uri": {
                      "type": "string",
                      "description": "down_http_access_log 可选。按请求 URI 筛选，提供时必须以 / 开头。"
                    },
                    "status": {
                      "type": "string",
                      "pattern": "^[0-9]{3}$",
                      "description": "down_http_access_log 可选。按三位 HTTP 状态码筛选。"
                    },
                    "cache_status": {
                      "type": "string",
                      "enum": [
                        "HIT",
                        "MISS"
                      ],
                      "description": "down_http_access_log 可选。缓存状态筛选，只允许 HIT 或 MISS。"
                    },
                    "server_port": {
                      "type": "string",
                      "pattern": "^[0-9]+$",
                      "description": "down_http_access_log 可选。按源端口筛选，提供时必须为数字。"
                    },
                    "node_id": {
                      "type": "string",
                      "pattern": "^[0-9]+$",
                      "description": "down_http_access_log 可选。按节点 ID 筛选，提供时必须为数字。"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "additionalProperties": false
            },
            {
              "type": "array",
              "minItems": 1,
              "description": "批量提交的任务对象数组。服务端按数组顺序处理，成功响应 data 中的任务 ID 与此顺序一致。",
              "items": {
                "type": "object",
                "required": [
                  "type",
                  "data"
                ],
                "description": "任务对象，字段和校验规则与单对象提交相同。data 的已知字段为 url、site_id、ip、key1、key2、start、end、host、addr、req_uri、status、cache_status、server_port、node_id。",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "clean_url",
                      "clean_dir",
                      "pre_cache_url",
                      "cancel_task",
                      "unlock_ip",
                      "clean_white_ip",
                      "down_http_access_log"
                    ],
                    "description": "任务类型。"
                  },
                  "data": {
                    "type": "object",
                    "description": "任务参数。缓存类使用 url；IP 类使用 site_id、ip、key1/key2；日志下载使用 start/end 及可选筛选字段。",
                    "properties": {
                      "url": {
                        "type": "string",
                        "description": "缓存类任务必填的 HTTP/HTTPS URL；clean_dir 必须以 / 结尾。"
                      },
                      "site_id": {
                        "type": "integer",
                        "format": "int64",
                        "description": "IP 解锁或白名单清理任务必填的网站 ID。"
                      },
                      "ip": {
                        "type": "string",
                        "description": "IP 解锁任务可选的空白分隔 IP 列表。"
                      },
                      "key1": {
                        "type": "string",
                        "description": "可选业务索引字段名，常用值 site_id。"
                      },
                      "key2": {
                        "type": "string",
                        "description": "可选第二业务索引字段名。"
                      },
                      "start": {
                        "type": "string",
                        "description": "日志下载必填开始时间，YYYY-MM-DD HH:mm:ss。"
                      },
                      "end": {
                        "type": "string",
                        "description": "日志下载必填结束时间，YYYY-MM-DD HH:mm:ss，时间范围最多 25 小时。"
                      },
                      "host": {
                        "type": "string",
                        "description": "日志下载可选域名筛选。"
                      },
                      "addr": {
                        "type": "string",
                        "description": "日志下载可选 IP 筛选。"
                      },
                      "req_uri": {
                        "type": "string",
                        "description": "日志下载可选 URI 筛选，必须以 / 开头。"
                      },
                      "status": {
                        "type": "string",
                        "description": "日志下载可选三位状态码。"
                      },
                      "cache_status": {
                        "type": "string",
                        "enum": [
                          "HIT",
                          "MISS"
                        ],
                        "description": "日志下载可选缓存状态。"
                      },
                      "server_port": {
                        "type": "string",
                        "description": "日志下载可选数字端口。"
                      },
                      "node_id": {
                        "type": "string",
                        "description": "日志下载可选数字节点 ID。"
                      }
                    },
                    "additionalProperties": true
                  }
                },
                "additionalProperties": false
              }
            }
          ]
        },
        "examples": {
          "cleanUrl": {
            "summary": "刷新单个 URL 缓存",
            "value": {
              "type": "clean_url",
              "data": {
                "url": "https://www.example.invalid/index.html"
              }
            }
          },
          "unlockIp": {
            "summary": "解锁网站 IP",
            "value": {
              "type": "unlock_ip",
              "data": {
                "site_id": 101,
                "ip": "198.51.100.23",
                "key1": "site_id"
              }
            }
          },
          "downloadLog": {
            "summary": "申请下载访问日志",
            "value": {
              "type": "down_http_access_log",
              "data": {
                "start": "2026-01-01 00:00:00",
                "end": "2026-01-01 23:59:59",
                "host": "www.example.invalid",
                "status": "200"
              }
            }
          }
        }
      }
    }
  },
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "system.JobAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 660
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "post",
  "path": "/v1/jobs",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "AccessToken": {
      "type": "apiKey",
      "in": "header",
      "name": "access-token",
      "description": "通过登录接口获得的短期访问令牌。"
    },
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "api-key",
      "description": "API Key；必须和 api-secret 同时发送。"
    },
    "ApiSecret": {
      "type": "apiKey",
      "in": "header",
      "name": "api-secret",
      "description": "API Secret；必须和 api-key 同时发送。"
    }
  },
  "jsonRequestBodyExample": {
    "type": "clean_url",
    "data": {
      "url": "string",
      "site_id": 0,
      "ip": "string",
      "key1": "string",
      "key2": "string",
      "start": "string",
      "end": "string",
      "host": "string",
      "addr": "string",
      "req_uri": "string",
      "status": "string",
      "cache_status": "HIT",
      "server_port": "string",
      "node_id": "string"
    }
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "提交异步业务任务",
    "description": {
      "content": "提交缓存刷新或预热、IP 解锁、白名单清理、网站访问日志下载等异步任务。需要登录。请求可为一个任务对象或非空任务对象数组；服务端依次校验并在同一事务中创建全部任务，任一项失败会回滚。任务结果和执行状态可通过 GET /v1/jobs 查询。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "jobs"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": []
    },
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "POST",
    "body": {
      "mode": "raw",
      "raw": "",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}