API Endpoint for Outbound NAT rules?

Started by dreamsmoney, November 11, 2025, 07:29:37 PM

Previous topic - Next topic
Hello all,

Thank you for putting together such a wonderful product and API.  I've found how to programmatically edit most things, but I cannot find an endpoint for Outbound NAT rules.

Is there an API endpoint for Outbound NAT rules?

I can trace requests for that page - it uses's application/x-www-form-urlencoded.  I haven't attempted to code for that yet.

I'm okay making URL encoded requests, but my issue is that I can't GET (retrieve) an existing rule.  I'd like to retain most of the existing fields.  My intent is to POST (edit) one field - enable/disable.

My larger goal is to write a high availability program for a non OPNSense service, it floats a VIP across multiple data centers.

I don't use API myself but on the OPNsense API page there is a (source) NAT section:

https://docs.opnsense.org/development/api/core/firewall.html#id10
Deciso DEC740

Quote from: patient0 on November 11, 2025, 08:10:50 PMI don't use API myself but on the OPNsense API page there is a (source) NAT section:

https://docs.opnsense.org/development/api/core/firewall.html#id10

Thank you so much for your reply.  I took a look at the source_nat endpoints and they don't seem to return the rules under outbound NAT.  I tried both the get_rule and search_rule endpoints.

You are right, that API does indeed return the 'Source NAT', Sorry.

If you enable 'Inspect' in your browser and reload a page, you will see the API call that is being made.
And it seems like the 'Outbound NAT' does not yet have a API endpoint.
Deciso DEC740

Quote from: patient0 on November 12, 2025, 06:54:45 PMYou are right, that API does indeed return the 'Source NAT', Sorry.

If you enable 'Inspect' in your browser and reload a page, you will see the API call that is being made.
And it seems like the 'Outbound NAT' does not yet have a API endpoint.

It's okay!  Thank you again for the speedy reply.  I agree that there is no API endpoint for outbound NAT.

The good news - I'm finding that I don't need to disable the outbound NAT rule in order for my failover to work.  I only need to disable the route that's paired with it.  That does have an API endpoint.

Thank you again for your time and information.  Have a good rest of the week.