---
title: "Search Commands"
method: POST
path: "/search/commands"
tags: ["Search"]
---

# Search Commands

`POST /search/commands`

## Request

- Base URL: `https://console.jumpcloud.com/api`
- URL: `https://console.jumpcloud.com/api/search/commands`
- Auth: API key in header `x-api-key`
- TypeScript: <https://skmtc.dev/jumpcloud/apis/jumpcloud-api/docs/search/commands/post.ts> (a function with typed inputs; its response is checked against the schema)

Return Commands in multi-record format allowing for the passing of the `filter` and `searchFilter` parameters. This WILL NOT allow you to add a new command.
To support advanced filtering you can use the `filter` and `searchFilter` parameters that can only be passed in the body of POST /api/search/* routes. The `filter` and `searchFilter` parameters must be passed as Content-Type application/json.
The `filter` parameter is an object with a single property, either `and` or `or` with the value of the property being an array of query expressions.
This allows you to filter records using the logic of matching ALL or ANY records in the array of query expressions. If the `and` or `or` are not included the default behavior is to match ALL query expressions.
The `searchFilter` parameter allows text searching on supported fields by specifying a `searchTerm` and a list of `fields` to query on. If any `field` has a partial text match on the `searchTerm` the record will be returned.

#### Sample Request
Exact search for a list of commands in a launchType
```
curl -X POST https://console.jumpcloud.com/api/search/commands \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: {API_KEY}' \
  -d '{
  "filter" : [{"launchType" : "repeated"}],
  "fields" : "name launchType sudo"
}'
```
Text search for commands with name
```
curl -X POST https://console.jumpcloud.com/api/search/commands \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: {API_KEY}' \
  -d '{
  "searchFilter" : {
    "searchTerm": "List",
    "fields": ["name"]
  },
  "fields" : "name launchType sudo"
}'
```
Text search for multiple commands
```
curl -X POST https://console.jumpcloud.com/api/search/commands \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: {API_KEY}' \
  -d '{
  "searchFilter" : {
    "searchTerm": ["List", "Log"],
    "fields": ["name"]
  },
  "fields" : "name launchType sudo"
}'
```
Combining `filter` and `searchFilter` to text search for commands with name who are in a list of launchType
```
curl -X POST https://console.jumpcloud.com/api/search/commands \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: {API_KEY}' \
  -d '{
  "searchFilter": {
    "searchTerm": "List",
    "fields": ["name"]
  },
  "filter": {
    "or": [
      {"launchType" : "repeated"},
      {"launchType" : "one-time"}
    ]
  },
  "fields" : "name launchType sudo"
}'
```

## Query parameters

- `fields` string
- `filter` string
- `limit` integer
- `skip` integer

## Headers

- `x-org-id` string

## Request body

- Search
  - `fields` string
  - `filter` object
  - `searchFilter` object

## Response `200`

OK

- Commandslist
  - `results` object[]
    - `_id` string: The ID of the command.
    - `command` string: The Command to execute, truncated to 10k characters.
    - `commandType` string: The Command OS.
    - `launchType` string: How the Command is executed.
    - `listensTo` string
    - `name` string: The name of the Command.
    - `organization` string: The ID of the Organization.
    - `schedule` string: A crontab that consists of: [ (seconds) (minutes) (hours) (days of month) (months) (weekdays) ] or [ immediate ]. If you send this as an empty string, it will run immediately.
    - `scheduleRepeatType` string: When the command will repeat.
    - `trigger` string: Trigger to execute command.
    - `description` string: Description of the command.
    - `aiGenerated` boolean: Whether this command was generated with AI assistance.
    - `templatingRequired` boolean: Whether this command requires templating before execution.
    - `managedBy` 'enterprise' | 'organization': Command owner type (`enterprise` or `organization`).
  - `totalCount` integer: The total number of commands

## Other responses

- `401`: Unauthorized

---

[API](https://skmtc.dev/jumpcloud/apis/jumpcloud-api.md) - [All operations](https://skmtc.dev/jumpcloud/apis/jumpcloud-api/llms.txt) - [OpenAPI document](https://skmtc.dev/jumpcloud/apis/jumpcloud-api/revisions/0762c7d17a26?raw)
