I came across a toast that appears when I try to change my vote that I made a few days ago.
Is it documented somewhere after which time span you can no longer change your vote? Or does the API return the text contained in the toast? (see below)
It's no different in the API than it is for the main site. From the FAQ:
you may change your vote within a five minute window from the time of the first vote you cast on that post. Note that after voting and undoing your vote 30 times, it will also be locked in.