What It Is
A script holding a full API key works an agent inbox's Drive over REST, as an agent: it keeps to the modes the owner set, the secret check and the storage limit, exactly as a connected session does. A key pinned to one agent works that agent's Drive. An account key works any agent inbox of the account by name. Neither reaches your own inbox's Drive or a business's, so give a script an agent inbox of its own, for example one named ci.
What You Need
- 1 A full API key, made by you in the app under API Keys. Put it in $HOMING_API_KEY yourself, in your shell or your CI's secret store, and never in a script or a prompt. An approvals key does not open this door.
- 2 An agent inbox for the script, made in the app under Agent Inboxes. Its handle (or the part after the dot) is the {inbox} in every address below.
Read a File
The answer is the file's receipt: its text inline up to the inline limit, otherwise a short-lived download link. With download=1 the address redirects to that link, so curl -L saves the bytes. Add version to read an older one.
Save a File
The body is the file. A put with text or bytes in the request takes up to 256 KB; for a larger file, send size_bytes (and sha256) with no body and the answer carries a one-time upload address to PUT the bytes to. Send a client_id of your own: a retry with the same one answers unchanged and writes nothing. if_version refuses the save if the file moved on since you read it.
List, Move and Delete
GET /drive/{inbox} lists a folder (path), searches (find, since) and pages (skip), with the real total. POST /drive/{inbox}/move takes path and to, and moves a folder when both end in a slash. DELETE on a file's address, or a folder's with a trailing slash, moves it to the trash, where you can restore it from the app for 30 days. Nothing here purges, restores, shares or changes a mode.
What You Will See
- 1 A refusal keeps the receipt's code and words under its HTTP status: read_only (403) where the owner set a folder to Read Only, version_conflict (409), secret_in_content (422), storage_full and files_full (507), rate_limited (429, with Retry-After).
- 2 A path the owner keeps Private is the same file_not_found as a path that is not there.
- 3 An inbox that is not the key's to work, another account's, a retired agent and your own inbox are all one 404, the same as an inbox that does not exist. A wrong, revoked or approvals key is a 401.
- 4 Every save and delete is recorded with the key that made it, and the owner sees it in the app.