# Get verdict (Step 7)

POST https://api.forboc.ai/npcs/{npcId}/verdict
Content-Type: application/json

SDK sends SLM-generated output. API validates it against rules, signs it, and returns
memory storage instructions + state delta for the SDK to execute locally.


Reference: https://docs.forboc.ai/api-reference/endpoints/forboc-ai-sdk-api/np-cs/get-npc-verdict

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: ForbocAI API
  version: 1.0.0
paths:
  /npcs/{npcId}/verdict:
    post:
      operationId: get-npc-verdict
      summary: Get verdict (Step 7)
      description: >
        SDK sends SLM-generated output. API validates it against rules, signs
        it, and returns

        memory storage instructions + state delta for the SDK to execute
        locally.
      tags:
        - subpackage_npCs
      parameters:
        - name: npcId
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Validation verdict with storage/state instructions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VerdictResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VerdictRequest'
servers:
  - url: https://api.forboc.ai
  - url: http://localhost:8080
components:
  schemas:
    VerdictRequest:
      type: object
      properties:
        generatedOutput:
          type: string
          description: Raw output from the local SLM
        observation:
          type: string
          description: Original observation (echoed)
        npcState:
          type: object
          additionalProperties:
            description: Any type
        rulesetId:
          type:
            - string
            - 'null'
      required:
        - generatedOutput
        - observation
        - npcState
      title: VerdictRequest
    MemoryStoreInstructionType:
      type: string
      enum:
        - observation
        - experience
        - knowledge
        - emotion
      title: MemoryStoreInstructionType
    MemoryStoreInstruction:
      type: object
      properties:
        text:
          type: string
        type:
          $ref: '#/components/schemas/MemoryStoreInstructionType'
        importance:
          type: number
          format: double
      title: MemoryStoreInstruction
    GenericAction:
      type: object
      properties:
        type:
          type: string
        reason:
          type:
            - string
            - 'null'
        target:
          type:
            - string
            - 'null'
      title: GenericAction
    VerdictResponse:
      type: object
      properties:
        valid:
          type: boolean
          description: Whether the generated output passed validation
        signature:
          type:
            - string
            - 'null'
          description: Cryptographic signature (HMAC) if valid
        memoryStore:
          type: array
          items:
            $ref: '#/components/schemas/MemoryStoreInstruction'
          description: Instructions for what the SDK should store in its local vector DB
        stateDelta:
          type: object
          additionalProperties:
            description: Any type
          description: State changes for the SDK to apply locally
        action:
          oneOf:
            - $ref: '#/components/schemas/GenericAction'
            - type: 'null'
          description: Validated action to return to the game
        dialogue:
          type: string
          description: Validated dialogue text returned to the caller
      title: VerdictResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python
import requests

url = "https://api.forboc.ai/npcs/npcId/verdict"

payload = {
    "generatedOutput": "The NPC decides to investigate the strange noise coming from the east corridor.",
    "observation": "Player reports hearing a mysterious sound near the east corridor at 22:15."
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.forboc.ai/npcs/npcId/verdict';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"generatedOutput":"The NPC decides to investigate the strange noise coming from the east corridor.","observation":"Player reports hearing a mysterious sound near the east corridor at 22:15."}'
};

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 := "https://api.forboc.ai/npcs/npcId/verdict"

	payload := strings.NewReader("{\n  \"generatedOutput\": \"The NPC decides to investigate the strange noise coming from the east corridor.\",\n  \"observation\": \"Player reports hearing a mysterious sound near the east corridor at 22:15.\"\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
require 'uri'
require 'net/http'

url = URI("https://api.forboc.ai/npcs/npcId/verdict")

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  \"generatedOutput\": \"The NPC decides to investigate the strange noise coming from the east corridor.\",\n  \"observation\": \"Player reports hearing a mysterious sound near the east corridor at 22:15.\"\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.post("https://api.forboc.ai/npcs/npcId/verdict")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"generatedOutput\": \"The NPC decides to investigate the strange noise coming from the east corridor.\",\n  \"observation\": \"Player reports hearing a mysterious sound near the east corridor at 22:15.\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.forboc.ai/npcs/npcId/verdict', [
  'body' => '{
  "generatedOutput": "The NPC decides to investigate the strange noise coming from the east corridor.",
  "observation": "Player reports hearing a mysterious sound near the east corridor at 22:15."
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.forboc.ai/npcs/npcId/verdict");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"generatedOutput\": \"The NPC decides to investigate the strange noise coming from the east corridor.\",\n  \"observation\": \"Player reports hearing a mysterious sound near the east corridor at 22:15.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "generatedOutput": "The NPC decides to investigate the strange noise coming from the east corridor.",
  "observation": "Player reports hearing a mysterious sound near the east corridor at 22:15."
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.forboc.ai/npcs/npcId/verdict")! 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()
```