工作
對已上傳的檔案執行操作。一個工作中,每個要處理的檔案各有一個任務。執行工作說明了設定、狀態和批次處理。
本頁內容
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或skipped其中之一tasks[].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或cancelled其中之一jobs[].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或skipped其中之一jobs[].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或cancelled其中之一client_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或skipped其中之一tasks[].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或cancelled其中之一client_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或skipped其中之一tasks[].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或cancelled其中之一client_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或skipped其中之一tasks[].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)