Miguel de Unamuno's Mist or Fog (Spanish: Niebla) (1914), tr. Elena Barcia (2017).
"The plot revolves around the character of Augusto...Because everything Augusto does involves a lengthy thought process, he decides that he needs to consult Unamuno himself (the author of the novel), who had written an article on suicide which Augusto had read. When Augusto speaks with Unamuno, the truth is revealed that Augusto is actually a fictional character whom Unamuno has created. Augusto is not real, Unamuno explains, and for that reason cannot kill himself. Augusto asserts that he exists, even though he acknowledges internally that he doesn't, and threatens Unamuno by telling him that he is not the ultimate author. Augusto reminds Unamuno that he might be just a character in one of God's dreams. Augusto returns to his home and dies."