> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://www.comet.com/docs/opik/llms.txt.

# Update Agent Insights project guidance

PUT http://localhost:5173/api/v1/private/agent-insights/jobs/{projectId}/guidance
Content-Type: application/json

Saves the project guidance sent to every Agent Insights run, creating the job (disabled) if the project has none. Empty or whitespace-only clears it. The guidance version is bumped only when the text changes. 404 while guidance is not enabled.

Reference: https://www.comet.com/docs/opik/reference/rest-api/agent-insights-jobs/update-agent-insights-guidance

## Servers

- `http://localhost:5173/api` (Local server, default)
- `https://www.comet.com/opik/api` (Opik Cloud)

## Request

### Path parameters

- `projectId` (string, required)

### Body (application/json)

This endpoint expects an AgentInsightsGuidanceUpdate.

- `guidance` (string, required) — Project guidance for Agent Insights runs. Empty or whitespace-only clears it

## Response

### 200

Job with the saved guidance

- `project_id` (string, required)
- `id` (string, optional)
- `status` (enum, optional)
  - Allowed values: `enabled`, `disabled`
- `auto_first_run_enrolled` (boolean, optional)
- `auto_first_run_at` (datetime, optional)
- `last_scan_at` (datetime, optional)
- `last_failure_reason` (string, optional)
- `last_failure_detail` (string, optional)
- `last_failed_at` (datetime, optional)
- `guidance` (string, optional) — Project guidance sent to every run; null when none
- `guidance_updated_by` (string, optional) — Who last saved the guidance
- `guidance_updated_at` (datetime, optional) — When the guidance was last saved
- `guidance_version` (integer, optional) — Bumped each time the guidance text changes; 0 = never saved
- `results_guidance_version` (integer, optional) — Guidance version the current results were produced with; null = no run since guidance existed
- `created_at` (datetime, optional)
- `created_by` (string, optional)
- `last_updated_at` (datetime, optional)
- `last_updated_by` (string, optional)

## Errors

### 403 Forbidden Error

Forbidden

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

### 404 Not Found Error

Project not found, or guidance not enabled

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

### 422 Unprocessable Entity Error

Guidance missing or over the length limit

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

## Examples

**Request**

```json
{
  "guidance": "string"
}
```

**Response**

```json
{
  "project_id": "string",
  "id": "string",
  "status": "enabled",
  "auto_first_run_enrolled": true,
  "auto_first_run_at": "2024-01-15T09:30:00Z",
  "last_scan_at": "2024-01-15T09:30:00Z",
  "last_failure_reason": "string",
  "last_failure_detail": "string",
  "last_failed_at": "2024-01-15T09:30:00Z",
  "guidance": "string",
  "guidance_updated_by": "string",
  "guidance_updated_at": "2024-01-15T09:30:00Z",
  "guidance_version": 1,
  "results_guidance_version": 1,
  "created_at": "2024-01-15T09:30:00Z",
  "created_by": "string",
  "last_updated_at": "2024-01-15T09:30:00Z",
  "last_updated_by": "string"
}
```

**SDK Code**

```python
import requests

url = "http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance"

payload = { "guidance": "string" }
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance';
const options = {
  method: 'PUT',
  headers: {'Content-Type': 'application/json'},
  body: '{"guidance":"string"}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance"

	payload := strings.NewReader("{\n  \"guidance\": \"string\"\n}")

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

	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
require 'uri'
require 'net/http'

url = URI("http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance")

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

request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"guidance\": \"string\"\n}"

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.put("http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance")
  .header("Content-Type", "application/json")
  .body("{\n  \"guidance\": \"string\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance', [
  'body' => '{
  "guidance": "string"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"guidance\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["guidance": "string"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5173/api/v1/private/agent-insights/jobs/projectId/guidance")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```