An API method to get Contacts and/or Contacts Group for a Site Group (or Site)? #8779

Closed
opened 2025-12-29 20:41:05 +01:00 by adam · 4 comments
Owner

Originally created by @lamoni on GitHub (Oct 27, 2023).

NetBox version

v3.2.6

Feature type

Data model extension

Proposed functionality

Given a specific site name, I'm trying to use the API (pynetbox, specifically) to get to the site's site-group's contacts. I know we're running a bit older version but the swagger docs for the newest version didn't have the output either mentioned in the response example, but apologies anyway if this is in a newer version.

Example:

Site: ABC123
Site Group: ABCs
Contacts: abc-member@abc.com (which are also in a Contacts Group called ABC Staff)

If I start out with a site name and try to follow the API breadcrumbs (Ideally I could go: /dcim/sites -> /dcim/site-groups -> /tenancy/contacts), it goes cold at Site Group -> Contacts because the /site-groups GET output doesn't contain anything about its contacts or contact groups that are associated with it.

Example of the /dcim/site-groups output:

{'_depth': 0, 'created': '2023-10-27T18:01:32.758424Z', 'custom_fields': {}, 'description': '', 'display': 'ABCs, 'id': 10, 'last_updated': '2023-10-27T18:12:18.259881Z', 'name': 'ABCs', 'parent': None, 'site_count': 1, 'slug': 'abcs', 'tags': [], 'url': 'http://netbox.blahblah.com/api/dcim/site-groups/10/'}

I would expect to see a list of contacts there.

I then try to go backwards and pull all contacts and see if there is any reference in the GET output to their associated objects, and there isn't (which I wouldn't expect to be coming from this direction, but I did check)

Use case

We want to use the Contacts in our Site Groups as a SoT for who to contact when alerting triggers for a site under that Site Group. We're able to figure out which site group a given site name is in, but can't get to the Contacts associated with the Site Groups.

I should mention that just adding the Contacts directly to the Site also doesn't help because the Site's GET output doesn't contain contacts data

Database changes

N/A

External dependencies

N/A

Originally created by @lamoni on GitHub (Oct 27, 2023). ### NetBox version v3.2.6 ### Feature type Data model extension ### Proposed functionality Given a specific site name, I'm trying to use the API (pynetbox, specifically) to get to the site's site-group's contacts. I know we're running a bit older version but the swagger docs for the newest version didn't have the output either mentioned in the response example, but apologies anyway if this is in a newer version. Example: Site: ABC123 Site Group: ABCs Contacts: abc-member@abc.com (which are also in a Contacts Group called ABC Staff) If I start out with a site name and try to follow the API breadcrumbs (Ideally I could go: /dcim/sites -> /dcim/site-groups -> /tenancy/contacts), it goes cold at Site Group -> Contacts because the /site-groups GET output doesn't contain anything about its contacts or contact groups that are associated with it. Example of the /dcim/site-groups output: ` {'_depth': 0, 'created': '2023-10-27T18:01:32.758424Z', 'custom_fields': {}, 'description': '', 'display': 'ABCs, 'id': 10, 'last_updated': '2023-10-27T18:12:18.259881Z', 'name': 'ABCs', 'parent': None, 'site_count': 1, 'slug': 'abcs', 'tags': [], 'url': 'http://netbox.blahblah.com/api/dcim/site-groups/10/'} ` I would expect to see a list of contacts there. I then try to go backwards and pull all contacts and see if there is any reference in the GET output to their associated objects, and there isn't (which I wouldn't expect to be coming from this direction, but I did check) ### Use case We want to use the Contacts in our Site Groups as a SoT for who to contact when alerting triggers for a site under that Site Group. We're able to figure out which site group a given site name is in, but can't get to the Contacts associated with the Site Groups. I should mention that just adding the Contacts directly to the Site also doesn't help because the Site's GET output doesn't contain contacts data ### Database changes N/A ### External dependencies N/A
adam added the type: featurepending closure labels 2025-12-29 20:41:05 +01:00
adam closed this issue 2025-12-29 20:41:06 +01:00
Author
Owner

@Lisa94p commented on GitHub (Dec 20, 2023):

Hello, I would like to link a similar requirement to this thread.
I'm using v3.6.4 and I kindly need to retrieve the contacts associated with a circuit or with a provider, from the browser the pages consulted would be:
https://netbox.lan/circuits/providers/33/contacts/
https://netbox.lan/circuits/circuits/26/contacts/
but I can't find an associated API. Also by doing only
GET https://netbox.lan/circuits/providers/33/ or
GET https://netbox.lan/circuits/circuits/26/
I do not see anything regarding the associated contacts.

Looking forward for an update on this.
Many thanks

@Lisa94p commented on GitHub (Dec 20, 2023): Hello, I would like to link a similar requirement to this thread. I'm using v3.6.4 and I kindly need to retrieve the contacts associated with a circuit or with a provider, from the browser the pages consulted would be: https://netbox.lan/circuits/providers/33/contacts/ https://netbox.lan/circuits/circuits/26/contacts/ but I can't find an associated API. Also by doing only GET https://netbox.lan/circuits/providers/33/ or GET https://netbox.lan/circuits/circuits/26/ I do not see anything regarding the associated contacts. Looking forward for an update on this. Many thanks
Author
Owner

@DanSheps commented on GitHub (Dec 20, 2023):

Use case

We want to use the Contacts in our Site Groups as a SoT for who to contact when alerting triggers for a site under that Site Group. We're able to figure out which site group a given site name is in, but can't get to the Contacts associated with the Site Groups.

I should mention that just adding the Contacts directly to the Site also doesn't help because the Site's GET output doesn't contain contacts data

This would require a separate API call to the /api/tenancny/contact-assignments API too get the associated contacts.

You would need to query both: content_type and object_id to obtain the approrpiate site group.

Perhaps there might be a better way to do this using some form of dynamic filter that gets built.

@DanSheps commented on GitHub (Dec 20, 2023): > ### Use case > We want to use the Contacts in our Site Groups as a SoT for who to contact when alerting triggers for a site under that Site Group. We're able to figure out which site group a given site name is in, but can't get to the Contacts associated with the Site Groups. > > I should mention that just adding the Contacts directly to the Site also doesn't help because the Site's GET output doesn't contain contacts data This would require a separate API call to the /api/tenancny/contact-assignments API too get the associated contacts. You would need to query both: content_type and object_id to obtain the approrpiate site group. Perhaps there might be a better way to do this using some form of dynamic filter that gets built.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 20, 2024):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Mar 20, 2024): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (May 17, 2024):

Closing this out as stale as there's been no further discussion.

@jeremystretch commented on GitHub (May 17, 2024): Closing this out as stale as there's been no further discussion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8779