Hello! As per title, is there a way to programmatically get/set redirects and rewrites for a site? I’m trying to do this as part of an automated deploy script, but failed to find anything.
My fallback approach was to download the latest deploy, parse the netlify.toml file, get / update the redirects table, then redeploy the site - but seems like a lot of effort so wanted to check if I have missed something, or if there’s a better way to do this.
Thanks for your reply. How can I download just the netlify.toml via the API? I tried using the endpoint https://api.netlify.com/api/v1/deploys/${latestDeploy.id}/files/netlify.toml but the response just returns a data structure with informations about the file, such as the path and the sha - and it doesn’t seem to be possible to download the netlify.toml directly file as a public asset from the site
Netlify doesn’t provide an API to directly add or update redirects/rewrites.
To change them, you must update your _redirects or netlify.toml file and then redeploy the site.
If you need dynamic redirects without redeploying, you’d have to handle them manually using an Edge Function.