Skip to content
Docs menu

Create an upload

Returns a signed URL for files larger than 100 MB. Send the file as the body of a PUT to url, then call POST /v1/convert with upload_id. Supports Idempotency-Key.

POSThttps://api.switchfile.io/v1/uploads

Needs an API key: Authorization: Bearer YOUR_API_KEY. See Authentication.

Example

curl "https://api.switchfile.io/v1/uploads" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "lecture.mov",
    "size": 734003200
  }'

Parameters

Headers

  • Idempotency-Keystring

    1 to 255 visible ASCII characters, for example a UUID. Send the request again with the same key after a timeout: nothing is created twice. Kept for 24 hours.

    example: 6f1c2b8e-1d8e-4c55-9f0e-3f3f0b0a8f21

  • X-End-Userstring

    Service keys only: an ID for the visitor you act for (1 to 128 characters: letters, digits and . _ : @ -). Quotas and rate limits then count per visitor.

  • X-End-User-Ipstring

    Required with X-End-User: the IP address of the visitor.

Request body

  • filenamestring

    File name. Its extension sets the input format

    1 to 255 characters

  • sizestring (integer) | integer

    Size in bytes, if known. Over the limit, this request fails with 413 FILE_TOO_LARGE

    at least 0

Responses

  • 201Created
    • expires_atstringrequired

      The upload_id works until this time

    • headersmap of stringrequired

      Headers the PUT request must send (usually none)

      keys match ^(.*)$

    • max_file_sizestring (integer) | integerrequired
    • methodstringrequired

      one of "PUT"

    • upload_idstring (uuid)required
    • urlstringrequired

      Send the file as the body of a PUT request to this URL

    • url_expires_atstringrequired

      Start the PUT before this time

    201 application/json
    {
      "upload_id": "7d1f0f7e-0b55-4a8e-8c5b-9d8e3f1a2b3c",
      "method": "PUT",
      "url": "https://api.switchfile.io/v1/uploads/7d1f0f7e-0b55-4a8e-8c5b-9d8e3f1a2b3c/content?expires=1762538401&signature=3f9c2a7d41e8b6c05d1f9e2a7b4c8d3e6f0a1b2c3d4e5f60718293a4b5c6d7e8",
      "headers": {},
      "max_file_size": 1073741824,
      "url_expires_at": "2026-11-06T18:15:00+00:00",
      "expires_at": "2026-11-07T18:00:00+00:00"
    }
  • 401The API key is missing or not valid
    401 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-unauthenticated",
      "title": "Unauthenticated",
      "status": 401,
      "code": "UNAUTHENTICATED",
      "detail": "Missing or invalid API key."
    }
  • 403Not allowed: a signed URL is wrong or expired, or X-End-User was sent without a service key
    403 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-end-user-not-allowed",
      "title": "End user not allowed",
      "status": 403,
      "code": "END_USER_NOT_ALLOWED",
      "detail": "The X-End-User header is only allowed with a service key."
    }
  • 404Does not exist for this account
    404 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-not-found",
      "title": "Not found",
      "status": 404,
      "code": "NOT_FOUND",
      "detail": "Conversion not found."
    }
  • 409Conflict with the current state
    409 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-idempotency-key-in-use",
      "title": "Idempotency key in use",
      "status": 409,
      "code": "IDEMPOTENCY_KEY_IN_USE",
      "detail": "A request with this Idempotency-Key is still running."
    }
  • 411The request has a body but no Content-Length header
    411 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-length-required",
      "title": "Length required",
      "status": 411,
      "code": "LENGTH_REQUIRED",
      "detail": "A Content-Length header is required for this request."
    }
  • 413size is over max_file_size
    413 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-file-too-large",
      "title": "File too large",
      "status": 413,
      "code": "FILE_TOO_LARGE",
      "detail": "The file is larger than the allowed maximum."
    }
  • 422Invalid data. errors names the fields
    422 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-invalid-data",
      "title": "Invalid data",
      "status": 422,
      "code": "INVALID_DATA",
      "detail": "The request contains invalid data.",
      "errors": {
        "to": [
          "Expected string"
        ]
      }
    }
  • 429Too many requests or a daily quota is used up. See Retry-After
    429 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-rate-limit-exceeded",
      "title": "Rate limit exceeded",
      "status": 429,
      "code": "RATE_LIMIT_EXCEEDED",
      "detail": "Too many requests. Try again in 12 seconds."
    }

Error bodies and codes are explained in Errors.