Skip to content

Commit 0466c8e

Browse files
authored
Closes #19167: Update REST API examples (#19353)
* Closes #19167: Update REST API examples * Fix missing description --------- Co-authored-by: Markku Leiniö <[email protected]>
1 parent 5342552 commit 0466c8e

File tree

1 file changed

+63
-22
lines changed

1 file changed

+63
-22
lines changed

docs/integrations/rest-api.md

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,34 @@ If we wanted to assign this IP address to a virtual machine interface instead, w
217217

218218
### Brief Format
219219

220-
Most API endpoints support an optional "brief" format, which returns only a minimal representation of each object in the response. This is useful when you need only a list of available objects without any related data, such as when populating a drop-down list in a form. As an example, the default (complete) format of an IP address looks like this:
220+
Most API endpoints support an optional "brief" format, which returns only a minimal representation of each object in the response. This is useful when you need only a list of available objects without any related data, such as when populating a drop-down list in a form. As an example, the default (complete) format of a prefix looks like this:
221221

222-
```
222+
```no-highlight
223223
GET /api/ipam/prefixes/13980/
224+
```
224225

226+
```json
225227
{
226228
"id": 13980,
227229
"url": "http://netbox/api/ipam/prefixes/13980/",
230+
"display_url": "http://netbox/api/ipam/prefixes/13980/",
231+
"display": "192.0.2.0/24",
228232
"family": {
229233
"value": 4,
230234
"label": "IPv4"
231235
},
232236
"prefix": "192.0.2.0/24",
233-
"site": {
237+
"vrf": null,
238+
"scope_type": "dcim.site",
239+
"scope_id": 3,
240+
"scope": {
234241
"id": 3,
235-
"url": "http://netbox/api/dcim/sites/17/",
242+
"url": "http://netbox/api/dcim/sites/3/",
243+
"display": "Site 23A",
236244
"name": "Site 23A",
237-
"slug": "site-23a"
245+
"slug": "site-23a",
246+
"description": ""
238247
},
239-
"vrf": null,
240248
"tenant": null,
241249
"vlan": null,
242250
"status": {
@@ -250,24 +258,36 @@ GET /api/ipam/prefixes/13980/
250258
"slug": "staging"
251259
},
252260
"is_pool": false,
261+
"mark_utilized": false,
253262
"description": "Example prefix",
263+
"comments": "",
254264
"tags": [],
255265
"custom_fields": {},
256-
"created": "2018-12-10",
257-
"last_updated": "2019-03-01T20:02:46.173540Z"
266+
"created": "2025-03-01T20:01:23.458302Z",
267+
"last_updated": "2025-03-01T20:02:46.173540Z",
268+
"children": 0,
269+
"_depth": 0
258270
}
259271
```
260272

261273
The brief format is much more terse:
262274

263-
```
275+
```no-highlight
264276
GET /api/ipam/prefixes/13980/?brief=1
277+
```
265278

279+
```json
266280
{
267281
"id": 13980,
268282
"url": "http://netbox/api/ipam/prefixes/13980/",
269-
"family": 4,
270-
"prefix": "10.40.3.0/24"
283+
"display": "192.0.2.0/24",
284+
"family": {
285+
"value": 4,
286+
"label": "IPv4"
287+
},
288+
"prefix": "192.0.2.0/24",
289+
"description": "Example prefix",
290+
"_depth": 0
271291
}
272292
```
273293

@@ -400,25 +420,31 @@ curl -s -X POST \
400420
-H "Authorization: Token $TOKEN" \
401421
-H "Content-Type: application/json" \
402422
http://netbox/api/ipam/prefixes/ \
403-
--data '{"prefix": "192.0.2.0/24", "site": 6}' | jq '.'
423+
--data '{"prefix": "192.0.2.0/24", "scope_type": "dcim.site", "scope_id": 6}' | jq '.'
404424
```
405425

406426
```json
407427
{
408428
"id": 18691,
409429
"url": "http://netbox/api/ipam/prefixes/18691/",
430+
"display_url": "http://netbox/api/ipam/prefixes/18691/",
431+
"display": "192.0.2.0/24",
410432
"family": {
411433
"value": 4,
412434
"label": "IPv4"
413435
},
414436
"prefix": "192.0.2.0/24",
415-
"site": {
437+
"vrf": null,
438+
"scope_type": "dcim.site",
439+
"scope_id": 6,
440+
"scope": {
416441
"id": 6,
417442
"url": "http://netbox/api/dcim/sites/6/",
443+
"display": "US-East 4",
418444
"name": "US-East 4",
419-
"slug": "us-east-4"
445+
"slug": "us-east-4",
446+
"description": ""
420447
},
421-
"vrf": null,
422448
"tenant": null,
423449
"vlan": null,
424450
"status": {
@@ -427,11 +453,15 @@ http://netbox/api/ipam/prefixes/ \
427453
},
428454
"role": null,
429455
"is_pool": false,
456+
"mark_utilized": false,
430457
"description": "",
458+
"comments": "",
431459
"tags": [],
432460
"custom_fields": {},
433-
"created": "2020-08-04",
434-
"last_updated": "2020-08-04T20:08:39.007125Z"
461+
"created": "2025-04-29T15:44:47.597092Z",
462+
"last_updated": "2025-04-29T15:44:47.597092Z",
463+
"children": 0,
464+
"_depth": 0
435465
}
436466
```
437467

@@ -490,18 +520,24 @@ http://netbox/api/ipam/prefixes/18691/ \
490520
{
491521
"id": 18691,
492522
"url": "http://netbox/api/ipam/prefixes/18691/",
523+
"display_url": "http://netbox/api/ipam/prefixes/18691/",
524+
"display": "192.0.2.0/24",
493525
"family": {
494526
"value": 4,
495527
"label": "IPv4"
496528
},
497529
"prefix": "192.0.2.0/24",
498-
"site": {
530+
"vrf": null,
531+
"scope_type": "dcim.site",
532+
"scope_id": 6,
533+
"scope": {
499534
"id": 6,
500535
"url": "http://netbox/api/dcim/sites/6/",
536+
"display": "US-East 4",
501537
"name": "US-East 4",
502-
"slug": "us-east-4"
538+
"slug": "us-east-4",
539+
"description": ""
503540
},
504-
"vrf": null,
505541
"tenant": null,
506542
"vlan": null,
507543
"status": {
@@ -510,11 +546,15 @@ http://netbox/api/ipam/prefixes/18691/ \
510546
},
511547
"role": null,
512548
"is_pool": false,
549+
"mark_utilized": false,
513550
"description": "",
551+
"comments": "",
514552
"tags": [],
515553
"custom_fields": {},
516-
"created": "2020-08-04",
517-
"last_updated": "2020-08-04T20:14:55.709430Z"
554+
"created": "2025-04-29T15:44:47.597092Z",
555+
"last_updated": "2025-04-29T15:49:40.689109Z",
556+
"children": 0,
557+
"_depth": 0
518558
}
519559
```
520560

@@ -670,6 +710,7 @@ Note that we are _not_ passing an existing REST API token with this request. If
670710
{
671711
"id": 6,
672712
"url": "https://netbox/api/users/tokens/6/",
713+
"display_url": "https://netbox/api/users/tokens/6/",
673714
"display": "**********************************3c9cb9",
674715
"user": {
675716
"id": 2,

0 commit comments

Comments
 (0)