@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api Gmail API
@base https://gmail.googleapis.com/
@version v1
@auth OAuth2 | OAuth2
@common_fields {userId: str}
@endpoints 79
@hint download_for_search
@toc gmail(79)

@endpoint GET /gmail/v1/users/{userId}/drafts
@optional {includeSpamTrash: bool, maxResults: int, pageToken: str, q: str}
@returns(200) {drafts: [map], nextPageToken: str, resultSizeEstimate: int(uint32)}

@endpoint POST /gmail/v1/users/{userId}/drafts
@returns(200) {id: str, message: map{historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}}

@endpoint POST /gmail/v1/users/{userId}/drafts/send
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint DELETE /gmail/v1/users/{userId}/drafts/{id}
@required {id: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/drafts/{id}
@required {id: str}
@optional {format: str(minimal/full/raw/metadata)}
@returns(200) {id: str, message: map{historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}}

@endpoint PUT /gmail/v1/users/{userId}/drafts/{id}
@required {id: str}
@returns(200) {id: str, message: map{historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}}

@endpoint GET /gmail/v1/users/{userId}/history
@optional {historyTypes: [str], labelId: str, maxResults: int, pageToken: str, startHistoryId: str}
@returns(200) {history: [map], historyId: str(uint64), nextPageToken: str}

@endpoint GET /gmail/v1/users/{userId}/labels
@returns(200) {labels: [map]}

@endpoint POST /gmail/v1/users/{userId}/labels
@optional {color: map{backgroundColor: str, textColor: str}, id: str, labelListVisibility: str(labelShow/labelShowIfUnread/labelHide), messageListVisibility: str(show/hide), messagesTotal: int(int32), messagesUnread: int(int32), name: str, threadsTotal: int(int32), threadsUnread: int(int32), type: str(system/user)}
@returns(200) {color: map{backgroundColor: str, textColor: str}, id: str, labelListVisibility: str, messageListVisibility: str, messagesTotal: int(int32), messagesUnread: int(int32), name: str, threadsTotal: int(int32), threadsUnread: int(int32), type: str}

@endpoint DELETE /gmail/v1/users/{userId}/labels/{id}
@required {id: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/labels/{id}
@required {id: str}
@returns(200) {color: map{backgroundColor: str, textColor: str}, id: str, labelListVisibility: str, messageListVisibility: str, messagesTotal: int(int32), messagesUnread: int(int32), name: str, threadsTotal: int(int32), threadsUnread: int(int32), type: str}

@endpoint PATCH /gmail/v1/users/{userId}/labels/{id}
@required {id: str}
@optional {color: map{backgroundColor: str, textColor: str}, id: str, labelListVisibility: str(labelShow/labelShowIfUnread/labelHide), messageListVisibility: str(show/hide), messagesTotal: int(int32), messagesUnread: int(int32), name: str, threadsTotal: int(int32), threadsUnread: int(int32), type: str(system/user)}
@returns(200) {color: map{backgroundColor: str, textColor: str}, id: str, labelListVisibility: str, messageListVisibility: str, messagesTotal: int(int32), messagesUnread: int(int32), name: str, threadsTotal: int(int32), threadsUnread: int(int32), type: str}

@endpoint PUT /gmail/v1/users/{userId}/labels/{id}
@required {id: str}
@optional {color: map{backgroundColor: str, textColor: str}, id: str, labelListVisibility: str(labelShow/labelShowIfUnread/labelHide), messageListVisibility: str(show/hide), messagesTotal: int(int32), messagesUnread: int(int32), name: str, threadsTotal: int(int32), threadsUnread: int(int32), type: str(system/user)}
@returns(200) {color: map{backgroundColor: str, textColor: str}, id: str, labelListVisibility: str, messageListVisibility: str, messagesTotal: int(int32), messagesUnread: int(int32), name: str, threadsTotal: int(int32), threadsUnread: int(int32), type: str}

@endpoint GET /gmail/v1/users/{userId}/messages
@optional {includeSpamTrash: bool, labelIds: [str], maxResults: int, pageToken: str, q: str}
@returns(200) {messages: [map], nextPageToken: str, resultSizeEstimate: int(uint32)}

@endpoint POST /gmail/v1/users/{userId}/messages
@optional {deleted: bool, internalDateSource: str(receivedTime/dateHeader)}
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint POST /gmail/v1/users/{userId}/messages/batchDelete
@optional {ids: [str]}
@returns(200)

@endpoint POST /gmail/v1/users/{userId}/messages/batchModify
@optional {addLabelIds: [str], ids: [str], removeLabelIds: [str]}
@returns(200)

@endpoint POST /gmail/v1/users/{userId}/messages/import
@optional {deleted: bool, internalDateSource: str(receivedTime/dateHeader), neverMarkSpam: bool, processForCalendar: bool}
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint POST /gmail/v1/users/{userId}/messages/send
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint DELETE /gmail/v1/users/{userId}/messages/{id}
@required {id: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/messages/{id}
@required {id: str}
@optional {format: str(minimal/full/raw/metadata), metadataHeaders: [str]}
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint POST /gmail/v1/users/{userId}/messages/{id}/modify
@required {id: str}
@optional {addLabelIds: [str], removeLabelIds: [str]}
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint POST /gmail/v1/users/{userId}/messages/{id}/trash
@required {id: str}
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint POST /gmail/v1/users/{userId}/messages/{id}/untrash
@required {id: str}
@returns(200) {historyId: str(uint64), id: str, internalDate: str(int64), labelIds: [str], payload: map{body: map{attachmentId: str, data: str(byte), size: int(int32)}, filename: str, headers: [map], mimeType: str, partId: str, parts: [map]}, raw: str(byte), sizeEstimate: int(int32), snippet: str, threadId: str}

@endpoint GET /gmail/v1/users/{userId}/messages/{messageId}/attachments/{id}
@required {messageId: str, id: str}
@returns(200) {attachmentId: str, data: str(byte), size: int(int32)}

@endpoint GET /gmail/v1/users/{userId}/profile
@returns(200) {emailAddress: str, historyId: str(uint64), messagesTotal: int(int32), threadsTotal: int(int32)}

@endpoint GET /gmail/v1/users/{userId}/settings/autoForwarding
@returns(200) {disposition: str, emailAddress: str, enabled: bool}

@endpoint PUT /gmail/v1/users/{userId}/settings/autoForwarding
@optional {disposition: str(dispositionUnspecified/leaveInInbox/archive/trash/markRead), emailAddress: str, enabled: bool}
@returns(200) {disposition: str, emailAddress: str, enabled: bool}

@endpoint GET /gmail/v1/users/{userId}/settings/cse/identities
@optional {pageSize: int, pageToken: str}
@returns(200) {cseIdentities: [map], nextPageToken: str}

@endpoint POST /gmail/v1/users/{userId}/settings/cse/identities
@optional {emailAddress: str, primaryKeyPairId: str}
@returns(200) {emailAddress: str, primaryKeyPairId: str}

@endpoint DELETE /gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}
@required {cseEmailAddress: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}
@required {cseEmailAddress: str}
@returns(200) {emailAddress: str, primaryKeyPairId: str}

@endpoint PATCH /gmail/v1/users/{userId}/settings/cse/identities/{emailAddress}
@required {emailAddress: str}
@optional {emailAddress: str, primaryKeyPairId: str}
@returns(200) {emailAddress: str, primaryKeyPairId: str}

@endpoint GET /gmail/v1/users/{userId}/settings/cse/keypairs
@optional {pageSize: int, pageToken: str}
@returns(200) {cseKeyPairs: [map], nextPageToken: str}

@endpoint POST /gmail/v1/users/{userId}/settings/cse/keypairs
@optional {disableTime: str(google-datetime), enablementState: str(stateUnspecified/enabled/disabled), keyPairId: str, pem: str, pkcs7: str, privateKeyMetadata: [map{kaclsKeyMetadata: map, privateKeyMetadataId: str}], subjectEmailAddresses: [str]}
@returns(200) {disableTime: str(google-datetime), enablementState: str, keyPairId: str, pem: str, pkcs7: str, privateKeyMetadata: [map], subjectEmailAddresses: [str]}

@endpoint GET /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}
@required {keyPairId: str}
@returns(200) {disableTime: str(google-datetime), enablementState: str, keyPairId: str, pem: str, pkcs7: str, privateKeyMetadata: [map], subjectEmailAddresses: [str]}

@endpoint POST /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:disable
@required {keyPairId: str}
@returns(200) {disableTime: str(google-datetime), enablementState: str, keyPairId: str, pem: str, pkcs7: str, privateKeyMetadata: [map], subjectEmailAddresses: [str]}

@endpoint POST /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:enable
@required {keyPairId: str}
@returns(200) {disableTime: str(google-datetime), enablementState: str, keyPairId: str, pem: str, pkcs7: str, privateKeyMetadata: [map], subjectEmailAddresses: [str]}

@endpoint POST /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:obliterate
@required {keyPairId: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/delegates
@returns(200) {delegates: [map]}

@endpoint POST /gmail/v1/users/{userId}/settings/delegates
@optional {delegateEmail: str, verificationStatus: str(verificationStatusUnspecified/accepted/pending/rejected/expired)}
@returns(200) {delegateEmail: str, verificationStatus: str}

@endpoint DELETE /gmail/v1/users/{userId}/settings/delegates/{delegateEmail}
@required {delegateEmail: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/delegates/{delegateEmail}
@required {delegateEmail: str}
@returns(200) {delegateEmail: str, verificationStatus: str}

@endpoint GET /gmail/v1/users/{userId}/settings/filters
@returns(200) {filter: [map]}

@endpoint POST /gmail/v1/users/{userId}/settings/filters
@optional {action: map{addLabelIds: [str], forward: str, removeLabelIds: [str]}, criteria: map{excludeChats: bool, from: str, hasAttachment: bool, negatedQuery: str, query: str, size: int(int32), sizeComparison: str, subject: str, to: str}, id: str}
@returns(200) {action: map{addLabelIds: [str], forward: str, removeLabelIds: [str]}, criteria: map{excludeChats: bool, from: str, hasAttachment: bool, negatedQuery: str, query: str, size: int(int32), sizeComparison: str, subject: str, to: str}, id: str}

@endpoint DELETE /gmail/v1/users/{userId}/settings/filters/{id}
@required {id: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/filters/{id}
@required {id: str}
@returns(200) {action: map{addLabelIds: [str], forward: str, removeLabelIds: [str]}, criteria: map{excludeChats: bool, from: str, hasAttachment: bool, negatedQuery: str, query: str, size: int(int32), sizeComparison: str, subject: str, to: str}, id: str}

@endpoint GET /gmail/v1/users/{userId}/settings/forwardingAddresses
@returns(200) {forwardingAddresses: [map]}

@endpoint POST /gmail/v1/users/{userId}/settings/forwardingAddresses
@optional {forwardingEmail: str, verificationStatus: str(verificationStatusUnspecified/accepted/pending)}
@returns(200) {forwardingEmail: str, verificationStatus: str}

@endpoint DELETE /gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}
@required {forwardingEmail: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}
@required {forwardingEmail: str}
@returns(200) {forwardingEmail: str, verificationStatus: str}

@endpoint GET /gmail/v1/users/{userId}/settings/imap
@returns(200) {autoExpunge: bool, enabled: bool, expungeBehavior: str, maxFolderSize: int(int32)}

@endpoint PUT /gmail/v1/users/{userId}/settings/imap
@optional {autoExpunge: bool, enabled: bool, expungeBehavior: str(expungeBehaviorUnspecified/archive/trash/deleteForever), maxFolderSize: int(int32)}
@returns(200) {autoExpunge: bool, enabled: bool, expungeBehavior: str, maxFolderSize: int(int32)}

@endpoint GET /gmail/v1/users/{userId}/settings/language
@returns(200) {displayLanguage: str}

@endpoint PUT /gmail/v1/users/{userId}/settings/language
@optional {displayLanguage: str}
@returns(200) {displayLanguage: str}

@endpoint GET /gmail/v1/users/{userId}/settings/pop
@returns(200) {accessWindow: str, disposition: str}

@endpoint PUT /gmail/v1/users/{userId}/settings/pop
@optional {accessWindow: str(accessWindowUnspecified/disabled/fromNowOn/allMail), disposition: str(dispositionUnspecified/leaveInInbox/archive/trash/markRead)}
@returns(200) {accessWindow: str, disposition: str}

@endpoint GET /gmail/v1/users/{userId}/settings/sendAs
@returns(200) {sendAs: [map]}

@endpoint POST /gmail/v1/users/{userId}/settings/sendAs
@optional {displayName: str, isDefault: bool, isPrimary: bool, replyToAddress: str, sendAsEmail: str, signature: str, smtpMsa: map{host: str, password: str, port: int(int32), securityMode: str, username: str}, treatAsAlias: bool, verificationStatus: str(verificationStatusUnspecified/accepted/pending)}
@returns(200) {displayName: str, isDefault: bool, isPrimary: bool, replyToAddress: str, sendAsEmail: str, signature: str, smtpMsa: map{host: str, password: str, port: int(int32), securityMode: str, username: str}, treatAsAlias: bool, verificationStatus: str}

@endpoint DELETE /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
@required {sendAsEmail: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
@required {sendAsEmail: str}
@returns(200) {displayName: str, isDefault: bool, isPrimary: bool, replyToAddress: str, sendAsEmail: str, signature: str, smtpMsa: map{host: str, password: str, port: int(int32), securityMode: str, username: str}, treatAsAlias: bool, verificationStatus: str}

@endpoint PATCH /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
@required {sendAsEmail: str}
@optional {displayName: str, isDefault: bool, isPrimary: bool, replyToAddress: str, sendAsEmail: str, signature: str, smtpMsa: map{host: str, password: str, port: int(int32), securityMode: str, username: str}, treatAsAlias: bool, verificationStatus: str(verificationStatusUnspecified/accepted/pending)}
@returns(200) {displayName: str, isDefault: bool, isPrimary: bool, replyToAddress: str, sendAsEmail: str, signature: str, smtpMsa: map{host: str, password: str, port: int(int32), securityMode: str, username: str}, treatAsAlias: bool, verificationStatus: str}

@endpoint PUT /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
@required {sendAsEmail: str}
@optional {displayName: str, isDefault: bool, isPrimary: bool, replyToAddress: str, sendAsEmail: str, signature: str, smtpMsa: map{host: str, password: str, port: int(int32), securityMode: str, username: str}, treatAsAlias: bool, verificationStatus: str(verificationStatusUnspecified/accepted/pending)}
@returns(200) {displayName: str, isDefault: bool, isPrimary: bool, replyToAddress: str, sendAsEmail: str, signature: str, smtpMsa: map{host: str, password: str, port: int(int32), securityMode: str, username: str}, treatAsAlias: bool, verificationStatus: str}

@endpoint GET /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo
@required {sendAsEmail: str}
@returns(200) {smimeInfo: [map]}

@endpoint POST /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo
@required {sendAsEmail: str}
@optional {encryptedKeyPassword: str, expiration: str(int64), id: str, isDefault: bool, issuerCn: str, pem: str, pkcs12: str(byte)}
@returns(200) {encryptedKeyPassword: str, expiration: str(int64), id: str, isDefault: bool, issuerCn: str, pem: str, pkcs12: str(byte)}

@endpoint DELETE /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}
@required {sendAsEmail: str, id: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}
@required {sendAsEmail: str, id: str}
@returns(200) {encryptedKeyPassword: str, expiration: str(int64), id: str, isDefault: bool, issuerCn: str, pem: str, pkcs12: str(byte)}

@endpoint POST /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault
@required {sendAsEmail: str, id: str}
@returns(200)

@endpoint POST /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/verify
@required {sendAsEmail: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/settings/vacation
@returns(200) {enableAutoReply: bool, endTime: str(int64), responseBodyHtml: str, responseBodyPlainText: str, responseSubject: str, restrictToContacts: bool, restrictToDomain: bool, startTime: str(int64)}

@endpoint PUT /gmail/v1/users/{userId}/settings/vacation
@optional {enableAutoReply: bool, endTime: str(int64), responseBodyHtml: str, responseBodyPlainText: str, responseSubject: str, restrictToContacts: bool, restrictToDomain: bool, startTime: str(int64)}
@returns(200) {enableAutoReply: bool, endTime: str(int64), responseBodyHtml: str, responseBodyPlainText: str, responseSubject: str, restrictToContacts: bool, restrictToDomain: bool, startTime: str(int64)}

@endpoint POST /gmail/v1/users/{userId}/stop
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/threads
@optional {includeSpamTrash: bool, labelIds: [str], maxResults: int, pageToken: str, q: str}
@returns(200) {nextPageToken: str, resultSizeEstimate: int(uint32), threads: [map]}

@endpoint DELETE /gmail/v1/users/{userId}/threads/{id}
@required {id: str}
@returns(200)

@endpoint GET /gmail/v1/users/{userId}/threads/{id}
@required {id: str}
@optional {format: str(full/metadata/minimal), metadataHeaders: [str]}
@returns(200) {historyId: str(uint64), id: str, messages: [map], snippet: str}

@endpoint POST /gmail/v1/users/{userId}/threads/{id}/modify
@required {id: str}
@optional {addLabelIds: [str], removeLabelIds: [str]}
@returns(200) {historyId: str(uint64), id: str, messages: [map], snippet: str}

@endpoint POST /gmail/v1/users/{userId}/threads/{id}/trash
@required {id: str}
@returns(200) {historyId: str(uint64), id: str, messages: [map], snippet: str}

@endpoint POST /gmail/v1/users/{userId}/threads/{id}/untrash
@required {id: str}
@returns(200) {historyId: str(uint64), id: str, messages: [map], snippet: str}

@endpoint POST /gmail/v1/users/{userId}/watch
@optional {labelFilterAction: str(include/exclude), labelIds: [str], topicName: str}
@returns(200) {expiration: str(int64), historyId: str(uint64)}

@end
