---
title: "GET /users/{userId}/history"
method: GET
path: "/users/{userId}/history"
tags: ["users"]
---

# GET /users/{userId}/history

`GET /users/{userId}/history`

Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing `historyId`).

## Path parameters

- `userId` string, required

## Query parameters

- `$.xgafv` '1' | '2' — V1 error format
- `access_token` string
- `alt` 'json' | 'media' | 'proto' — Data format for response
- `callback` string
- `fields` string
- `key` string
- `oauth_token` string
- `prettyPrint` boolean
- `quotaUser` string
- `upload_protocol` string
- `uploadType` string
- `historyTypes` string[]
- `labelId` string
- `maxResults` integer
- `pageToken` string
- `startHistoryId` string

## Response `200`

Successful response

- ListHistoryResponse
  - `historyId` string, uint64 — The ID of the mailbox's current history record
  - `nextPageToken` string — Page token to retrieve the next page of results in the list
  - `history` History[] — List of history records. Any `messages` contained in the response will typically only have `id` and `threadId` fields populated
    - `messagesAdded` HistoryMessageAdded[] — Messages added to the mailbox in this history record
      - `message` Message — An email message
        - `snippet` string — A short part of the message text
        - `threadId` string — The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
        - `labelIds` string[] — List of IDs of labels applied to this message
        - `payload` MessagePart — A single MIME message part
          - `headers` MessagePartHeader[] — List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`
            - `name` string — The name of the header before the `:` separator. For example, `To`
            - `value` string — The value of the header after the `:` separator. For example, `someuser@example.com`
          - `filename` string — The filename of the attachment. Only present if this message part represents an attachment
          - `partId` string — The immutable ID of the message part
          - `parts` MessagePart[] — The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521
          - `mimeType` string — The MIME type of the message part
          - `body` MessagePartBody — The body of a single MIME message part
            - `data` string, byte — The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment
            - `size` integer — Number of bytes for the message part data (encoding notwithstanding)
            - `attachmentId` string — When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field
        - `historyId` string, uint64 — The ID of the last history record that modified this message
        - `raw` string, byte — The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied
        - `id` string — The immutable ID of the message
        - `sizeEstimate` integer — Estimated size in bytes of the message
        - `internalDate` string, int64 — The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header
    - `labelsAdded` HistoryLabelAdded[] — Labels added to messages in this history record
      - `labelIds` string[] — Label IDs added to the message
      - `message` Message — An email message
        - `snippet` string — A short part of the message text
        - `threadId` string — The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
        - `labelIds` string[] — List of IDs of labels applied to this message
        - `payload` MessagePart — A single MIME message part
          - `headers` MessagePartHeader[] — List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`
            - `name` string — The name of the header before the `:` separator. For example, `To`
            - `value` string — The value of the header after the `:` separator. For example, `someuser@example.com`
          - `filename` string — The filename of the attachment. Only present if this message part represents an attachment
          - `partId` string — The immutable ID of the message part
          - `parts` MessagePart[] — The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521
          - `mimeType` string — The MIME type of the message part
          - `body` MessagePartBody — The body of a single MIME message part
            - `data` string, byte — The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment
            - `size` integer — Number of bytes for the message part data (encoding notwithstanding)
            - `attachmentId` string — When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field
        - `historyId` string, uint64 — The ID of the last history record that modified this message
        - `raw` string, byte — The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied
        - `id` string — The immutable ID of the message
        - `sizeEstimate` integer — Estimated size in bytes of the message
        - `internalDate` string, int64 — The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header
    - `messages` Message[] — 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
      - `snippet` string — A short part of the message text
      - `threadId` string — The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
      - `labelIds` string[] — List of IDs of labels applied to this message
      - `payload` MessagePart — A single MIME message part
        - `headers` MessagePartHeader[] — List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`
          - `name` string — The name of the header before the `:` separator. For example, `To`
          - `value` string — The value of the header after the `:` separator. For example, `someuser@example.com`
        - `filename` string — The filename of the attachment. Only present if this message part represents an attachment
        - `partId` string — The immutable ID of the message part
        - `parts` MessagePart[] — The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521
        - `mimeType` string — The MIME type of the message part
        - `body` MessagePartBody — The body of a single MIME message part
          - `data` string, byte — The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment
          - `size` integer — Number of bytes for the message part data (encoding notwithstanding)
          - `attachmentId` string — When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field
      - `historyId` string, uint64 — The ID of the last history record that modified this message
      - `raw` string, byte — The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied
      - `id` string — The immutable ID of the message
      - `sizeEstimate` integer — Estimated size in bytes of the message
      - `internalDate` string, int64 — The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header
    - `id` string, uint64 — The mailbox sequence ID
    - `labelsRemoved` HistoryLabelRemoved[] — Labels removed from messages in this history record
      - `labelIds` string[] — Label IDs removed from the message
      - `message` Message — An email message
        - `snippet` string — A short part of the message text
        - `threadId` string — The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
        - `labelIds` string[] — List of IDs of labels applied to this message
        - `payload` MessagePart — A single MIME message part
          - `headers` MessagePartHeader[] — List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`
            - `name` string — The name of the header before the `:` separator. For example, `To`
            - `value` string — The value of the header after the `:` separator. For example, `someuser@example.com`
          - `filename` string — The filename of the attachment. Only present if this message part represents an attachment
          - `partId` string — The immutable ID of the message part
          - `parts` MessagePart[] — The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521
          - `mimeType` string — The MIME type of the message part
          - `body` MessagePartBody — The body of a single MIME message part
            - `data` string, byte — The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment
            - `size` integer — Number of bytes for the message part data (encoding notwithstanding)
            - `attachmentId` string — When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field
        - `historyId` string, uint64 — The ID of the last history record that modified this message
        - `raw` string, byte — The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied
        - `id` string — The immutable ID of the message
        - `sizeEstimate` integer — Estimated size in bytes of the message
        - `internalDate` string, int64 — The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header
    - `messagesDeleted` HistoryMessageDeleted[] — Messages deleted (not Trashed) from the mailbox in this history record
      - `message` Message — An email message
        - `snippet` string — A short part of the message text
        - `threadId` string — The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
        - `labelIds` string[] — List of IDs of labels applied to this message
        - `payload` MessagePart — A single MIME message part
          - `headers` MessagePartHeader[] — List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`
            - `name` string — The name of the header before the `:` separator. For example, `To`
            - `value` string — The value of the header after the `:` separator. For example, `someuser@example.com`
          - `filename` string — The filename of the attachment. Only present if this message part represents an attachment
          - `partId` string — The immutable ID of the message part
          - `parts` MessagePart[] — The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521
          - `mimeType` string — The MIME type of the message part
          - `body` MessagePartBody — The body of a single MIME message part
            - `data` string, byte — The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment
            - `size` integer — Number of bytes for the message part data (encoding notwithstanding)
            - `attachmentId` string — When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field
        - `historyId` string, uint64 — The ID of the last history record that modified this message
        - `raw` string, byte — The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied
        - `id` string — The immutable ID of the message
        - `sizeEstimate` integer — Estimated size in bytes of the message
        - `internalDate` string, int64 — The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header

---

[API](https://skmtc.net/ballerina-platform/apis/gmail-api.md) · [All operations](https://skmtc.net/ballerina-platform/apis/gmail-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ballerina-platform/gmail-api/versions/c7f11764507c/schema)
