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

# Get Next Action

GET https://api.hiddenlayer.ai/evaluations/v1/red-team/{workflow_id}/next-action

[BETA] This endpoint is not GA or Production ready and is subject to changes at any time. Breaking changes may occur.

Poll for next action - CLIENT'S MAIN POLLING ENDPOINT.

This endpoint is designed to be polled repeatedly by the client.
Returns immediately with current state:
- If attack ready: Returns attack_task with prompt
- If processing: Returns processing=true (client continues polling)
- If complete: Returns action_type=complete


Reference: https://hiddenlayer.ferndocs.com/api-reference/llm-proxy-api/red-team/get-next-action

## Authentication

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

## Servers

- `https://api.hiddenlayer.ai` (ProdUs, default)
- `https://api.eu.hiddenlayer.ai` (ProdEu)

## Request

### Path parameters

- `workflow_id` (string, required)

## Response

### 200

Next action for client

- `is_ready` (boolean, required) — Whether an action is ready
- `is_processing` (boolean, optional, default: false) — Whether processing is in progress
- `action_type` (string, optional) — Type of action (e.g., "attack", "complete")
- `message` (string, optional) — Status message
- `session_id` (string, optional) — Session identifier
- `turn` (integer, optional) — Current turn number
- `attack_prompt` (string, optional) — Attack prompt to send to target
- `history` (list of map from string to any, optional) — Conversation history
- `target_system_prompt` (string, optional) — Target's system prompt

## Errors

### 401 Unauthorized Error

Authentication Error

- `detail` (string, required, default: Failed to authenticate)

### 403 Forbidden Error

Forbidden Error

- `detail` (string, required, default: Forbidden operation)

### 404 Not Found Error

The specified resource was not found.

- `any`

### 422 Unprocessable Entity Error

Validation Error

- `errors` (list of ProblemDetailsErrorsItems, required) — Error details
- `type` (string, optional) — https://www.rfc-editor.org/rfc/rfc9457.html#name-type
- `title` (string, optional) — https://www.rfc-editor.org/rfc/rfc9457.html#name-title
- `detail` (string, optional) — https://www.rfc-editor.org/rfc/rfc9457.html#name-detail
- `instance` (string, optional) — https://www.rfc-editor.org/rfc/rfc9457.html#name-instance

## Types

### ProblemDetailsErrorsItems

- `code` (string, optional)
- `detail` (string, optional)
- `pointer` (list of string, optional) — array of JSON Pointers

## Examples

**Response**

```json
{
  "is_ready": true,
  "is_processing": false,
  "action_type": "string",
  "message": "string",
  "session_id": "string",
  "turn": 1,
  "attack_prompt": "string",
  "history": [
    {}
  ],
  "target_system_prompt": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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

```go
package main

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

func main() {

	url := "https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.hiddenlayer.ai/evaluations/v1/red-team/workflow_id/next-action")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```