Upload To OneDrive
POST /v1/api/integration/onedrive
POST https://api.torbox.app/v1/api/integration/onedrive
- Operation ID:
upload_to_onedrive - Group: Integrations
- Auth: API key,
Authorization: Bearer <api key>(Sign in with TorBox gives the same key)
Overview
Uploads a file, or a zip of a whole download, from your TorBox account to a OneDrive. Send the id of the torrent, usenet download or web download, its type, and either the file_id of one file or zip set to true. In onedrive_token you send a OneDrive (Microsoft) OAuth access token for the drive to upload to. The login started by Authenticate OAuth with the provider onedrive asks Microsoft for the files.readwrite.all scope and ends with such a token.
The route answers at once with a job_id. The upload itself runs in the background as a transfer job, and nothing is checked with OneDrive before the answer, so a token OneDrive does not accept only shows up as a failed job. Follow the job with Get Specific Job (/v1/api/integration/job/{job_id}), Get All Jobs (/v1/api/integration/jobs) or Get All Jobs By Hash (/v1/api/integration/jobs/{hash}), and stop it with Cancel Specific Job.
The job goes from "pending" through "preparing" and "uploading" to "completed" or "failed". Its detail says what it is doing or why it failed, and its progress runs from 0 to 1. When it is completed, its download_url is the link to the file on OneDrive and you get an "Upload Complete" notification. A failed job is deleted about an hour after it failed, a completed job about 7 days after it completed.
The download has to be cached on TorBox, otherwise the job fails. If you send neither file_id nor zip, the request is still queued, but there is no file to upload and the job fails. The file is saved under the onedrive_save_path of your settings, or in the root of the drive when that setting is empty. A file with the same name in that place is replaced.
Authorization
Requires an API key using the Authorization Bearer Header.
Request body (application/json)
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | yes | Id of the torrent, usenet download or web download to upload. It has to be one of your own downloads. Required. |
file_id | integer | no | Id of the file to upload, from the download's files. Leave out when zip is true. |
zip | boolean | no | Upload the whole download as one zip instead of a single file. Takes precedence over file_id. Optional, default false. |
type | string | no | Which kind of download id refers to. One of torrent, usenet or webdownload. Optional, default torrent. |
onedrive_token | string | yes | OneDrive OAuth access token for the drive to upload to. It is issued by Microsoft, not by TorBox. Required. |
Responses
200Successful Response400Bad Request401Unauthorized403Forbidden404Not Found422Validation Error429Too Many Requests500Internal Server Error503Service Unavailable