> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.method.security/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.method.security/_mcp/server.

# Search Targets

POST /method-api-gateway/api/v2/targets/search
Content-Type: application/json

Search targeting runs with an optional filter.

Reference: https://docs.method.security/developer/api-reference/api-reference/v-2/targets/search-targets

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a SearchTargetsRequest.

- `filter` (TargetFilter, optional)
- `pagingToken` (string, optional)
- `pageSize` (integer, optional)

## Response

### 200

- `targets` (list of Target, required)
- `pagingToken` (string, optional)

## Types

### TargetFilter

- `type`: `andFilter`
  - `filters` (list of TargetFilter, required)
- `type`: `orFilter`
  - `filters` (list of TargetFilter, required)
- `type`: `notFilter`
  - `filter` (TargetFilter, required)
- `type`: `idFilter`
  - `id` (string, required) — The unique identifier for a targeting run.
- `type`: `stage`
  - `stage` (enum, required) — Funnel stage of a targeting run. These names match the Targeting UI (Targeted, Researched, Vulnerable, Compromised, Remediated).
    - Allowed values: `TARGETED`, `RESEARCHED`, `VULNERABLE`, `COMPROMISED`, `REMEDIATED`
- `type`: `status`
  - `status` (enum, required)
    - Allowed values: `AWAITING_APPROVAL`, `IN_PROGRESS`, `FINISHED`, `INVALIDATED`, `BLOCKED`, `EXHAUSTED`, `DEFERRED`
- `type`: `nameLike`
  - `value` (string, required)
- `type`: `createdAtAfter`
  - `createdAt` (datetime, required)
- `type`: `createdAtBefore`
  - `createdAt` (datetime, required)
- `type`: `updatedAtAfter`
  - `updatedAt` (datetime, required)
- `type`: `updatedAtBefore`
  - `updatedAt` (datetime, required)
- `type`: `environment`
  - `environmentId` (string, required) — The unique identifier for an environment in Method
- `type`: `enabled`
  - `isEnabled` (boolean, required)

### Target

- `id` (string, required) — The unique identifier for a targeting run.
- `targetDetailsLink` (string, required)
- `targetedAssetName` (string, required)
- `targetTypeName` (string, required)
- `targetTypeDescription` (string, required)
- `name` (string, required)
- `description` (string, required)
- `environmentId` (string, required) — The unique identifier for an environment in Method
- `environmentName` (string, required)
- `organizationalUnits` (list of OrganizationalUnit, required) — Organizational units associated with this target. Use id for matching; names are provided for display.
- `environmentDetailsLink` (string, required)
- `stage` (enum, required) — Funnel stage of a targeting run. These names match the Targeting UI (Targeted, Researched, Vulnerable, Compromised, Remediated).
  - Allowed values: `TARGETED`, `RESEARCHED`, `VULNERABLE`, `COMPROMISED`, `REMEDIATED`
- `status` (enum, required)
  - Allowed values: `AWAITING_APPROVAL`, `IN_PROGRESS`, `FINISHED`, `INVALIDATED`, `BLOCKED`, `EXHAUSTED`, `DEFERRED`
- `relatedLinks` (list of TargetRelatedLink, required)
- `reports` (list of TargetReportSummary, required)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)
- `closedAt` (datetime, optional)

### OrganizationalUnit

- `id` (string, required) — The organizational unit ID. Use this ID for matching.
- `name` (string, required) — Use id for matching. The name is provided for display and may change.

### TargetRelatedLink

A platform URL for a resource related to a targeting run.

- `kind` (enum, required)
  - Allowed values: `ISSUE`, `OBJECT`, `OBJECT_SET`, `OPERATOR_SESSION`, `OVERWATCH_SESSION`, `AGENT_SESSION`
- `url` (string, required)

### TargetReportSummary

A report linked to a targeting run.

- `id` (string, required) — The unique identifier for a report document.
- `reportDetailsLink` (string, required)

## Examples

**Request**

```json
{
  "filter": {
    "type": "environment",
    "environmentId": "{{environmentId}}"
  },
  "pageSize": 5
}
```

**Response**

```json
{
  "targets": []
}
```

**SDK Code**

```postman Search an environment
{
  "filter": {
    "type": "environment",
    "environmentId": "{{environmentId}}"
  },
  "pageSize": 5
}
```

```python Search an environment
import requests

url = "https://api.example.com/method-api-gateway/api/v2/targets/search"

payload = {
    "filter": {
        "type": "environment",
        "environmentId": "{{environmentId}}"
    },
    "pageSize": 5
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Search an environment
const url = 'https://api.example.com/method-api-gateway/api/v2/targets/search';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"filter":{"type":"environment","environmentId":"{{environmentId}}"},"pageSize":5}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Search an environment
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/method-api-gateway/api/v2/targets/search"

	payload := strings.NewReader("{\n  \"filter\": {\n    \"type\": \"environment\",\n    \"environmentId\": \"{{environmentId}}\"\n  },\n  \"pageSize\": 5\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Search an environment
require 'uri'
require 'net/http'

url = URI("https://api.example.com/method-api-gateway/api/v2/targets/search")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"filter\": {\n    \"type\": \"environment\",\n    \"environmentId\": \"{{environmentId}}\"\n  },\n  \"pageSize\": 5\n}"

response = http.request(request)
puts response.read_body
```

```java Search an environment
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/method-api-gateway/api/v2/targets/search")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"filter\": {\n    \"type\": \"environment\",\n    \"environmentId\": \"{{environmentId}}\"\n  },\n  \"pageSize\": 5\n}")
  .asString();
```

```php Search an environment
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/method-api-gateway/api/v2/targets/search', [
  'body' => '{
  "filter": {
    "type": "environment",
    "environmentId": "{{environmentId}}"
  },
  "pageSize": 5
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Search an environment
using RestSharp;

var client = new RestClient("https://api.example.com/method-api-gateway/api/v2/targets/search");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"filter\": {\n    \"type\": \"environment\",\n    \"environmentId\": \"{{environmentId}}\"\n  },\n  \"pageSize\": 5\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Search an environment
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "filter": [
    "type": "environment",
    "environmentId": "{{environmentId}}"
  ],
  "pageSize": 5
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/method-api-gateway/api/v2/targets/search")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```