harbor0APIBeta

Beta. The harbor0 API is still in beta, so routes and responses may change before it is final. What beta means

Uploading files

File bytes never pass through the API itself. You create an upload, the API signs URLs for each part, you PUT the bytes straight to storage, and then you complete the upload. The file appears in My Drive only when the upload completes, all at once.

1. Create the upload

POST /v1/uploads
{
  "operationId": "3f0c6a1e-5d1b-4a8e-9a63-0d6c2b5f7e21",
  "parentId": "9b7d…",
  "name": "holiday.mp4",
  "sizeBytes": 734003200,
  "mimeType": "video/mp4",
  "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  "modifiedAt": "2026-11-30T09:12:44.000Z",
  "fileCreatedAt": "2026-11-29T17:40:02.000Z"
}
Field
operationIdA new UUID for this upload. Retrying with the same one returns the same upload.
parentIdThe folder to upload into, or null for the top of My Drive.
nameThe file's name.
sizeBytesThe exact number of bytes you will upload.
mimeTypeThe file's type. When left out, the file is stored as application/octet-stream.
contentHashThe SHA-256 of the bytes, in hex, if you know it now. You can also give it only when completing.
modifiedAt, fileCreatedAtThe file's own times, shown in the apps.
driveItemId, baseRevisionTo upload a new version of an existing file instead of a new file. See below.
encryptedtrue for an end-to-end encrypted upload. See Uploading to an encrypted account.

The response holds the upload and your storage after reserving room for it:

{
  "upload": {
    "id": "u_81c…",
    "state": "CREATED",
    "multipart": true,
    "partSizeBytes": 67108864,
    "expectedSizeBytes": 734003200,
    "expiresAt": "2026-12-04T10:15:00.000Z"
  },
  "storage": { "quotaBytes": 214748364800, "usedBytes": 1048576, "reservedBytes": 734003200, "availableBytes": 214013312000 }
}

The room is reserved now, so an upload that starts will not run out of space half way. If there isn't enough room, you get 409 STORAGE_QUOTA_EXCEEDED before any bytes move. If a file with that name is already in the folder, you get 409 NAME_CONFLICT; upload a new version of it instead.

2. Send the parts

The file is split into parts of exactly partSizeBytes (at least 64 MiB; larger for very large files, so no file needs more than 10,000 parts). The last part holds whatever is left. Part numbers start at 1, and a file smaller than one part is a single part, number 1. An empty file is also one part, of zero bytes.

Ask for signed URLs for the parts you are about to send, up to a few at a time:

POST /v1/uploads/{uploadId}/parts
{ "partNumbers": [1, 2, 3, 4] }
{
  "parts": [
    { "partNumber": 1, "uploadUrl": "https://…", "expiresAt": "2026-12-03T10:30:00.000Z" },
    { "partNumber": 2, "uploadUrl": "https://…", "expiresAt": "2026-12-03T10:30:00.000Z" }
  ]
}

PUT each part's bytes to its URL. Send no Authorization header and no Content-Type; the URL is already signed, and for an exact Content-Length of that part. Keep the ETag header from each response, quotes included:

curl -s -X PUT --data-binary @part-1.bin "$UPLOAD_URL" -D - -o /dev/null | grep -i '^etag:'
# ETag: "9b2cf535f27731c974343645a3985328"

Signed URLs work for 15 minutes. Ask again for any you didn't use in time. You can send several parts at once; 4 at a time is a good start.

3. Complete the upload

POST /v1/uploads/{uploadId}/complete
{
  "parts": [
    { "partNumber": 1, "etag": "\"9b2cf535f27731c974343645a3985328\"" },
    { "partNumber": 2, "etag": "\"6f1ed002ab5595859014ebf0951522d9\"" }
  ],
  "contentHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}

List every part, in order, with its ETag, and the SHA-256 of the whole file. The response is { "item": … }: the new file, or the file with its new version. Completing again with the same parts returns the same item, so it is safe to retry.

harbor0 checks the stored bytes against contentHash after the upload completes. If they differ, the file is kept but marked with uploadMismatch: true, so you can upload it again. Hash the bytes as you read them for upload, so the hash describes what you actually sent.

Uploading a new version

To replace the content of an existing file, create the upload with its ID and current revision:

{
  "operationId": "…",
  "driveItemId": "c41f0a8e-…",
  "baseRevision": 3,
  "name": "notes.txt",
  "sizeBytes": 940,
  "contentHash": "…"
}

The file keeps its name and place, the earlier content becomes a version, and revision goes up. If the file changed since you read it, you get 409 REVISION_CONFLICT.

Resuming an upload

An upload stays open for 24 hours, and longer while parts keep arriving. To pick up an interrupted upload, read it:

GET /v1/uploads/{uploadId}
{
  "upload": { "id": "u_81c…", "state": "UPLOADING", "partSizeBytes": 67108864, "…": "…" },
  "parts": [ { "partNumber": 1, "etag": "\"9b2c…\"" }, { "partNumber": 2, "etag": "\"6f1e…\"" } ]
}

parts lists the parts storage already holds. Sign and send the missing ones, then complete with the full list. Your SHA-256 must cover the whole file, so read the parts you skip as well, or keep the hash state from the earlier run.

Cancelling

DELETE /v1/uploads/{uploadId}

The upload is aborted, its parts are discarded and the reserved room is released. Uploads you abandon are cleaned up automatically once they expire.

Many small files

For lots of small files (up to 8 MiB each), two batch routes save requests. POST /v1/uploads/batch creates up to 25 uploads at once, each with its one signed part URL already included. After you PUT each file, POST /v1/uploads/batch/finish completes them together with each file's uploadId, etag and contentHash. Each file gets its own result, so one failure does not stop the rest. See the API reference for the exact shapes.

A complete example

The example clients upload files with exactly these steps, encrypting them first when the account uses end-to-end encryption. In Node.js, the upload part looks like this:

const { upload } = await api('POST', '/v1/uploads', {
  operationId: randomUUID(), parentId, name, sizeBytes: bytes.length, contentHash,
});
const count = Math.max(1, Math.ceil(bytes.length / upload.partSizeBytes));
const parts = [];
for (let first = 1; first <= count; first += 10) {
  const partNumbers = Array.from({ length: Math.min(10, count - first + 1) }, (_, i) => first + i);
  const signed = await api('POST', `/v1/uploads/${upload.id}/parts`, { partNumbers });
  for (const part of signed.parts) {
    const start = (part.partNumber - 1) * upload.partSizeBytes;
    const res = await fetch(part.uploadUrl, {
      method: 'PUT',
      body: bytes.subarray(start, start + upload.partSizeBytes),
    });
    parts.push({ partNumber: part.partNumber, etag: res.headers.get('ETag') });
  }
}
const { item } = await api('POST', `/v1/uploads/${upload.id}/complete`, { parts, contentHash });