Return Specific Status Code When PATCH Results in No Changes #285

Closed
opened 2026-04-05 16:24:37 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @sweickge on 2/24/2026

NetBox version

v4.5.3

Feature type

Change to existing functionality

Proposed functionality

Currently, a PATCH request to most API endpoints (for example, /dcim/device-types) always returns a 200 OK response, even if no actual updates are made to a resource in Netbox.

It would be beneficial to return a different status code, such as 204 No Content with an empty response body, when a PATCH request does not result in any changes. This would better align with existing Netbox behavior, where a PATCH that makes no modifications does not generate a changelog entry.

Use case

We use Ansible to add and modify a large list of device and module types sourced from the device type community library. Currently, when a potential change is detected for a specific device or module type, we issue a PATCH request to update the resource and rely on Ansible to report whether a change was made. However, since the API always returns a 200 status code, there is no straightforward way to create a changed_when conditional based solely on the PATCH response.

As a workaround, we must make an additional API call to retrieve the resource and compare each field to determine if any changes occurred before issuing a PATCH request. This leads to numerous unnecessary API calls for resources that haven't actually changed.

With the proposed enhancement, a single PATCH request could be made, and the status code would immediately indicate whether the resource was updated. This would streamline automation workflows and reduce redundant API requests.

Database changes

N/A

External dependencies

N/A

*Originally created by @sweickge on 2/24/2026* ### NetBox version v4.5.3 ### Feature type Change to existing functionality ### Proposed functionality Currently, a PATCH request to most API endpoints (for example, /dcim/device-types) always returns a 200 OK response, even if no actual updates are made to a resource in Netbox. It would be beneficial to return a different status code, such as 204 No Content with an empty response body, when a PATCH request does not result in any changes. This would better align with existing Netbox behavior, where a PATCH that makes no modifications does not generate a changelog entry. ### Use case We use Ansible to add and modify a large list of device and module types sourced from the device type community library. Currently, when a potential change is detected for a specific device or module type, we issue a PATCH request to update the resource and rely on Ansible to report whether a change was made. However, since the API always returns a 200 status code, there is no straightforward way to create a `changed_when` conditional based solely on the PATCH response. As a workaround, we must make an additional API call to retrieve the resource and compare each field to determine if any changes occurred before issuing a PATCH request. This leads to numerous unnecessary API calls for resources that haven't actually changed. With the proposed enhancement, a single PATCH request could be made, and the status code would immediately indicate whether the resource was updated. This would streamline automation workflows and reduce redundant API requests. ### Database changes N/A ### External dependencies N/A
MrUnknownDE added the netboxtype: featurenetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxtype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: feature labels 2026-04-05 16:24:40 +02:00
Sign in to join this conversation.
No Label netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#285