Skip to content
Developers

    Uploads

    Get an upload link for a file

    Markdown
    POSThttps://api.tiktornado.com/api/v1/uploads

    Scope: posts:write

    Step 1 of posting a file from your computer. The answer gives an uploadUrl and a mediaRef.

    1. Upload the file with an HTTP PUT to uploadUrl, sending only the headers in the answer's headers, for example: curl -X PUT -H 'Content-Type: video/mp4' --upload-file clip.mp4 '<uploadUrl>'.
    2. Pass mediaRef in a post's mediaRefs, or as settings.coverImageRef.

    mediaRef is an opaque value: store it and pass it back exactly as you got it. Ask for one link per file. The link expires, so upload soon after you get it, and post the file soon after you upload it.

    Videos: MP4, MOV or WebM, up to 4 GB, 3 seconds to 10 minutes. Photos: JPEG, PNG or WebP, up to 20 MB.

    This route needs no Idempotency-Key: a repeat simply gives you a new link.

    Request body

    • accountIdstringRequired

      An id, letters and digits only.

      Matches ^[A-Za-z0-9]{1,64}$.

    • filenamestringRequired

      The file's name, for example clip.mp4.

      1 to 255 characters.

    • contentTypestringRequired

      The file's type (file_type_not_supported for any other).

      One of video/mp4, video/quicktime, video/webm, image/jpeg, image/png, image/webp.

    • sizeintegerRequired

      The file's size in bytes. Videos up to 4 GB (file_too_large), photos up to 20 MB (photo_too_large).

      1 to 4,000,000,000.

    Example request

    curl -X POST 'https://api.tiktornado.com/api/v1/uploads' \
      -H "Authorization: Bearer $TIKTORNADO_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "accountId": "j971x2c4ajrq0w8sd5e8fxz3a57v2k8m",
        "filename": "leg-day.mp4",
        "contentType": "video/mp4",
        "size": 48213504
      }'

    Response 201

    The upload link.

    • uploadUrlstringRequired

      Where to upload the file, with an HTTP PUT. For this file only. It expires.

      A URL.

    • mediaRefstringRequired

      An opaque value for the uploaded file. Pass it back exactly as you got it, in mediaRefs or as settings.coverImageRef.

    • methodstringRequired

      Always PUT.

    • headersobjectRequired

      The only headers to send with the upload.

      1 field inside
      • Content-TypestringRequired

    Example
    {
      "uploadUrl": "https://uploads.example.com/put/leg-day.mp4?signature=EXAMPLE",
      "mediaRef": "https://media.example.com/uploads/7f3a9c/leg-day.mp4",
      "method": "PUT",
      "headers": {
        "Content-Type": "video/mp4"
      }
    }

    Errors

    StatusReasonMessage
    400invalid_request

    Something here isn't valid. Check it and try again.

    file_type_not_supported

    This file type isn't supported. Use MP4, MOV or WebM for videos, or JPEG, PNG or WebP for photos.

    file_too_large

    This file is too big. Videos can be up to 4 GB and photos 20 MB.

    photo_too_large

    This photo is too big. Photos can be up to 20 MB.

    account_not_ready

    This account isn't ready to post yet.

    This account is under review by TikTok, so new posts can't be scheduled right now.

    invalid_state

    This can't be done right now. Refresh and try again.

    401api_key_invalid

    This API key isn't valid. Check it, or create a new one in the app.

    403access_locked

    Your subscription isn't active, so this can't be changed right now. Visit Billing to fix it.

    api_scope_missing

    This API key can't do this. Create a key with the access it needs in the app.

    404not_found

    We couldn't find this.

    429slow_down

    You're going a bit fast. Wait a moment and try again.

    500unknown_error

    Something went wrong on our side. We're on it.

    503service_unavailable

    Something went wrong on our side. We're on it.