Save to file from cron job

I have a cron job that fetches an API endpoint. If the ID returned from that endpoint is different from the last ID then it should send a webhook.

So in order to do this, I need to keep track of the last returned ID. How to best do this? Locally I save this in a .txt file. How does it work on Render? Having a separate database for this seems to be overkill. I was thinking that I could perhaps store the ID in an environment variable and let the cron update the var when a new ID is detected. Would that be possible?

What would you recommend for this use case?