Canonical: https://weaveos.com/reference/gmail/recover-stale-history-id

1. [Software capabilities](https://weaveos.com/reference)
2. /[Gmail](https://weaveos.com/reference/gmail)
3. /Recover a stale Gmail history ID

[![](https://weaveos.com/reference/logos/gmail.svg)Gmail](https://weaveos.com/reference/gmail)

# Recover a stale Gmail history ID

Use history.list while the saved startHistoryId is valid. If an outdated ID causes a 404, rebuild the local mailbox index and save the historyId of the most recent message from the full sync.

Documentation reviewed November 27, 2026 · 3 methods with sources

## Ways to do it

1. [1API: GET /gmail/v1/users/{userId}/history](https://weaveos.com/reference/gmail/recover-stale-history-id#method-1)
2. [2API: Full sync after HTTP 404](https://weaveos.com/reference/gmail/recover-stale-history-id#method-2)
3. [3SDK: gmail.users().history().list()](https://weaveos.com/reference/gmail/recover-stale-history-id#method-3)

API

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

Read mailbox changes after startHistoryId. Follow nextPageToken and save the returned historyId only after processing the last page.

[Read source: Gmail users.history.list reference](https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.history/list)

- Requirements

  Gmail OAuth credentials with an appropriate readonly, metadata, or modify scope and a stored history ID.

- Limitations

  History IDs increase with gaps. Google says they usually remain valid for at least a week and can expire within hours in rare cases.

Example shell

Copy

```
curl --fail --get 'https://gmail.googleapis.com/gmail/v1/users/me/history' -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN" --data-urlencode "startHistoryId=$GMAIL_HISTORY_ID"
```

API

### Full sync after HTTP 404

List messages, fetch the fields your app uses, and save the historyId from the most recent message after rebuilding.

[Read source: Gmail synchronize clients guide](https://developers.google.com/workspace/gmail/api/guides/sync)

- Requirements

  A Gmail OAuth token with scope for the fields your app reads and local storage for the mailbox index.

- Limitations

  Rebuild the subset of the mailbox your app tracks. If it caches message bodies, request FULL or RAW on the initial messages.get calls.

Example text

Copy

```
1. List the messages your app tracks with messages.list.
2. Fetch each record with messages.get and rebuild the local index.
3. Save the historyId from the most recent message after committing the rebuild.
```

SDK

### gmail.users().history().list()

Use the Python client with an authenticated Gmail service to read one page of changes.

[Read source: Gmail Python client history.list](https://googleapis.github.io/google-api-python-client/docs/dyn/gmail_v1.users.history.html)

- Requirements

  An authenticated Gmail API service from google-api-python-client and a saved history ID.

- Limitations

  Reuse the original startHistoryId on subsequent pages. A stale ID requires the same full-sync recovery as REST.

Example text

Copy

```
page = gmail.users().history().list(
    userId="me", startHistoryId=saved_history_id
).execute()
```

[Previous Gmail taskHow to apply a Gmail label](https://weaveos.com/reference/gmail/apply-label)

## More from Gmail

[View all 5 Gmail tasks](https://weaveos.com/reference/gmail)

- ### [How to download Gmail attachments](https://weaveos.com/reference/gmail/download-attachments)

  For an attachment with an attachmentId, call users.messages.attachments.get and decode the returned data as base64url. For a one-off download, open the message in Gmail and use the attachment’s Download button.

  API, Interface

- ### [How to search Gmail messages](https://weaveos.com/reference/gmail/search-messages)

  Use Gmail search operators in the inbox or pass a query as q to users.messages.list. The API returns message IDs that you can use to fetch individual messages.

  API, Interface

- ### [How to retrieve the body of a Gmail message](https://weaveos.com/reference/gmail/read-message)

  Call users.messages.get with format=full to inspect the parsed message or format=raw to get the original MIME payload. A connected Gmail MCP client can retrieve the body using get\_message.

  API, MCP
