OverviewProductsPlatformsAPI ReferenceResources

Files

Let users pick Google Drive files, then list, upload, download, share and organise them, or use a Drive file as post media.


Every call takes the accountId of a Google account connected with scopes=files. Ids are Drive file ids.

Before you start

Zernio connects Google Drive with the drive.file scope, never full Drive access. It sees only two kinds of files:

  • files created through Zernio, by POST /v1/files or POST /v1/files/folders;
  • files the user picked in Google Picker, from your app or the Zernio dashboard.

Everything else in the user's Drive stays invisible. Opening it answers 404 with details.reason: "file_not_granted".

Let the user pick Drive files

Create a picker session and send the user's browser to its url. They choose files in Google Picker on a page hosted by Zernio:

Terminal
curl -X POST "https://zernio.com/api/v1/files/picker-sessions" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "ACCOUNT_ID", "redirectUrl": "https://example.com/files/done", "mimeTypes": ["application/pdf"] }'
JSON
{ "data": { "id": "ps_…", "url": "https://zernio.com/files/picker/…", "expiresAt": "2026-10-26T16:10:00.000Z" } }

When the user finishes, Zernio redirects to redirectUrl with pickerSessionId, status=picked and fileIds (comma-separated), or status=cancelled. A file.picked webhook carries the picked files too, so redirectUrl is optional when you handle picks on your server.

FieldWhat it does
redirectUrlWhere to send the user afterwards
fileIdsUp to 50 files to preselect
mimeTypesUp to 30 types to show in the picker
multiselectAllow several files. Default true

A session is single-use and expires after 30 minutes, so create one per pick. A pick is a lasting grant: the file stays readable until the user removes Zernio from their Google account.

List and read files

GET /v1/files?accountId=… lists the granted files and folders. Add folderId to list one folder, or q to search by name:

Terminal
curl "https://zernio.com/api/v1/files?accountId=ACCOUNT_ID&q=invoice&limit=20" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
JSON
{
  "data": [
    {
      "id": "1AbC…",
      "accountId": "ACCOUNT_ID",
      "provider": "google",
      "name": "invoice-october.pdf",
      "kind": "file",
      "mimeType": "application/pdf",
      "size": 48213,
      "downloadable": true,
      "webUrl": "https://drive.google.com/file/d/1AbC…/view"
    }
  ],
  "pagination": { "hasMore": false, "nextCursor": null }
}

GET /v1/files/{fileId}?accountId=… returns one file. limit goes up to 100, default 50.

Download a file

GET /v1/files/{fileId}/download?accountId=… streams the bytes. Google Docs, Sheets, Slides and Drawings have no bytes of their own, so they are exported:

Google typeDownloads as
DocsPDF
SheetsXLSX
SlidesPDF
DrawingsPNG

Other Google types, such as Forms and Sites, have downloadable: false.

Upload a file

POST /v1/files uploads from a URL as JSON, or a file as multipart/form-data:

Terminal
curl -X POST "https://zernio.com/api/v1/files" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "ACCOUNT_ID", "name": "report.pdf", "contentType": "application/pdf", "url": "https://example.com/report.pdf", "parentId": "FOLDER_ID" }'

Set convertTo to a Google Docs, Sheets or Slides type to import the file as one. A file uploaded through Zernio is granted from then on.

Organise and share

  • POST /v1/files/folders creates a folder, with name and an optional parentId.
  • PATCH /v1/files/{fileId} renames a file (name) or moves it (parentId).
  • DELETE /v1/files/{fileId}?accountId=… moves it to the Drive trash.
  • GET /v1/files/{fileId}/share-link?accountId=… makes the file readable by anyone with the link and returns that link.

Use a Drive file in a post

A post's mediaItems accepts { "fileId": "…", "accountId": "…" } next to the usual url items.

Zernio copies the file when the post is created, so it publishes even if the file changes or the account disconnects later.

A folder, or a file that cannot be downloaded, answers 400 on that media item.

A file shared with "Anyone with the link" needs no connected account: send its share link as url (Google Drive links).

How it behaves

  • Uploads by URL accept up to 100 MB, over https only, without redirects, and must download within 20 seconds. Multipart uploads are limited by the 4.5 MB request size, so send larger files by URL.
  • Names are up to 255 characters, without / or \.
  • file.created, file.updated and file.deleted fire for changes to granted files. See Webhooks.

If it fails

ErrorCauseFix
404 with reason: "file_not_granted"The file was neither created through Zernio nor pickedSend the user to a picker session.
400 on urlThe URL is not https, redirects, or the file is over 100 MBUse a direct https link to a smaller file.
412 account_scope_missingThe account has no files areaConnect again with files in scopes.
Was this page helpful?

On this page