> For the complete documentation index, see [llms.txt](https://documentation.ocsinventory-ng.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.ocsinventory-ng.org/open-api-reference/search.md).

# Search

## POST /search/

> Run a multi-condition search across assets and their related data (results, logs, snmpscanner, inventory\_sections, software\_dictionary\_entries).

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"SearchRequest":{"type":"object","description":"Payload accepted by POST /search/.\n\nsearch_data is a list of AND-groups; groups are combined using each\ngroup's first condition 'link' (AND/OR).","properties":{"search_data":{"type":"array","items":{"type":"array","items":{"$ref":"#/components/schemas/SearchCondition"}},"description":"List of AND-condition groups to combine into the search query."},"grouped":{"type":"boolean","default":true,"description":"If true, results are grouped by asset with a single matched row per relation."},"ungroup":{"type":"boolean","default":false,"description":"If true, one row is returned per matched related record instead of one per asset."}}},"SearchCondition":{"type":"object","description":"One search condition, as sent in a search_data AND-group.\n\nExample:\n{\"object\": \"software_dictionary_entries\", \"route\": \"software_dictionary\",\n \"field\": \"name\", \"fieldtype\": \"string\", \"operator\": \"iexact\",\n \"value\": \"Git\", \"link\": \"AND\"}","properties":{"object":{"type":"string","description":"Target model key, e.g. 'InventoryBase', 'AccountinfoConfig', 'results', 'logs', 'snmpscanner', 'inventory_sections', 'software_dictionary_entries'."},"route":{"type":"string","description":"Frontend route associated with the condition."},"field":{"type":"string","description":"Field name to filter on."},"fieldtype":{"type":"string","description":"Field type hint, e.g. 'string', 'select', 'checkbox'."},"operator":{"type":"string","description":"Lookup operator, e.g. 'exact', 'iexact', 'icontains', 'istartswith', 'iendswith'."},"value":{"description":"Value to compare the field against."},"link":{"allOf":[{"$ref":"#/components/schemas/LinkEnum"}],"default":"AND","description":"How this condition links to the previous one.\n\n* `AND` - AND\n* `OR` - OR"},"section":{"type":"string","description":"Template section id, required when object is 'inventory_sections'."}},"required":["field","object","operator","value"]},"LinkEnum":{"enum":["AND","OR"],"type":"string","description":"* `AND` - AND\n* `OR` - OR"},"PaginatedInventoryBaseList":{"type":"object","required":["count","results"],"properties":{"count":{"type":"integer"},"next":{"type":"string","nullable":true,"format":"uri"},"previous":{"type":"string","nullable":true,"format":"uri"},"results":{"type":"array","items":{"$ref":"#/components/schemas/InventoryBase"}}}},"InventoryBase":{"type":"object","description":"Serializer class for Base","properties":{"id":{"type":"integer","readOnly":true},"name":{"type":"string","maxLength":50},"description":{"type":"string","nullable":true,"maxLength":255},"serial":{"type":"string","maxLength":255},"osname":{"type":"string","maxLength":255},"osversion":{"type":"string","maxLength":255},"uuid":{"type":"string","maxLength":255},"srcip":{"type":"string","maxLength":255},"srcmac":{"type":"string","maxLength":255},"domain":{"type":"string","maxLength":255},"agent":{"type":"string","maxLength":255},"template":{"type":"integer","nullable":true},"last_update":{"type":"string","format":"date-time","readOnly":true},"is_template_forced":{"type":"boolean"},"matched":{"type":"string","readOnly":true}},"required":["id","last_update","matched","name","osname","serial","uuid"]},"SearchError":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}},"paths":{"/search/":{"post":{"operationId":"search_create","description":"Run a multi-condition search across assets and their related data (results, logs, snmpscanner, inventory_sections, software_dictionary_entries).","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"name":"limit","required":false,"in":"query","description":"Number of results to return per page.","schema":{"type":"integer"}},{"name":"offset","required":false,"in":"query","description":"The initial index from which to return the results.","schema":{"type":"integer"}}],"tags":["search"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/SearchRequest"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/SearchRequest"}},"application/json":{"schema":{"$ref":"#/components/schemas/SearchRequest"}},"application/xml":{"schema":{"$ref":"#/components/schemas/SearchRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedInventoryBaseList"}},"application/xml":{"schema":{"$ref":"#/components/schemas/PaginatedInventoryBaseList"}}},"description":""},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchError"}},"application/xml":{"schema":{"$ref":"#/components/schemas/SearchError"}}},"description":""}}}}}}
```

## GET /search/save/

> Return the list of objects that the user can see (public,\
> private\_personal, private\_group)

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"PaginatedSearchList":{"type":"object","required":["count","results"],"properties":{"count":{"type":"integer"},"next":{"type":"string","nullable":true,"format":"uri"},"previous":{"type":"string","nullable":true,"format":"uri"},"results":{"type":"array","items":{"$ref":"#/components/schemas/Search"}}}},"Search":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"visibility":{"$ref":"#/components/schemas/VisibilityEnum"},"allow_group_modification":{"type":"boolean"},"search":{},"last_updated":{"type":"string","format":"date-time","readOnly":true},"name":{"type":"string","maxLength":50},"description":{"type":"string","nullable":true},"user":{"type":"integer"},"groups":{"type":"array","items":{"type":"integer"}}},"required":["id","last_updated","name","search","user"]},"VisibilityEnum":{"enum":["public","private_personal","private_group"],"type":"string","description":"* `public` - Public\n* `private_personal` - Private (Personal)\n* `private_group` - Private (Group)"}}},"paths":{"/search/save/":{"get":{"operationId":"search_save_list","description":"Return the list of objects that the user can see (public,\nprivate_personal, private_group)","parameters":[{"in":"query","name":"description","schema":{"type":"string"}},{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"query","name":"id","schema":{"type":"integer"}},{"in":"query","name":"last_updated","schema":{"type":"string","format":"date-time"}},{"name":"limit","required":false,"in":"query","description":"Number of results to return per page.","schema":{"type":"integer"}},{"in":"query","name":"name","schema":{"type":"string"}},{"name":"offset","required":false,"in":"query","description":"The initial index from which to return the results.","schema":{"type":"integer"}},{"name":"ordering","required":false,"in":"query","description":"Which field to use when ordering the results.","schema":{"type":"string"}},{"name":"search","required":false,"in":"query","description":"A search term.","schema":{"type":"string"}}],"tags":["search"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedSearchList"}},"application/xml":{"schema":{"$ref":"#/components/schemas/PaginatedSearchList"}}},"description":""}}}}}}
```

## POST /search/save/

> Handle post request, suitable for single and multi creation\
> \
> Args:\
> &#x20;   request (\[dict]): can be dict or list of dicts\
> \
> Returns:\
> &#x20;   \[type]: \[description]

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"Search":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"visibility":{"$ref":"#/components/schemas/VisibilityEnum"},"allow_group_modification":{"type":"boolean"},"search":{},"last_updated":{"type":"string","format":"date-time","readOnly":true},"name":{"type":"string","maxLength":50},"description":{"type":"string","nullable":true},"user":{"type":"integer"},"groups":{"type":"array","items":{"type":"integer"}}},"required":["id","last_updated","name","search","user"]},"VisibilityEnum":{"enum":["public","private_personal","private_group"],"type":"string","description":"* `public` - Public\n* `private_personal` - Private (Personal)\n* `private_group` - Private (Group)"}}},"paths":{"/search/save/":{"post":{"operationId":"search_save_create","description":"Handle post request, suitable for single and multi creation\n\nArgs:\n    request ([dict]): can be dict or list of dicts\n\nReturns:\n    [type]: [description]","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}}],"tags":["search"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Search"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Search"}},"application/json":{"schema":{"$ref":"#/components/schemas/Search"}},"application/xml":{"schema":{"$ref":"#/components/schemas/Search"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}},"application/xml":{"schema":{"$ref":"#/components/schemas/Search"}}},"description":""}}}}}}
```

## GET /search/save/{id}/

> This class will define the view behavior\
> \
> Inherits from RestrictVisibilityViewSet to restrict the visibility of the\
> Search objects based on user and group membership\
> \
> Args:\
> &#x20;   viewsets (\[OCSVIewSet])

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"Search":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"visibility":{"$ref":"#/components/schemas/VisibilityEnum"},"allow_group_modification":{"type":"boolean"},"search":{},"last_updated":{"type":"string","format":"date-time","readOnly":true},"name":{"type":"string","maxLength":50},"description":{"type":"string","nullable":true},"user":{"type":"integer"},"groups":{"type":"array","items":{"type":"integer"}}},"required":["id","last_updated","name","search","user"]},"VisibilityEnum":{"enum":["public","private_personal","private_group"],"type":"string","description":"* `public` - Public\n* `private_personal` - Private (Personal)\n* `private_group` - Private (Group)"}}},"paths":{"/search/save/{id}/":{"get":{"operationId":"search_save_retrieve","description":"This class will define the view behavior\n\nInherits from RestrictVisibilityViewSet to restrict the visibility of the\nSearch objects based on user and group membership\n\nArgs:\n    viewsets ([OCSVIewSet])","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this search.","required":true}],"tags":["search"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}},"application/xml":{"schema":{"$ref":"#/components/schemas/Search"}}},"description":""}}}}}}
```

## PUT /search/save/{id}/

> User needs to either be the creator or part of the group\
> (if allow\_group\_modification is enabled) to modify a\
> visibility restricted object

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"Search":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"visibility":{"$ref":"#/components/schemas/VisibilityEnum"},"allow_group_modification":{"type":"boolean"},"search":{},"last_updated":{"type":"string","format":"date-time","readOnly":true},"name":{"type":"string","maxLength":50},"description":{"type":"string","nullable":true},"user":{"type":"integer"},"groups":{"type":"array","items":{"type":"integer"}}},"required":["id","last_updated","name","search","user"]},"VisibilityEnum":{"enum":["public","private_personal","private_group"],"type":"string","description":"* `public` - Public\n* `private_personal` - Private (Personal)\n* `private_group` - Private (Group)"}}},"paths":{"/search/save/{id}/":{"put":{"operationId":"search_save_update","description":"User needs to either be the creator or part of the group\n(if allow_group_modification is enabled) to modify a\nvisibility restricted object","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this search.","required":true}],"tags":["search"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Search"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Search"}},"application/json":{"schema":{"$ref":"#/components/schemas/Search"}},"application/xml":{"schema":{"$ref":"#/components/schemas/Search"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}},"application/xml":{"schema":{"$ref":"#/components/schemas/Search"}}},"description":""}}}}}}
```

## DELETE /search/save/{id}/

> User needs to be the creator to delete a visibility restricted object

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}}},"paths":{"/search/save/{id}/":{"delete":{"operationId":"search_save_destroy","description":"User needs to be the creator to delete a visibility restricted object","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this search.","required":true}],"tags":["search"],"responses":{"204":{"description":"No response body"}}}}}}
```

## PATCH /search/save/{id}/

> This class will define the view behavior\
> \
> Inherits from RestrictVisibilityViewSet to restrict the visibility of the\
> Search objects based on user and group membership\
> \
> Args:\
> &#x20;   viewsets (\[OCSVIewSet])

```json
{"openapi":"3.0.3","info":{"title":"OCS Inventory Backend API References","version":"3.0.0"},"security":[{"knoxApiToken":[]}],"components":{"securitySchemes":{"knoxApiToken":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""}},"schemas":{"PatchedSearch":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"visibility":{"$ref":"#/components/schemas/VisibilityEnum"},"allow_group_modification":{"type":"boolean"},"search":{},"last_updated":{"type":"string","format":"date-time","readOnly":true},"name":{"type":"string","maxLength":50},"description":{"type":"string","nullable":true},"user":{"type":"integer"},"groups":{"type":"array","items":{"type":"integer"}}}},"VisibilityEnum":{"enum":["public","private_personal","private_group"],"type":"string","description":"* `public` - Public\n* `private_personal` - Private (Personal)\n* `private_group` - Private (Group)"},"Search":{"type":"object","description":"This serialize class provide the API representation","properties":{"id":{"type":"integer","readOnly":true},"visibility":{"$ref":"#/components/schemas/VisibilityEnum"},"allow_group_modification":{"type":"boolean"},"search":{},"last_updated":{"type":"string","format":"date-time","readOnly":true},"name":{"type":"string","maxLength":50},"description":{"type":"string","nullable":true},"user":{"type":"integer"},"groups":{"type":"array","items":{"type":"integer"}}},"required":["id","last_updated","name","search","user"]}}},"paths":{"/search/save/{id}/":{"patch":{"operationId":"search_save_partial_update","description":"This class will define the view behavior\n\nInherits from RestrictVisibilityViewSet to restrict the visibility of the\nSearch objects based on user and group membership\n\nArgs:\n    viewsets ([OCSVIewSet])","parameters":[{"in":"query","name":"format","schema":{"type":"string","enum":["json","xml"]}},{"in":"path","name":"id","schema":{"type":"integer"},"description":"A unique integer value identifying this search.","required":true}],"tags":["search"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/PatchedSearch"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/PatchedSearch"}},"application/json":{"schema":{"$ref":"#/components/schemas/PatchedSearch"}},"application/xml":{"schema":{"$ref":"#/components/schemas/PatchedSearch"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}},"application/xml":{"schema":{"$ref":"#/components/schemas/Search"}}},"description":""}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://documentation.ocsinventory-ng.org/open-api-reference/search.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
