diff --git a/README.md b/README.md
index 4785900..19a008b 100644
--- a/README.md
+++ b/README.md
@@ -1469,6 +1469,32 @@ corresponding to when the API was available for use.
```
+#### `guiUndo`
+
+* Undo the last action / card; returns `true` if succeeded or `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiUndo",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiDeckOverview`
* Opens the *Deck Overview* dialog for the deck with the given name; returns `true` if succeeded or `false` otherwise.
diff --git a/plugin/__init__.py b/plugin/__init__.py
index a30fca0..73f4d81 100644
--- a/plugin/__init__.py
+++ b/plugin/__init__.py
@@ -1801,6 +1801,12 @@ class AnkiConnect:
return True
+ @util.api()
+ def guiUndo(self):
+ self.window().undo()
+ return True
+
+
@util.api()
def guiDeckOverview(self, name):
collection = self.collection()
diff --git a/tests/test_graphical.py b/tests/test_graphical.py
index cabcfea..6311bb4 100755
--- a/tests/test_graphical.py
+++ b/tests/test_graphical.py
@@ -102,6 +102,19 @@ class TestReviewActions:
reviews_after = ac.cardReviews(deck="test_deck", startID=0)
assert len(reviews_after) == len(reviews_before) + 1
+ def test_guiUndo(self, reviewing_started):
+ ac.guiShowAnswer()
+ reviews_before = ac.cardReviews(deck="test_deck", startID=0)
+ assert ac.guiAnswerCard(ease=4) is True
+
+ reviews_after_answer = ac.cardReviews(deck="test_deck", startID=0)
+ assert len(reviews_after_answer) == len(reviews_before) + 1
+
+ assert ac.guiUndo() is True
+
+ reviews_after_undo = ac.cardReviews(deck="test_deck", startID=0)
+ assert len(reviews_after_undo) == len(reviews_before)
+
class TestSelectedNotes:
def test_with_valid_deck_query(self, setup):