Skip to content

Instantly share code, notes, and snippets.

@gitstua
Created May 29, 2024 08:07
Show Gist options
  • Save gitstua/e643a08484b973937aa0a6ad10e7d9e3 to your computer and use it in GitHub Desktop.
Save gitstua/e643a08484b973937aa0a6ad10e7d9e3 to your computer and use it in GitHub Desktop.

The curl command below will mark all of your notifications as read, clear the notification indicator, and should take care of that phantom message for you.

A few things to note: In order to use this command a Personal Access Token (PAT) will be required and $TOKEN needs to be replaced by a personal access token you can create here: https://github.com/settings/tokens/new. Creating a Personal Access Token also has the steps to create a token. After it is created, replace $TOKEN in the command with your new PAT. Note: Please ensure that the PAT has the notifications scope.

Please update the date and time to your current date and note the time values must be in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. curl -H "Authorization: bearer $TOKEN" -X PUT -H "Accept: application/vnd.github.v3+json" https://api.github.com/notifications -d '{"last_read_at":"2022-11-08T13:21:00"}'

You can also export the current date and time in bash by running: export now=$(date +%Y-%m-%dT%H:%M:%SZ)

Then you can use the date and time variable in the curl command as follows: curl -H "Authorization: bearer $TOKEN" -X PUT -H "Accept: application/vnd.github.v3+json" https://api.github.com/notifications -d '{"last_read_at":"'"$now"'"}'

For your reference, here is the documentation for the Notifications REST API endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment