Gmail API
  1. users
Gmail API
  • users
    • /gmail/v1/users/{userId}/drafts
      GET
    • /gmail/v1/users/{userId}/drafts
      POST
    • /gmail/v1/users/{userId}/drafts/send
      POST
    • /gmail/v1/users/{userId}/drafts/{id}
      DELETE
    • /gmail/v1/users/{userId}/drafts/{id}
      GET
    • /gmail/v1/users/{userId}/drafts/{id}
      PUT
    • /gmail/v1/users/{userId}/history
      GET
    • /gmail/v1/users/{userId}/labels
      GET
    • /gmail/v1/users/{userId}/labels
      POST
    • /gmail/v1/users/{userId}/labels/{id}
      DELETE
    • /gmail/v1/users/{userId}/labels/{id}
      GET
    • /gmail/v1/users/{userId}/labels/{id}
      PATCH
    • /gmail/v1/users/{userId}/labels/{id}
      PUT
    • /gmail/v1/users/{userId}/messages
      GET
    • /gmail/v1/users/{userId}/messages
      POST
    • /gmail/v1/users/{userId}/messages/batchDelete
      POST
    • /gmail/v1/users/{userId}/messages/batchModify
      POST
    • /gmail/v1/users/{userId}/messages/import
      POST
    • /gmail/v1/users/{userId}/messages/send
      POST
    • /gmail/v1/users/{userId}/messages/{id}
      DELETE
    • /gmail/v1/users/{userId}/messages/{id}
      GET
    • /gmail/v1/users/{userId}/messages/{id}/modify
      POST
    • /gmail/v1/users/{userId}/messages/{id}/trash
      POST
    • /gmail/v1/users/{userId}/messages/{id}/untrash
      POST
    • /gmail/v1/users/{userId}/messages/{messageId}/attachments/{id}
      GET
    • /gmail/v1/users/{userId}/profile
      GET
    • /gmail/v1/users/{userId}/settings/autoForwarding
      GET
    • /gmail/v1/users/{userId}/settings/autoForwarding
      PUT
    • /gmail/v1/users/{userId}/settings/cse/identities
      GET
    • /gmail/v1/users/{userId}/settings/cse/identities
      POST
    • /gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}
      DELETE
    • /gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}
      GET
    • /gmail/v1/users/{userId}/settings/cse/identities/{emailAddress}
      PATCH
    • /gmail/v1/users/{userId}/settings/cse/keypairs
      GET
    • /gmail/v1/users/{userId}/settings/cse/keypairs
      POST
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}
      GET
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:disable
      POST
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:enable
      POST
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:obliterate
      POST
    • /gmail/v1/users/{userId}/settings/delegates
      GET
    • /gmail/v1/users/{userId}/settings/delegates
      POST
    • /gmail/v1/users/{userId}/settings/delegates/{delegateEmail}
      DELETE
    • /gmail/v1/users/{userId}/settings/delegates/{delegateEmail}
      GET
    • /gmail/v1/users/{userId}/settings/filters
      GET
    • /gmail/v1/users/{userId}/settings/filters
      POST
    • /gmail/v1/users/{userId}/settings/filters/{id}
      DELETE
    • /gmail/v1/users/{userId}/settings/filters/{id}
      GET
    • /gmail/v1/users/{userId}/settings/forwardingAddresses
      GET
    • /gmail/v1/users/{userId}/settings/forwardingAddresses
      POST
    • /gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}
      DELETE
    • /gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}
      GET
    • /gmail/v1/users/{userId}/settings/imap
      GET
    • /gmail/v1/users/{userId}/settings/imap
      PUT
    • /gmail/v1/users/{userId}/settings/language
      GET
    • /gmail/v1/users/{userId}/settings/language
      PUT
    • /gmail/v1/users/{userId}/settings/pop
      GET
    • /gmail/v1/users/{userId}/settings/pop
      PUT
    • /gmail/v1/users/{userId}/settings/sendAs
      GET
    • /gmail/v1/users/{userId}/settings/sendAs
      POST
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      DELETE
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      GET
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      PATCH
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      PUT
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo
      GET
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo
      POST
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}
      DELETE
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}
      GET
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault
      POST
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/verify
      POST
    • /gmail/v1/users/{userId}/settings/vacation
      GET
    • /gmail/v1/users/{userId}/settings/vacation
      PUT
    • /gmail/v1/users/{userId}/stop
      POST
    • /gmail/v1/users/{userId}/threads
      GET
    • /gmail/v1/users/{userId}/threads/{id}
      DELETE
    • /gmail/v1/users/{userId}/threads/{id}
      GET
    • /gmail/v1/users/{userId}/threads/{id}/modify
      POST
    • /gmail/v1/users/{userId}/threads/{id}/trash
      POST
    • /gmail/v1/users/{userId}/threads/{id}/untrash
      POST
    • /gmail/v1/users/{userId}/watch
      POST
  1. users

/gmail/v1/users/{userId}/history

GET
/gmail/v1/users/{userId}/history
users
Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing historyId).
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request GET 'https://gmail.googleapis.com//gmail/v1/users//history'
Response Response Example
{
  "history": [
    {
      "id": "string",
      "labelsAdded": [
        {
          "labelIds": [
            "string"
          ],
          "message": {
            "historyId": "string",
            "id": "string",
            "internalDate": "string",
            "labelIds": [
              "string"
            ],
            "payload": {
              "body": {
                "attachmentId": "string",
                "data": "string",
                "size": 0
              },
              "filename": "string",
              "headers": [
                {
                  "name": "string",
                  "value": "string"
                }
              ],
              "mimeType": "string",
              "partId": "string",
              "parts": [
                {}
              ]
            },
            "raw": "string",
            "sizeEstimate": 0,
            "snippet": "string",
            "threadId": "string"
          }
        }
      ],
      "labelsRemoved": [
        {
          "labelIds": [
            "string"
          ],
          "message": {
            "historyId": "string",
            "id": "string",
            "internalDate": "string",
            "labelIds": [
              "string"
            ],
            "payload": {
              "body": {
                "attachmentId": "string",
                "data": "string",
                "size": 0
              },
              "filename": "string",
              "headers": [
                {
                  "name": "string",
                  "value": "string"
                }
              ],
              "mimeType": "string",
              "partId": "string",
              "parts": [
                {}
              ]
            },
            "raw": "string",
            "sizeEstimate": 0,
            "snippet": "string",
            "threadId": "string"
          }
        }
      ],
      "messages": [
        {
          "historyId": "string",
          "id": "string",
          "internalDate": "string",
          "labelIds": [
            "string"
          ],
          "payload": {
            "body": {
              "attachmentId": "string",
              "data": "string",
              "size": 0
            },
            "filename": "string",
            "headers": [
              {
                "name": "string",
                "value": "string"
              }
            ],
            "mimeType": "string",
            "partId": "string",
            "parts": [
              {}
            ]
          },
          "raw": "string",
          "sizeEstimate": 0,
          "snippet": "string",
          "threadId": "string"
        }
      ],
      "messagesAdded": [
        {
          "message": {
            "historyId": "string",
            "id": "string",
            "internalDate": "string",
            "labelIds": [
              "string"
            ],
            "payload": {
              "body": {
                "attachmentId": "string",
                "data": "string",
                "size": 0
              },
              "filename": "string",
              "headers": [
                {
                  "name": "string",
                  "value": "string"
                }
              ],
              "mimeType": "string",
              "partId": "string",
              "parts": [
                {}
              ]
            },
            "raw": "string",
            "sizeEstimate": 0,
            "snippet": "string",
            "threadId": "string"
          }
        }
      ],
      "messagesDeleted": [
        {
          "message": {
            "historyId": "string",
            "id": "string",
            "internalDate": "string",
            "labelIds": [
              "string"
            ],
            "payload": {
              "body": {
                "attachmentId": "string",
                "data": "string",
                "size": 0
              },
              "filename": "string",
              "headers": [
                {
                  "name": "string",
                  "value": "string"
                }
              ],
              "mimeType": "string",
              "partId": "string",
              "parts": [
                {}
              ]
            },
            "raw": "string",
            "sizeEstimate": 0,
            "snippet": "string",
            "threadId": "string"
          }
        }
      ]
    }
  ],
  "historyId": "string",
  "nextPageToken": "string"
}

Request

Path Params
userId
string 
required
The user's email address. The special value me can be used to indicate the authenticated user.
Query Params
historyTypes
array[string]
optional
History types to be returned by the function
labelId
string 
optional
Only return messages with a label matching the ID.
maxResults
integer 
optional
Maximum number of history records to return. This field defaults to 100. The maximum allowed value for this field is 500.
pageToken
string 
optional
Page token to retrieve a specific page of results in the list.
startHistoryId
string 
optional
Required. Returns history records after the specified startHistoryId. The supplied startHistoryId should be obtained from the historyId of a message, thread, or previous list response. History IDs increase chronologically but are not contiguous with random gaps in between valid IDs. Supplying an invalid or out of date startHistoryId typically returns an HTTP 404 error code. A historyId is typically valid for at least a week, but in some rare circumstances may be valid for only a few hours. If you receive an HTTP 404 error response, your application should perform a full sync. If you receive no nextPageToken in the response, there are no updates to retrieve and you can store the returned historyId for a future request.

Responses

🟢200Successful response
application/json
Body
history
array[object (History) {6}] 
optional
List of history records. Any messages contained in the response will typically only have id and threadId fields populated.
id
string <uint64>
optional
The mailbox sequence ID.
labelsAdded
array[object (HistoryLabelAdded) {2}] 
optional
Labels added to messages in this history record.
labelsRemoved
array[object (HistoryLabelRemoved) {2}] 
optional
Labels removed from messages in this history record.
messages
array[object (Message) {9}] 
optional
List of messages changed in this history record. The fields for specific change types, such as messagesAdded may duplicate messages in this field. We recommend using the specific change-type fields instead of this.
messagesAdded
array[object (HistoryMessageAdded) {1}] 
optional
Messages added to the mailbox in this history record.
messagesDeleted
array[object (HistoryMessageDeleted) {1}] 
optional
Messages deleted (not Trashed) from the mailbox in this history record.
historyId
string <uint64>
optional
The ID of the mailbox's current history record.
nextPageToken
string 
optional
Page token to retrieve the next page of results in the list.
Modified at 2023-08-15 05:40:23
Previous
/gmail/v1/users/{userId}/drafts/{id}
Next
/gmail/v1/users/{userId}/labels
Built with