# Updating routes using API is not removing old routes

**URL:** <https://forum.pritunl.com/t/updating-routes-using-api-is-not-removing-old-routes/1976>\
**Category:** Pritunl VPN\
**Created:** [April 8, 2024, 7:53am UTC](https://forum.pritunl.com/t/updating-routes-using-api-is-not-removing-old-routes/1976 "2024-04-08T07:53:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://forum.pritunl.com/user_avatar/forum.pritunl.com/jonathan/32/657_2.png) [@Jonathan](https://forum.pritunl.com/u/Jonathan)\
**Post date:** [April 8, 2024, 7:53am UTC](https://forum.pritunl.com/t/updating-routes-using-api-is-not-removing-old-routes/1976/1 "2024-04-08T07:53:09Z")

</div>

The way our networking is set up, we need one of our servers to route data to some ips that might change from time to time. Therefore we have set up a job that runs from time to time, checking the servers current routes, and what the ip for the target is. If they are different, then we update them using the api based on this example: [pritunl/tools/add\_aws\_ranges.py at master · pritunl/pritunl · GitHub](https://github.com/pritunl/pritunl/blob/master/tools/add_aws_ranges.py)

Checking our logs, we get an output saying what routes that are being added:

```auto
[{
    "network": "<ip-1>/32",
    "comment": "Route updated <timestamp>",
    "nat": true
}, {
    "network": "<ip-2>/32",
    "comment": "Route updated <timestamp>",
    "nat": true
}]

```

That is the data being used in the `auth_request` function:

```auto
    response = auth_request(
        "POST",
        "/server/%s/routes" % SERVER_ID,
        headers={"Content-Type": "application/json"},
        data=json.dumps(routes),
    )

```

However, when checking the routes after this function is executed, the server contains more routes than the ones in the POST request. How can I solve this issue without having to manually remove an old route from time to time?

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [April 11, 2024, 2:42am UTC](https://forum.pritunl.com/t/updating-routes-using-api-is-not-removing-old-routes/1976/2 "2024-04-11T02:42:08Z")

</div>

The API will either add or remove routes. It can’t update all the routes and overwrite the existing route set. You will need to remove the other routes.
