작업 실행
작업은 업로드한 파일 하나 이상에 오퍼레이션 하나를 실행합니다. 즉시 시작되어 백그라운드에서 실행되며, 파일별 처리 결과를 알려 줍니다.
이 페이지의 내용
오퍼레이션은 video.compress처럼 작업이 수행하는 처리입니다. GET /v1/operations는 전체 목록을, GET /v1/operations/{id}는 설정 스키마를 포함한 오퍼레이션 하나를 반환합니다.
curl https://api.filesokay.com/v1/operations/video.compressconst res = await fetch("https://api.filesokay.com/v1/operations/video.compress");
const operation = await res.json();import requests
res = requests.get(
"https://api.filesokay.com/v1/operations/video.compress",
)
operation = res.json()각 오퍼레이션은 어떤 입력을 받고 어떻게 작동하는지 다음 필드로 알려 줍니다.
| 필드 | 의미 |
|---|---|
input_formats | 받는 파일 확장자입니다. 다른 확장자의 파일이라도 함께 보낸 type이 video/mp4처럼 오퍼레이션이 다루는 종류라면 받습니다. |
max_files | 작업 하나가 받는 입력 파일의 최대 개수입니다. |
limits.max_file_bytes | 입력 파일의 최대 크기(바이트)입니다. |
grouping | separate: 파일마다 태스크가 하나씩 생기고, 결과도 각각 따로 나옵니다. together: 병합처럼 모든 파일을 태스크 하나로 처리합니다. |
settings_schema | 설정이 따르는 JSON Schema로, 모든 설정의 기본값이 포함됩니다. |
오퍼레이션과 입력 파일 ID를 보내고, 필요하면 설정과 자체 참조 값도 함께 보내세요. 재시도로 작업이 두 번 시작되지 않도록 Idempotency-Key도 보내세요.
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": []
}
]
}settings는 오퍼레이션의 스키마에 따라 검증됩니다. 생략한 설정에는 기본값이 적용되며, 작업에는 기본값이 채워진 전체 설정이 표시됩니다.tasks에는 입력마다 태스크가 하나씩, 보낸 순서대로 들어 있습니다.reserved_credits는 이 작업에 들 수 있는 최대 비용입니다. 실제로는 사용한 만큼만 차감됩니다. 자세한 내용은 크레딧을 참고하세요.
POST /v1/estimates는 POST /v1/jobs와 같은 본문을 받지만 아무것도 실행하지 않습니다. 작업에 들 수 있는 최대 비용, 보유 크레딧, 부족한 크레딧 수, 파일별 예상 결과를 응답합니다.
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
}
}
]
}| 작업 상태 | 의미 |
|---|---|
waiting | 실행 중인 태스크가 없고, 시작을 기다리는 태스크가 하나 이상 있습니다. |
processing | 태스크가 하나 이상 실행 중입니다. |
completed | 취소된 태스크를 제외한 모든 태스크가 완료되었습니다. |
partly_failed | 일부 태스크는 완료되고 일부는 실패했습니다. |
failed | 취소된 태스크를 제외한 모든 태스크가 실패했습니다. |
cancelled | 태스크가 하나라도 완료되기 전에 취소되었습니다. |
태스크마다 waiting, processing, completed, failed, cancelled, skipped 중 하나의 status가 있습니다. 실행 중인 태스크는 0~100 사이의 progress를 표시하고, 실패하거나 건너뛴 태스크는 reason을 알려 줍니다.
작업 하나로 오퍼레이션의 max_files까지 여러 파일을 처리할 수 있습니다. separate 그룹화에서는 파일마다 별도의 태스크가 되므로, 한 파일이 실패해도 다른 파일은 계속 처리되고 실패한 파일에는 크레딧이 차감되지 않습니다.
사용할 수 없는 파일은 이유와 함께 건너뛰고 나머지 파일만 실행합니다. 건너뛴 파일에는 비용이 들지 않습니다. 건너뛰는 이유는 다음과 같습니다.
| 이유 | 의미 |
|---|---|
not_found | 이 ID를 가진 업로드 파일이 없습니다. |
not_ready | 파일 업로드가 아직 완료되지 않았습니다. |
refused | 파일 검사에서 거부되었습니다. |
check_failed | FilesOkay 측 문제로 파일 검사에 실패했습니다. |
other_operation | 다른 오퍼레이션용으로 업로드된 파일입니다. |
file_in_use | 다른 작업에서 사용 중입니다. |
repeated | 이 작업에 같은 파일이 두 번 들어 있습니다. |
오퍼레이션은 이미 목표 크기보다 작은 동영상처럼, 지정한 설정으로는 달라질 것이 없는 파일도 건너뛸 수 있습니다. 실행할 파일이 하나도 없으면 작업이 시작되지 않고, 요청이 파일별 이유와 함께 nothing_to_run으로 거부됩니다. 반면 모든 파일로 결과 하나를 만드는 together 그룹화 오퍼레이션은 대신 작업 전체를 files_unusable로 거부합니다.
client_reference에는 주문 번호처럼 작업을 식별하는 자체 ID를 최대 255자까지 넣을 수 있습니다. 이 값은 작업과 모든 웹훅 메시지에 함께 반환되며, GET /v1/jobs?client_reference=…로 작업을 찾을 수 있습니다. 고유한 값일 필요는 없습니다.
POST /v1/jobs/{id}/cancel은 아직 대기 중이거나 실행 중인 태스크를 중단합니다. 시작하지 않은 태스크에는 비용이 들지 않고, 이미 시작한 태스크는 실행된 시간만큼 차감됩니다. 이미 끝난 작업은 취소해도 아무것도 바뀌지 않습니다.
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()