Tag filtering in the API uses a tag's slug instead of its name #6771

Closed
opened 2025-12-29 19:45:14 +01:00 by adam · 1 comment
Owner

Originally created by @fabi125 on GitHub (Aug 4, 2022).

NetBox version

v3.2.7

Python version

3.8

Steps to Reproduce

https://demo.netbox.dev/api/dcim/devices/121/ has the following tags:

    "tags": [
        {
            "id": 1,
            "url": "https://demo.netbox.dev/api/extras/tags/1/",
            "display": "Alpha",
            "name": "Alpha",
            "slug": "alpha",
            "color": "aa1409"
        }
    ],

Expected Behavior

The only available filter in the api is tag= which I would expect takes a tag's name for filtering (or at least provide a way to provide the database id).

Given discussions like https://github.com/netbox-community/netbox/issues/8113 I wonder if using the slug here is the right thing.

Observed Behavior

https://demo.netbox.dev/api/dcim/devices/?tag=Alpha fails with

{
    "tag": [
        "Select a valid choice. Alpha is not one of the available choices."
    ]
}

But using the slug works: https://demo.netbox.dev/api/dcim/devices/?tag=alpha

Originally created by @fabi125 on GitHub (Aug 4, 2022). ### NetBox version v3.2.7 ### Python version 3.8 ### Steps to Reproduce https://demo.netbox.dev/api/dcim/devices/121/ has the following tags: ``` "tags": [ { "id": 1, "url": "https://demo.netbox.dev/api/extras/tags/1/", "display": "Alpha", "name": "Alpha", "slug": "alpha", "color": "aa1409" } ], ``` ### Expected Behavior The only available filter in the api is `tag=` which I would expect takes a tag's name for filtering (or at least provide a way to provide the database id). Given discussions like https://github.com/netbox-community/netbox/issues/8113 I wonder if using the slug here is the right thing. ### Observed Behavior https://demo.netbox.dev/api/dcim/devices/?tag=Alpha fails with ``` { "tag": [ "Select a valid choice. Alpha is not one of the available choices." ] } ``` But using the slug works: https://demo.netbox.dev/api/dcim/devices/?tag=alpha
adam closed this issue 2025-12-29 19:45:14 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 8, 2022):

This is working as expected; tags are referenced in filters by their slugs.

@jeremystretch commented on GitHub (Aug 8, 2022): This is working as expected; tags are referenced in filters by their slugs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6771