How to find specific files across whole repository including folders?

Hey,
I’m looking for a way to find specific files (e.g .txt files) across whole repository including folders via REST API.
I’ve tried using repositories/<workspace>/<repo>/src?q=path~".txt"&ext="txt" but it works only for main repository folder.

Thanks for any help.