作业
对已上传的文件运行操作。作业为它处理的每个文件各包含一个任务。设置、状态和批量处理的说明,请参阅运行作业。
本页内容
POST/v1/estimates
请求体与 POST /v1/jobs 相同。返回作业的最高费用(即启动时会预留的积分),以及每个输入将如何处理,但不会运行或预留任何内容。
请求体
operationstring必填操作的 ID,可通过
GET /v1/operations获取。inputsobject[]必填按顺序排列的输入文件。最多为该操作的
max_files个。inputs[].file_idstring必填settingsobject操作的设置,遵循其
settings_schema。省略则使用默认值。client_referencestring您自定义的参考值,会随作业及其 Webhook 一起返回,并可在
GET /v1/jobs中搜索。最多 255 个字符
返回
- 200预估结果。
14 个字段
operationstring必填settingsobject必填填入所有默认值后的设置。
reserved_creditsinteger必填作业可能产生的最高费用,启动时会预留这部分积分。最终只按实际用量扣费。
available_creditsinteger必填shortfallinteger必填启动作业还差多少积分。
最小值:0
tasksobject[]必填每个输入一项,按顺序排列。
tasks[].statusstring必填waiting:会运行。skipped:不会运行,原因见reason。可选值:
waiting或skippedtasks[].inputsobject[]必填tasks[].inputs[].file_idstringtasks[].inputs[].namestringtasks[].reserved_creditsintegertasks[].reasonstringtasks[].detailsobjecttasks[].previewobject操作将执行的处理,例如输出格式、编解码器和画面尺寸。
错误
示例
curl -X POST https://api.filesokay.com/v1/estimates \
-H "Authorization: Bearer $FILESOKAY_KEY" \
-H "Content-Type: application/json" \
-d '{
"operation": "video.compress",
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c"
}
],
"settings": {
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
}
}
}'const res = await fetch("https://api.filesokay.com/v1/estimates", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
operation: "video.compress",
inputs: [
{
file_id: "file_3cf0737aefa34b89b7b4443c9467d60c"
}
],
settings: {
method: "target_size",
target: {
unit: "percent",
value: 50
}
}
}),
});
const estimate = await res.json();import os
import requests
res = requests.post(
"https://api.filesokay.com/v1/estimates",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
json={
"operation": "video.compress",
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c"
}
],
"settings": {
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
}
}
},
)
estimate = res.json(){
"available_credits": 1908,
"operation": "video.compress",
"reserved_credits": 2,
"settings": {
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
},
"resolution": "auto",
"codec": "same",
"frame_rate": "original",
"audio": "keep",
"output_format": "same"
},
"shortfall": 0,
"tasks": [
{
"status": "waiting",
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4"
}
],
"reserved_credits": 2,
"preview": {
"output": {
"format": "mp4",
"extension": "mp4",
"file_name": "lecture-compressed.mp4"
},
"video": {
"codec": "h264",
"width": 1280,
"height": 720,
"frame_rate": "original",
"hdr": "none"
},
"smallest_bytes": 634179
}
}
]
}GET/v1/jobs
该工作区的 API 密钥启动的作业,按从新到旧排列。
查询参数
limitinteger每页包含的作业数。
默认值:
20· 范围:1 至 100cursorstring上一页的
next_cursor。client_referencestring仅返回使用此
client_reference启动的作业。最多 255 个字符
返回
- 200一页作业。
30 个字段
jobsobject[]必填jobs[].idstring必填jobs[].operationstring必填jobs[].statusstring必填waiting:没有任务在运行,且至少有一个任务仍在等待开始。completed:除已取消的任务外,所有任务均已完成。partly_failed:部分任务完成,部分任务失败。failed:除已取消的任务外,所有任务均失败。cancelled:在任何任务完成之前即被取消。可选值:
waiting、processing、completed、partly_failed、failed或cancelledjobs[].client_referencestring | null必填jobs[].settingsobject必填jobs[].created_atstring (date-time)必填jobs[].started_atstring (date-time)jobs[].finished_atstring (date-time)jobs[].reserved_creditsinteger必填jobs[].charged_creditsinteger必填jobs[].tasksobject[]必填每个输入一项,按请求中的顺序排列,包括被跳过的输入。
jobs[].tasks[].idstring被跳过的输入没有此字段,因为它从未成为任务。
jobs[].tasks[].statusstring必填可选值:
waiting、processing、completed、failed、cancelled或skippedjobs[].tasks[].progressinteger必填范围:0 至 100
jobs[].tasks[].stagestring当前正在进行的步骤,例如
processing或uploading。jobs[].tasks[].reasonstring失败或被跳过的原因。
jobs[].tasks[].detailsobjectjobs[].tasks[].reserved_creditsintegerjobs[].tasks[].charged_creditsintegerjobs[].tasks[].inputsobject[]必填jobs[].tasks[].inputs[].file_idstringjobs[].tasks[].inputs[].namestringjobs[].tasks[].outputsobject[]必填jobs[].tasks[].outputs[].file_idstring必填jobs[].tasks[].outputs[].namestring必填jobs[].tasks[].outputs[].sizeinteger必填jobs[].tasks[].outputs[].download_urlstring (URL)可供下载的结果,在
download_expires_at之前有效。jobs[].tasks[].outputs[].download_expires_atstring (date-time)next_cursorstring | null必填将其作为
cursor发送,即可获取下一页。最后一页为 null。
示例
curl "https://api.filesokay.com/v1/jobs?client_reference=lecture-0412" \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/jobs?client_reference=lecture-0412", {
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
const page = await res.json();import os
import requests
res = requests.get(
"https://api.filesokay.com/v1/jobs?client_reference=lecture-0412",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
page = res.json(){
"jobs": [
{
"id": "job_a1c9531eeb00434aba0058796f1ca517",
"operation": "video.compress",
"status": "completed",
"client_reference": "lecture-0412",
"settings": {
"audio": "keep",
"codec": "same",
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
},
"frame_rate": "original",
"resolution": "auto",
"output_format": "same"
},
"created_at": "2026-12-03T09:23:14Z",
"started_at": "2026-12-03T09:23:33Z",
"finished_at": "2026-12-03T09:23:50Z",
"reserved_credits": 2,
"charged_credits": 1,
"tasks": [
{
"id": "task_3f648f64472b4ea4b88568eea9d4f88c",
"status": "completed",
"progress": 100,
"reserved_credits": 2,
"charged_credits": 1,
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4"
}
],
"outputs": [
{
"file_id": "file_a1c8014998a14c4da72d6e6a0c74314c",
"name": "lecture-compressed.mp4",
"size": 6054914,
"download_url": "https://…",
"download_expires_at": "2026-12-06T09:23:50Z"
}
]
}
]
}
],
"next_cursor": null
}POST/v1/jobs
对文件运行一个操作:每个会运行的输入对应一个任务,并为其预留积分。无法使用的输入,或在当前设置下操作不会改变的输入,会被跳过并注明原因,不产生任何费用。当没有任何输入会运行时,响应为 422 nothing_to_run。请发送 Idempotency-Key,确保重试绝不会启动第二个作业。
请求头
Idempotency-Keystring任意唯一文本,例如 UUID。重试同一请求时,每次都原样再次发送。保留 24 小时。
最多 255 个字符
请求体
operationstring必填操作的 ID,可通过
GET /v1/operations获取。inputsobject[]必填按顺序排列的输入文件。最多为该操作的
max_files个。inputs[].file_idstring必填settingsobject操作的设置,遵循其
settings_schema。省略则使用默认值。client_referencestring您自定义的参考值,会随作业及其 Webhook 一起返回,并可在
GET /v1/jobs中搜索。最多 255 个字符
返回
- 200使用相同 Idempotency-Key 和请求体的重试。返回作业的当前状态。
- 201新作业。
28 个字段
idstring必填operationstring必填statusstring必填waiting:没有任务在运行,且至少有一个任务仍在等待开始。completed:除已取消的任务外,所有任务均已完成。partly_failed:部分任务完成,部分任务失败。failed:除已取消的任务外,所有任务均失败。cancelled:在任何任务完成之前即被取消。可选值:
waiting、processing、completed、partly_failed、failed或cancelledclient_referencestring | null必填settingsobject必填created_atstring (date-time)必填started_atstring (date-time)finished_atstring (date-time)reserved_creditsinteger必填charged_creditsinteger必填tasksobject[]必填每个输入一项,按请求中的顺序排列,包括被跳过的输入。
tasks[].idstring被跳过的输入没有此字段,因为它从未成为任务。
tasks[].statusstring必填可选值:
waiting、processing、completed、failed、cancelled或skippedtasks[].progressinteger必填范围:0 至 100
tasks[].stagestring当前正在进行的步骤,例如
processing或uploading。tasks[].reasonstring失败或被跳过的原因。
tasks[].detailsobjecttasks[].reserved_creditsintegertasks[].charged_creditsintegertasks[].inputsobject[]必填tasks[].inputs[].file_idstringtasks[].inputs[].namestringtasks[].outputsobject[]必填tasks[].outputs[].file_idstring必填tasks[].outputs[].namestring必填tasks[].outputs[].sizeinteger必填tasks[].outputs[].download_urlstring (URL)可供下载的结果,在
download_expires_at之前有效。tasks[].outputs[].download_expires_atstring (date-time)
错误
示例
curl -X POST https://api.filesokay.com/v1/jobs \
-H "Authorization: Bearer $FILESOKAY_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"operation": "video.compress",
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c"
}
],
"settings": {
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
}
},
"client_reference": "lecture-0412"
}'const res = await fetch("https://api.filesokay.com/v1/jobs", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
operation: "video.compress",
inputs: [
{
file_id: "file_3cf0737aefa34b89b7b4443c9467d60c"
}
],
settings: {
method: "target_size",
target: {
unit: "percent",
value: 50
}
},
client_reference: "lecture-0412"
}),
});
const job = await res.json();import os
import uuid
import requests
res = requests.post(
"https://api.filesokay.com/v1/jobs",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"operation": "video.compress",
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c"
}
],
"settings": {
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
}
},
"client_reference": "lecture-0412"
},
)
job = res.json(){
"id": "job_a1c9531eeb00434aba0058796f1ca517",
"operation": "video.compress",
"status": "waiting",
"client_reference": "lecture-0412",
"settings": {
"audio": "keep",
"codec": "same",
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
},
"frame_rate": "original",
"resolution": "auto",
"output_format": "same"
},
"created_at": "2026-12-03T09:23:14Z",
"reserved_credits": 2,
"charged_credits": 0,
"tasks": [
{
"id": "task_3f648f64472b4ea4b88568eea9d4f88c",
"status": "waiting",
"progress": 0,
"reserved_credits": 2,
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4"
}
],
"outputs": []
}
]
}GET/v1/jobs/{id}
返回作业及其任务。已完成的任务会列出结果及下载链接,每个链接最长有效 7 天;需要新链接时请再次请求。Webhook 会在作业结束时通知您,因此无需反复查询。
路径参数
idstring必填
返回
- 200该作业。
28 个字段
idstring必填operationstring必填statusstring必填waiting:没有任务在运行,且至少有一个任务仍在等待开始。completed:除已取消的任务外,所有任务均已完成。partly_failed:部分任务完成,部分任务失败。failed:除已取消的任务外,所有任务均失败。cancelled:在任何任务完成之前即被取消。可选值:
waiting、processing、completed、partly_failed、failed或cancelledclient_referencestring | null必填settingsobject必填created_atstring (date-time)必填started_atstring (date-time)finished_atstring (date-time)reserved_creditsinteger必填charged_creditsinteger必填tasksobject[]必填每个输入一项,按请求中的顺序排列,包括被跳过的输入。
tasks[].idstring被跳过的输入没有此字段,因为它从未成为任务。
tasks[].statusstring必填可选值:
waiting、processing、completed、failed、cancelled或skippedtasks[].progressinteger必填范围:0 至 100
tasks[].stagestring当前正在进行的步骤,例如
processing或uploading。tasks[].reasonstring失败或被跳过的原因。
tasks[].detailsobjecttasks[].reserved_creditsintegertasks[].charged_creditsintegertasks[].inputsobject[]必填tasks[].inputs[].file_idstringtasks[].inputs[].namestringtasks[].outputsobject[]必填tasks[].outputs[].file_idstring必填tasks[].outputs[].namestring必填tasks[].outputs[].sizeinteger必填tasks[].outputs[].download_urlstring (URL)可供下载的结果,在
download_expires_at之前有效。tasks[].outputs[].download_expires_atstring (date-time)
错误
示例
curl https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517 \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517", {
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
const job = await res.json();import os
import requests
res = requests.get(
"https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
job = res.json(){
"id": "job_a1c9531eeb00434aba0058796f1ca517",
"operation": "video.compress",
"status": "completed",
"client_reference": "lecture-0412",
"settings": {
"audio": "keep",
"codec": "same",
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
},
"frame_rate": "original",
"resolution": "auto",
"output_format": "same"
},
"created_at": "2026-12-03T09:23:14Z",
"started_at": "2026-12-03T09:23:33Z",
"finished_at": "2026-12-03T09:23:50Z",
"reserved_credits": 2,
"charged_credits": 1,
"tasks": [
{
"id": "task_3f648f64472b4ea4b88568eea9d4f88c",
"status": "completed",
"progress": 100,
"reserved_credits": 2,
"charged_credits": 1,
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4"
}
],
"outputs": [
{
"file_id": "file_a1c8014998a14c4da72d6e6a0c74314c",
"name": "lecture-compressed.mp4",
"size": 6054914,
"download_url": "https://…",
"download_expires_at": "2026-12-06T09:23:50Z"
}
]
}
]
}POST/v1/jobs/{id}/cancel
停止仍在等待或处理中的任务。尚未开始的任务不产生费用;已开始的任务按已运行的时间计费。取消已结束的作业不会有任何变化。
路径参数
idstring必填
返回
- 202正在取消。返回作业的当前状态。
28 个字段
idstring必填operationstring必填statusstring必填waiting:没有任务在运行,且至少有一个任务仍在等待开始。completed:除已取消的任务外,所有任务均已完成。partly_failed:部分任务完成,部分任务失败。failed:除已取消的任务外,所有任务均失败。cancelled:在任何任务完成之前即被取消。可选值:
waiting、processing、completed、partly_failed、failed或cancelledclient_referencestring | null必填settingsobject必填created_atstring (date-time)必填started_atstring (date-time)finished_atstring (date-time)reserved_creditsinteger必填charged_creditsinteger必填tasksobject[]必填每个输入一项,按请求中的顺序排列,包括被跳过的输入。
tasks[].idstring被跳过的输入没有此字段,因为它从未成为任务。
tasks[].statusstring必填可选值:
waiting、processing、completed、failed、cancelled或skippedtasks[].progressinteger必填范围:0 至 100
tasks[].stagestring当前正在进行的步骤,例如
processing或uploading。tasks[].reasonstring失败或被跳过的原因。
tasks[].detailsobjecttasks[].reserved_creditsintegertasks[].charged_creditsintegertasks[].inputsobject[]必填tasks[].inputs[].file_idstringtasks[].inputs[].namestringtasks[].outputsobject[]必填tasks[].outputs[].file_idstring必填tasks[].outputs[].namestring必填tasks[].outputs[].sizeinteger必填tasks[].outputs[].download_urlstring (URL)可供下载的结果,在
download_expires_at之前有效。tasks[].outputs[].download_expires_atstring (date-time)
错误
示例
curl -X POST https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/cancel \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/cancel", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
const job = await res.json();import os
import requests
res = requests.post(
"https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/cancel",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
job = res.json(){
"id": "job_a1c9531eeb00434aba0058796f1ca517",
"operation": "video.compress",
"status": "cancelled",
"client_reference": "lecture-0412",
"settings": {
"audio": "keep",
"codec": "same",
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
},
"frame_rate": "original",
"resolution": "auto",
"output_format": "same"
},
"created_at": "2026-12-03T09:23:14Z",
"finished_at": "2026-12-03T09:23:20Z",
"reserved_credits": 2,
"charged_credits": 0,
"tasks": [
{
"id": "task_3f648f64472b4ea4b88568eea9d4f88c",
"status": "cancelled",
"progress": 0,
"reserved_credits": 2,
"charged_credits": 0,
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4"
}
],
"outputs": []
}
]
}DELETE/v1/jobs/{id}/files
作业结束后,立即删除其输入文件和结果文件。正被另一个运行中作业使用的输入文件会留给该作业。作业本身及其积分记录会保留。
路径参数
idstring必填
返回
- 204已删除。
错误
示例
curl -X DELETE https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/files \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/files", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
console.log(res.status);import os
import requests
res = requests.delete(
"https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/files",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
print(res.status_code)