Files
इस समूह का हर ऑपरेशन: वह क्या लेता है, क्या लौटाता है और किन त्रुटियों के साथ जवाब दे सकता है।
ऑपरेशन
Every file the mailbox holds, sent, received and uploaded, with its bytes, its totals and the download links it went out as. It is the Files page of the app, gated like the mail: threads:read reads it and threads:write uploads and deletes. Only an upload that no message or live download link uses can be deleted, one at a time or up to 100 at once. Received and sent files stay with their message.
GET/files
List files
Every attachment the mailbox holds, sent and received, and every file uploaded to it, the Files page of the app: name, type, size, the address it came to, the thread it belongs to and whether it can be deleted. A deleted file is not listed.
Only an upload that nothing depends on can be deleted, and its deletable is true. Every other file has a usage saying what keeps it: received or sent for a file that came in or went out on a message, linked for an upload that went out as a download link that still works, and scheduled for one attached to a message that has not gone out yet.
Files have scopes of their own: files:read reads them and files:write uploads, deletes and publishes them. Reading an email with threads:read still reads the attachments on it. A key limited to particular addresses or domains sees only the files that arrived at them. It does not see files uploaded for the whole workspace, which have no deliveredTo.
The index starts from the day it shipped, so an older mailbox lists what has arrived since. Older attachments are still on their messages, where GET /threads/{id}/messages/{messageId}/attachments reads them.
Requires the files:read scope.
क्वेरी पैरामीटर
qstringSearches the file name and its type. Words match loosely, and a close spelling is tried when nothing matches exactly.
अधिकतम 200 वर्णkindstringKeeps one kind of file, the choices of the filter on the Files page: images, PDFs, audio, video or text.
इनमें से एक"image""pdf""audio""video""text"directionstringKeeps one direction:
inboundfor files that arrived on a message,outboundfor files that went out on one, anduploadedfor files put on the Files page.इनमें से एक"inbound""outbound""uploaded"addressstringKeeps the files of one address, the
deliveredToof the file, compared without regard to case.अधिकतम 320 वर्णsincestringKeeps files added at or after this moment, as an ISO 8601 date or date-time.
फ़ॉर्मैटdate-timeuntilstringKeeps files added before this moment, as an ISO 8601 date or date-time.
फ़ॉर्मैटdate-timesortstringThe order. A cursor carries on in the order it was handed out in, and one handed out under another
sortis a 400invalid_cursor.इनमें से एक"newest""oldest""largest""name"डिफ़ॉल्ट"newest"limitintegerRows per page, 1 to 100.
कम से कम 1अधिकतम 100डिफ़ॉल्ट25cursorstringThe previous page's
nextCursor, passed back as it came. It is opaque: it holds where the last row sat in this list's order, so a row deleted or edited between pages never breaks the walk, and the next page starts at the first row that sorts after it. A value this list did not hand out is a 400invalid_cursor.
लौटाता है
A page of files in the order sort names.
त्रुटियाँ
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404422500त्रुटि सूची
इनमें भी उपलब्ध
POST/files
Upload a file
Stores a file on the Files page, the way its Upload button does, and answers with it. Send the file itself as the body, up to 100 MB, with its type in Content-Type and its name in filename. Attach it to a send as { "fileId": "..." } in the attachments of POST /emails, which is how a file larger than the inline cap goes out.
A key limited to particular addresses or domains uploads to the first address it holds, which becomes deliveredTo. An unlimited key uploads for the whole workspace and deliveredTo is null, so a narrowed key never reaches that file.
A workspace keeps up to 10 GB of uploads and takes 500 an hour. Nothing makes an upload safe to repeat, so after a lost response look for the file with GET /files before sending it again.
Requires the files:write scope.
क्वेरी पैरामीटर
filenamestringThe name the file is stored and downloaded under, such as
report.pdf, taken as it is. It is cleaned rather than refused: characters a file name cannot hold become_, and a name longer than 255 characters is cut, keeping its extension. Left out,X-Filenameis read instead.
हेडर
X-FilenamestringThe file name, URI encoded, for a client that would rather not put it in the URL.
filenamewins when both are sent.
अनुरोध बॉडी
कंटेंट टाइप*/*
लौटाता है
Stored. direction is uploaded, usage is null and deletable is true.
त्रुटियाँ
- 400
upload_no_name: no name infilenameorX-Filename.upload_empty: the body is empty.upload_dangerous: a program or script, judged by its name, which cannot be stored.- 403
insufficient_scope: the key lacksfiles:write.upload_no_address: a key limited to particular addresses or domains that holds no address.- 413
upload_too_large: the file is larger than 100 MB.- 429
upload_rate_limited: 500 files were uploaded to this workspace in the last hour, deleted ones included. Try again later.- 502
upload_failed: the file could not be stored, and nothing was kept. Try again.- 507
upload_storage_full: the uploads on this workspace would pass 10 GB. Delete some first.
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है401404422500त्रुटि सूची
इनमें भी उपलब्ध
GET/files/stats
Count files
The numbers on the Analytics tab of the Files page in one request: how many files the mailbox holds and how many bytes they take, in all and split into received, sent and uploaded, the file types and the addresses taking the most space, how many files arrived on each of the last 30 days, and the download links still working with how often they were fetched.
Deleted files are not counted. A key limited to particular addresses or domains counts only the files that arrived at them, so files uploaded for the whole workspace are left out of its numbers.
Requires the files:read scope.
लौटाता है
The numbers on the Analytics tab of the Files page.
त्रुटियाँ
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404422500त्रुटि सूची
इनमें भी उपलब्ध
POST/files/batch-delete
Delete files in bulk
Deletes up to 100 files in one call, each the way DELETE /files/{id} deletes one, and reports the rest instead of failing. It is what selecting several files on the Files page and pressing Delete does.
Only an upload that nothing depends on is deleted. A file that was received or sent, or an upload that went out as a download link that still works or is attached to a message that has not gone out yet, comes back in kept with its usage and a reason. An id that is unknown, already deleted or outside the addresses a narrowed key holds comes back in missing. The rule is checked again at the moment of deleting, so a file that became used in between is kept. There is no undo.
Requires the files:write scope.
अनुरोध बॉडी
idsstring[]आवश्यक1 to 100 file ids from
GET /files, each at most 128 characters. A repeated id counts once.1 से 100 आइटम
लौटाता है
What was deleted, what was kept and why, and what was not found.
त्रुटियाँ
- 400
malformed_json: the body is not JSON.- 422
invalid_parameteronidsfor none or more than 100, andunknown_parameterfor any key butids.
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है401403404500त्रुटि सूची
इनमें भी उपलब्ध
GET/files/{id}
Retrieve a file
One file, with usage and deletable saying whether it can be deleted and what keeps it when it cannot. A deleted file, one outside the addresses a narrowed key holds, and an unknown id all answer 404.
Requires the files:read scope.
पाथ पैरामीटर
idstringआवश्यकThe id from
GET /files,file_and 24 hex.
लौटाता है
The file. GET /files/{id}/content has its bytes.
त्रुटियाँ
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404422500त्रुटि सूची
इनमें भी उपलब्ध
DELETE/files/{id}
Delete a file
Deletes an uploaded file: its bytes are removed from storage and it leaves the Files page. The row stays, marked deleted, so the index knows the file existed. There is no undo.
Only an upload that nothing depends on can be deleted, the files whose deletable is true. A file that was received or sent stays with its message, and so does an upload that went out as a download link that still works or is attached to a message that has not gone out yet: those answer 409 file_in_use. An upload that was sent inside a message can still be deleted, because the message keeps its own copy, which is listed as a separate sent file.
It needs the same scope as uploading. A key limited to particular addresses or domains may delete only a file that arrived at one of them. POST /files/batch-delete deletes many at once.
Requires the files:write scope.
पाथ पैरामीटर
idstringआवश्यकThe id from
GET /files,file_and 24 hex.
लौटाता है
Deleted. The bytes are gone and the file leaves the Files page.
objectstring- इनमें से एक
"file" idstringdeletedboolean- इनमें से एक
true
त्रुटियाँ
- 404
resource_not_found: the id is unknown, the file is already deleted, or it is outside the addresses a narrowed key holds.- 409
file_in_useonid: something depends on the file, so it stays. The message names the file and says why, andusageonGET /files/{id}says the same.
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403422500त्रुटि सूची
इनमें भी उपलब्ध
GET/files/{id}/content
Download a file
The file exactly as it is stored, the same bytes the Download action on the Files page saves. A file whose bytes are gone from storage answers 404 like a missing one.
Requires the files:read scope.
पाथ पैरामीटर
idstringआवश्यकThe id from
GET /files,file_and 24 hex.
क्वेरी पैरामीटर
downloadstringtruealways answersContent-Disposition: attachment. Otherwise an image, a PDF or plain text answersinline.इनमें से एक"true""false"
लौटाता है
application/octet-streamThe bytes, under the file's own Content-Type and name.
त्रुटियाँ
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404422500त्रुटि सूची
इनमें भी उपलब्ध
GET/files/{id}/links
List the download links of a file
Every download link made for this file, newest first, revoked ones included. A large attachment sent from OpenEmail travels as a link rather than inside the message, and each send makes a link of its own, and POST /files/{id}/links makes one on purpose, so this is how often each copy was fetched and when last.
A file attached inside a message has no links, because nothing records when those are opened.
Requires the files:read scope.
पाथ पैरामीटर
idstringआवश्यकThe id from
GET /files,file_and 24 hex.
क्वेरी पैरामीटर
limitintegerRows per page, 1 to 100.
कम से कम 1अधिकतम 100डिफ़ॉल्ट25cursorstringThe previous page's
nextCursor, passed back as it came. It is opaque: it holds where the last row sat in this list's order, so a row deleted or edited between pages never breaks the walk, and the next page starts at the first row that sorts after it. A value this list did not hand out is a 400invalid_cursor.
लौटाता है
A page of links, newest first.
त्रुटियाँ
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404422500त्रुटि सूची
इनमें भी उपलब्ध
POST/files/{id}/links
Publish a file at a public link
Makes a public download link for the file that anybody holding it can open without signing in, which is how an image or document is referenced from an email or a web page. Each call makes a new link with its own download count. The link keeps working until it is revoked or the file is deleted.
A file that came in or went out on a message is copied to public storage first. Programs and scripts are refused with 422 file_unshareable.
Requires the files:write scope.
पाथ पैरामीटर
idstringआवश्यकThe id from
GET /files,file_and 24 hex.
अनुरोध बॉडी
domainstringThe domain whose files host serves the link, such as
acme.comforfiles.acme.com. Left out, the domain of the address the file belongs to is used, and a file with no address, or a domain with no files host, is served from the API address.
लौटाता है
The new link. url opens the file with no sign-in.
त्रुटियाँ
- 422
file_unshareable: the file is a program or script, which never gets a public link.
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404500त्रुटि सूची
इनमें भी उपलब्ध
DELETE/files/{id}/links
Revoke every link to a file
Makes the file private, as Make private on the Files page does: every public download link to it stops working at once, including the ones in mail that already went out, and revoked says how many were still working. A file with no live links answers revoked: 0, so the call is safe to repeat. The file itself stays, and POST /files/{id}/links can publish it again at a new link.
A key limited to particular addresses reaches only the files that arrived at them, and any other file is a 404.
Requires the files:write scope.
पाथ पैरामीटर
idstringआवश्यकThe id from
GET /files,file_and 24 hex.
लौटाता है
How many links stopped working.
त्रुटियाँ
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404422500त्रुटि सूची
इनमें भी उपलब्ध
DELETE/files/{id}/links/{linkId}
Revoke a public link
Stops a public link from working, for good, including in mail that already went out with it. Revoking a link that is already revoked answers with it unchanged. An unknown link is a 404 not_found.
Requires the files:write scope.
पाथ पैरामीटर
idstringआवश्यकThe id from
GET /files,file_and 24 hex.linkIdstringआवश्यकThe link id from the links of the file.
लौटाता है
The link, with revokedAt set.
त्रुटियाँ
वे त्रुटियाँ जो कोई भी ऑपरेशन लौटा सकता है400401403404422500त्रुटि सूची
इनमें भी उपलब्ध
ऑब्जेक्ट
Fileobject
objectstring- इनमें से एक
"file" idstringfile_and 24 hex.filenamestringmimeTypestringsizeBytesintegerdirectionstringinboundfor a file that arrived,outboundfor one that was sent,uploadedfor one added on the Files page or withPOST /files.इनमें से एक"inbound""outbound""uploaded"threadIdstring- null हो सकता है
messageIdstring- null हो सकता है
deliveredTostringThe address it came to, lower-cased. An upload carries the first address its uploader was limited to, and none when the uploader was not limited, which the app shows as the whole workspace. A key limited to some addresses sees only files whose
deliveredToit holds, so a file with none recorded reaches only an unrestricted key.null हो सकता हैusagestringWhy the file is kept, or null when it can be deleted.
receivedandsentare files that came in or went out on a message, and they stay with it.linkedis an upload that went out as a download link that still works, andscheduledis one attached to a message that has not gone out yet.null हो सकता हैइनमें से एक"received""sent""linked""scheduled"deletablebooleanWhether
DELETE /files/{id}will take it. True only for an upload that nothing depends on, which is whenusageis null.visibilitystringpublicwhile at least one download link to the file works: a link made withPOST /files/{id}/links, or the link a sent message carries for it.privateotherwise, and every upload starts private.इनमें से एक"public""private"publicUrlstringA working public download link, on the domain's own files host when one is set up and on ours otherwise. A published link is preferred over a link from a sent message. Null while the file is private.
null हो सकता हैcreatedAtstring- फ़ॉर्मैट
date-time
FileBatchDeleteobject
objectstring- इनमें से एक
"file_batch_delete" deletedstring[]The ids this call deleted.
keptobject[]Files something depends on. Nothing happened to them.
idstringfilenamestringusagestringWhat keeps it, the same value as
usageon the file.इनमें से एक"received""sent""linked""scheduled"reasonstringThe same in a sentence, such as "It went out as a download link that still works."
missingstring[]Ids that are unknown, already deleted, or outside the addresses a narrowed key holds.
FileLinkobject
objectstring- इनमें से एक
"file_link" idstringfshr_and 24 hex.fileIdstring- null हो सकता है
filenamestringmimeTypestringsizeBytesintegerhoststringThe files domain the link was served from, or null for the default host.
null हो सकता हैurlstringThe link: as it went out in the message, or as
POST /files/{id}/linkspublished it.publishedbooleanTrue for a link made with
POST /files/{id}/links. Such a link does not stop the file being deleted, and deleting the file revokes it. A link that went out in a message is false and keeps an upload from being deleted while it works.downloadsintegerFetches by a person. Scanners and link previewers are left out.
lastDownloadAtstring- null हो सकता हैफ़ॉर्मैट
date-time revokedAtstringWhen the link stopped working, or null while it still works. An upload with a link that still works cannot be deleted.
null हो सकता हैफ़ॉर्मैटdate-timecreatedAtstring- फ़ॉर्मैट
date-time
FileLinkListobject
objectstring- इनमें से एक
"list" dataFileLink[]hasMorebooleanTrue when another page follows. Pass
nextCursorback ascursorto read it.nextCursorstringAn opaque cursor for the next page, or null on the last page. Pass it back unchanged.
null हो सकता है
FileLinkRevocationobject
objectstringआवश्यक- इनमें से एक
"file_link_revocation" fileIdstringआवश्यकrevokedintegerआवश्यकHow many links were still working and now are not. Links revoked earlier are not counted.
कम से कम 0
FileListobject
objectstring- इनमें से एक
"list" dataFile[]hasMorebooleanTrue when another page follows. Pass
nextCursorback ascursorto read it.nextCursorstringAn opaque cursor for the next page, or null on the last page. Pass it back unchanged.
null हो सकता है
FileStatsobject
objectstring- इनमें से एक
"file_stats" totalsobjectEvery file counted here, however it came.
filesintegerbytesintegerTheir sizes added up.
receivedobjectFiles that came in on a message.
filesintegerbytesintegerTheir sizes added up.
sentobjectFiles that went out on a message.
filesintegerbytesintegerTheir sizes added up.
uploadedobjectFiles uploaded on the Files page or with
POST /files.filesintegerbytesintegerTheir sizes added up.
typesobject[]The 8 types taking the most bytes, largest first.
mimeTypestringfilesintegerbytesinteger
byDayobject[]Files added on each of the last 30 days in UTC, today included, oldest first. A day on which none arrived has no entry, so a chart must fill the gaps.
daystringYYYY-MM-DD.फ़ॉर्मैटdatefilesintegerbytesinteger
addressesobject[]The 6 addresses holding the most bytes, largest first. A file uploaded for the whole workspace has no address, so it counts in the totals and never here.
addressstringfilesintegerbytesinteger
linksobjectThe download links that still work.
sharesintegerHow many links.
downloadsintegerFetches by a person across all of them. Scanners and link previewers are left out.
lastDownloadAtstringThe latest fetch, or null when none was ever fetched.
null हो सकता हैफ़ॉर्मैटdate-time