User Assets

POSThttps://sangtao.ai/api/v2/user-assets/presign

Reference for User Assets.

Upload and manage user media assets (videos, images, audio). Assets are used as intro/outro videos, logos, watermarks, background music, voiceovers, and thumbnails in video creation.

Upload Flow

text
1. POST /user-assets/presign  →  get sasUrl + blobPath
2. PUT  sasUrl (binary)       →  upload file to blob
3. POST /user-assets/confirm  →  register asset in DB
Note: The presign response includes category, maxSizeBytes, and allowedContentTypes — use these for client-side validation before uploading.

Step 1: Presign

POST /api/v2/user-assets/presign

FieldTypeDescription
fileName*stringOriginal file name (e.g. "logo.png")
contentType*stringMIME type (e.g. "image/png", "video/mp4")
bash
curl -X POST https://sangtao.ai/api/v2/user-assets/presign \\
  -H "X-Api-Key: YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{"fileName": "my-logo.png", "contentType": "image/png"}'
json
{
  "success": true,
  "data": {
    "sasUrl": "https://blob.sangtao.ai/...?sv=...&sig=...",
    "blobPath": "d15ed.../user-assets/1e65...png",
    "publicUrl": "https://blob.sangtao.ai/user-assets/...",
    "expiresAt": "2026-06-08T12:30:00Z",
    "category": "image",
    "maxSizeBytes": 52428800,
    "allowedContentTypes": ["image/png", "image/jpeg", "image/webp", "image/svg+xml"]
  }
}

Step 2: Upload to Blob

PUT the file binary directly to the sasUrl with x-ms-blob-type: BlockBlob header.

bash
curl -X PUT "PRESIGNED_SAS_URL" \\
  -H "x-ms-blob-type: BlockBlob" \\
  -H "Content-Type: image/png" \\
  --data-binary @my-logo.png

Step 3: Confirm

POST /api/v2/user-assets/confirm

FieldTypeDescription
blobPath*stringBlob path returned from presign
fileName*stringOriginal file name
contentType*stringMIME type
fileSizeBytes*numberFile size in bytes
purposestringAsset purpose (optional — see table below)
labelstringDisplay label
durationSecnumberDuration in seconds (video/audio)
aspectRatiostringAspect ratio (e.g. "16:9")
bash
curl -X POST https://sangtao.ai/api/v2/user-assets/confirm \\
  -H "X-Api-Key: YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "blobPath": "d15ed.../user-assets/1e65...png",
    "fileName": "my-logo.png",
    "contentType": "image/png",
    "fileSizeBytes": 245000,
    "purpose": "logo"
  }'

List Assets

GET /api/v2/user-assets

FieldTypeDescription
categorystringFilter by category: video, image, audio, document
purposestringFilter by purpose (see purpose table)
bash
curl "https://sangtao.ai/api/v2/user-assets?purpose=logo" \\
  -H "X-Api-Key: YOUR_API_KEY"
json
{
  "success": true,
  "data": [
    {
      "id": 42,
      "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"
    }
  ]
}

Response Fields

FieldTypeDescription
id*numberAsset ID
url*stringPublic URL of the asset
fileName*stringOriginal file name
mimeType*stringMIME type (e.g. "video/mp4")
fileSizeBytes*numberFile size in bytes
category*stringAuto-detected: video, image, audio, document
purpose*stringAsset purpose
labelstringDisplay label (nullable)
thumbnailUrlstringThumbnail URL (nullable)
durationSecnumberDuration in seconds (video/audio)
aspectRatiostringAspect ratio
hasAudiobooleanWhether file has audio track (video/audio)
createdAtstringISO 8601 creation timestamp

Get Asset by ID

GET /api/v2/user-assets/{id}

bash
curl https://sangtao.ai/api/v2/user-assets/42 \\
  -H "X-Api-Key: YOUR_API_KEY"

Update Asset

PUT /api/v2/user-assets/{id}

FieldTypeDescription
labelstringNew display label
purposestringNew purpose
bash
curl -X PUT https://sangtao.ai/api/v2/user-assets/42 \\
  -H "X-Api-Key: YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{"label": "New Label", "purpose": "watermark"}'

Delete Asset

DELETE /api/v2/user-assets/{id}

bash
curl -X DELETE https://sangtao.ai/api/v2/user-assets/42 \\
  -H "X-Api-Key: YOUR_API_KEY"

Bulk Delete

POST /api/v2/user-assets/bulk-delete

bash
curl -X POST https://sangtao.ai/api/v2/user-assets/bulk-delete \\
  -H "X-Api-Key: YOUR_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{"ids": [42, 43, 44]}'

Storage Usage

GET /api/v2/user-assets/usage

bash
curl https://sangtao.ai/api/v2/user-assets/usage \\
  -H "X-Api-Key: YOUR_API_KEY"
json
{
  "success": true,
  "data": {
    "video":    { "count": 3, "maxCount": 20, "storageBytes": 150000000, "maxStorageBytes": 2147483648 },
    "image":    { "count": 12, "maxCount": 100, "storageBytes": 8500000, "maxStorageBytes": 524288000 },
    "audio":    { "count": 2, "maxCount": 30, "storageBytes": 25000000, "maxStorageBytes": 524288000 },
    "document": { "count": 0, "maxCount": 20, "storageBytes": 0, "maxStorageBytes": 209715200 }
  }
}

Purpose Values

PurposeUsed for
outro_videoAppended at end of rendered videos
intro_videoPrepended at start of rendered videos
logoOverlay logo on video during render
watermarkWatermark overlay in render pipeline
background_musicCustom background music for all video types
voiceoverUser-uploaded voice file (replaces TTS)
thumbnailCustom thumbnail for published jobs
generalGeneral reference files

Category Limits

CategoryContent TypesMax SizeMax Items
videovideo/mp4, video/webm500 MB20
imageimage/png, jpeg, webp, svg+xml50 MB100
audioaudio/mpeg, wav, ogg, aac100 MB30
documentapplication/pdf, text/csv, application/json200 MB20

Error Codes

CodeWhen
400Invalid content type or missing required fields
401Not authenticated
404Asset not found or doesn't belong to user
409Conflict — asset with same blobPath already confirmed
429Max items or storage quota exceeded