User Assets
Xác nhận upload
Bước 3 khi upload asset: đăng ký file đã upload thành asset.
https://api.sangtao.ai/v2/user-assets/confirmXác thực
X-Api-Keystring · headerbắt buộcAPI key của bạn, tạo ở trang API key trong tài khoản.
Body
fileKeystringbắt buộcfileKey mà bước presign trả về
fileNamestringbắt buộcTên file gốc
contentTypestringbắt buộcMIME type
fileSizeBytesnumberbắt buộcKích thước file (bytes)
purposestringMục đích asset — ý nghĩa từng giá trị: bảng Giá trị Purpose ở trang Tạo link upload
Giá trị có thể:
outro_videointro_videologowatermarkbackground_musicvoiceoverthumbnailgenerallabelstringNhãn hiển thị
durationSecnumberThời lượng giây (video/audio)
aspectRatiostringTỷ lệ khung (ví dụ "16:9")
Response
Asset, gồm các field sau:
idstringbắt buộcID của asset, ua_ cộng 9 ký tự chữ và số (ví dụ "ua_3kT9qPz0B")
urlstringbắt buộcURL công khai của asset
fileNamestringbắt buộcTên file gốc
mimeTypestringbắt buộcMIME type (ví dụ "video/mp4")
fileSizeBytesnumberbắt buộcKích thước (bytes)
categorystringbắt buộcTự phát hiện
Giá trị có thể:
videoimageaudiodocumentpurposestringbắt buộcMục đích asset
Giá trị có thể:
outro_videointro_videologowatermarkbackground_musicvoiceoverthumbnailgenerallabelstringNhãn hiển thị (nullable)
thumbnailUrlstringURL thumbnail (nullable)
durationSecnumberThời lượng (video/audio)
aspectRatiostringTỷ lệ khung
hasAudiobooleanFile có audio track không (video/audio)
createdAtstringThời điểm tạo (ISO 8601)
Mã lỗi
| Mã | errorCode | Khi nào |
|---|---|---|
| 400 | UNSUPPORTED_FILE_TYPE | Content type không được nhận cho category này (xem Giới hạn theo Category) |
| 400 | VALIDATION_ERROR | Thiếu fileKey |
| 400 | UPLOAD_FAILED | Không xác nhận được file đã tải lên (lỗi lưu trữ) — thử lại |
| 409 | ASSET_ALREADY_CONFIRMED | fileKey này đã được xác nhận rồi |
| 429 | QUOTA_EXCEEDED | Đã chạm trần số file hoặc dung lượng của category |
/user-assets/confirmcurl -X POST "https://api.sangtao.ai/v2/user-assets/confirm" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fileKey": "d15ed…/user-assets/1e65….png",
"fileName": "my-logo.png",
"contentType": "image/png",
"fileSizeBytes": 245000,
"purpose": "logo"
}'{
"success": true,
"data": {
"id": "ua_3kT9qPz0B",
"url": "https://blob.sangtao.ai/user-assets/abc123/my-logo.png",
"fileName": "my-logo.png",
"mimeType": "image/png",
"fileSizeBytes": 245000,
"category": "image",
"purpose": "logo",
"label": "My Brand Logo",
"thumbnailUrl": null,
"durationSec": null,
"aspectRatio": null,
"hasAudio": false,
"createdAt": "2026-06-08T10:30:00Z"
}
}/user-assets/confirmcurl -X POST "https://api.sangtao.ai/v2/user-assets/confirm" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fileKey": "d15ed…/user-assets/1e65….png",
"fileName": "my-logo.png",
"contentType": "image/png",
"fileSizeBytes": 245000,
"purpose": "logo"
}'{
"success": true,
"data": {
"id": "ua_3kT9qPz0B",
"url": "https://blob.sangtao.ai/user-assets/abc123/my-logo.png",
"fileName": "my-logo.png",
"mimeType": "image/png",
"fileSizeBytes": 245000,
"category": "image",
"purpose": "logo",
"label": "My Brand Logo",
"thumbnailUrl": null,
"durationSec": null,
"aspectRatio": null,
"hasAudio": false,
"createdAt": "2026-06-08T10:30:00Z"
}
}