Create a REST API upload session
Start a REST API upload with the correct destination, size, scope, and multipart settings, then inspect the returned session before sending bytes.
Last reviewed
Create an upload session only after the destination and credential boundaries are known. The REST base is https://api.dosya.dev/api, and requests authenticate with Authorization: Bearer dos_….

Requirements
Use an Upload only or Full access key that permits the REST API surface. A workspace pin is compatible with REST; a folder anchor is not. Folder-anchored keys are rejected before the upload route runs.
An ordinary REST upload requires both upload_files and access_upload in the current workspace role. Only the SFTP gateway bypasses the upload-page gate because its separate access_sftp permission governs that surface. Dosya can answer You don't have upload permission in this workspace or You don't have access to the upload page when either REST role gate fails.
Steps
- Choose the destination workspace and, when the file belongs below a folder, record that folder’s
fld_…identifier. - Send
POST /api/upload/initwith JSON containingworkspace_id,file_name, and the byte valuefile_size; addfolder_idonly for a non-root destination. - Add
mime_typewhen known. It defaults toapplication/octet-stream;file_idandexpected_versionare for deliberate version replacement, whileforce_multipartmust be a Boolean. - Check the 201 response for the same workspace, sanitized filename, declared size, MIME type, extension, region, and a new
session_id. - Read
resumable:nullmeans send one PUT toupload_url; an object means use itspart_upload_url,complete_url, andstatus_urlvalues. - Store the session details beside the local transfer state, then begin sending bytes only after the returned destination and transfer mode match the intended upload.
Request rules and limits
A filename is sanitized before validation and may contain at most 255 characters. Supply an accurate numeric file_size; omission is treated as zero, and a negative value is refused. expected_version, when present, must be a non-negative integer. force_multipart:true requires a file larger than zero bytes.
Files above 50 MiB use multipart automatically. A smaller file can opt in with force_multipart:true. Multipart sessions use 10 MiB parts and report total_parts; smaller ordinary sessions return resumable:null.
Initialization also checks storage quota, the credential’s maximum file size, workspace extension and size policies, per-member storage, the destination folder, locks, and concurrency. There is no separate Idempotency-Key header for this endpoint.
Expected result
The API returns HTTP 201 with ok:true, a unique session_id, upload_url, normalized file details, and either a multipart instruction object or resumable:null. No file is complete merely because the session exists.
Troubleshooting
workspace_id is required, file_name is required, and file_size must not be negative identify malformed input. force_multipart must be a boolean and force_multipart requires a file_size greater than 0 explain multipart setup errors. A 403 mentioning a folder anchor means the key must be recreated without that REST-incompatible restriction.

Related guides
Was this helpful?
Loading helpfulness results…
Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.
Questions and replies
Ask about the steps in this guide. Questions are reviewed before publication.
Keep account details, credentials and private files out of public questions. Use private support for those.
Loading questions…
Sign in to your Dosya account to ask a question.