> This page is for version v0.25.0.
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.25.0: https://docs.nvidia.com/nemo/guardrails/v0.25.0/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

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

# Check a Claude Code Tool Call

POST http://localhost:8100/v1/hooks/claude-code
Content-Type: application/json

Checks a Claude Code `PreToolUse` hook. Extra input fields are accepted and ignored.
An allowed call returns `{}` so Claude Code continues its own permission flow.
A denied call returns a deny decision prefixed with `NeMo Guardrails: `.
An error status indicates a failed hook.

See [Hooks Server Results and Errors](/nemo/guardrails/v0.25.0/run-guardrailed-inference/using-hooks-server/results-and-errors#errors)
for error codes and the `Retry-After: 30` header on a full queue.

See [Check Claude Code Tool Calls with the Hooks Server](/nemo/guardrails/v0.25.0/run-guardrailed-inference/using-hooks-server/claude-code).

Reference: https://docs.nvidia.com/nemo/guardrails/reference/hooks-server-api/claude-code

## Request

### Body (application/json)

This endpoint expects a ClaudeCodePreToolUseRequest.

- `hook_event_name` ("PreToolUse", required) — The event must be `PreToolUse`. Other events return `422` with `unsupported_hook_event`.
- `tool_input` (ClaudeCodePreToolUseRequestToolInput, required, nullable) — Tool call arguments. A value that is not a JSON object is denied.
- `tool_name` (string, required) — The tool name, matched exactly by the policy and per-tool rails. It must not be empty.
- `tool_use_id` (string, required)

## Response

### 200

Allow or deny decision

- `Hooks_checkClaudeCodeToolCall_Response_200`
  - map from string to any
  - PreToolUseDeny: PreToolUseDeny

## Errors

### 422 Unprocessable Entity Error

Invalid request or unsupported event

- `error` (HookErrorError, required)

### 500 Internal Server Error

Check failed

- `error` (HookErrorError, required)

### 503 Service Unavailable Error

Admission queue full

- `error` (HookErrorError, required)

## Types

### ClaudeCodePreToolUseRequestToolInput

Tool call arguments. A value that is not a JSON object is denied.

- map from string to any
- list of any
- string
- double
- boolean

### PreToolUseDeny

- `hookSpecificOutput` (PreToolUseDenyHookSpecificOutput, required)

### HookErrorError

- `code` (string, required, nullable) — `unsupported_hook_event`, `rail_failed`, `queue_full`, or `null`.
- `message` (string, required) — Human-readable message. Validation errors name each failing field as `body.<field>: <reason>`.
- `param` (string, required, nullable) — The request field the error relates to, or `null`.
- `type` (string, required) — `invalid_request_error` for `422`; `server_error` for `500` and `503`.

### PreToolUseDenyHookSpecificOutput

- `hookEventName` ("PreToolUse", required)
- `permissionDecision` ("deny", required)
- `permissionDecisionReason` (string, required)

## Examples

### Deny

**Request**

```json
{
  "hook_event_name": "PreToolUse",
  "tool_input": {
    "command": "git push --force origin main"
  },
  "tool_name": "Bash",
  "tool_use_id": "toolu_02"
}
```

**Response**

```json
{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "deny",
    "permissionDecisionReason": "NeMo Guardrails: regex check tool call"
  }
}
```

**SDK Code**

```python Deny
import requests

url = "http://localhost:8100/v1/hooks/claude-code"

payload = {
    "hook_event_name": "PreToolUse",
    "tool_input": { "command": "git push --force origin main" },
    "tool_name": "Bash",
    "tool_use_id": "toolu_02"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Deny
const url = 'http://localhost:8100/v1/hooks/claude-code';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"hook_event_name":"PreToolUse","tool_input":{"command":"git push --force origin main"},"tool_name":"Bash","tool_use_id":"toolu_02"}'
};

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

```go Deny
package main

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

func main() {

	url := "http://localhost:8100/v1/hooks/claude-code"

	payload := strings.NewReader("{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git push --force origin main\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_02\"\n}")

	req, _ := http.NewRequest("POST", 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 Deny
require 'uri'
require 'net/http'

url = URI("http://localhost:8100/v1/hooks/claude-code")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git push --force origin main\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_02\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8100/v1/hooks/claude-code")
  .header("Content-Type", "application/json")
  .body("{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git push --force origin main\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_02\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8100/v1/hooks/claude-code', [
  'body' => '{
  "hook_event_name": "PreToolUse",
  "tool_input": {
    "command": "git push --force origin main"
  },
  "tool_name": "Bash",
  "tool_use_id": "toolu_02"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Deny
using RestSharp;

var client = new RestClient("http://localhost:8100/v1/hooks/claude-code");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git push --force origin main\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_02\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Deny
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "hook_event_name": "PreToolUse",
  "tool_input": ["command": "git push --force origin main"],
  "tool_name": "Bash",
  "tool_use_id": "toolu_02"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8100/v1/hooks/claude-code")! 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()
```

### Allow

**Request**

```json
{
  "hook_event_name": "PreToolUse",
  "tool_input": {
    "command": "git status"
  },
  "tool_name": "Bash",
  "tool_use_id": "toolu_01"
}
```

**Response**

```json
{}
```

**SDK Code**

```python Allow
import requests

url = "http://localhost:8100/v1/hooks/claude-code"

payload = {
    "hook_event_name": "PreToolUse",
    "tool_input": { "command": "git status" },
    "tool_name": "Bash",
    "tool_use_id": "toolu_01"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Allow
const url = 'http://localhost:8100/v1/hooks/claude-code';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"hook_event_name":"PreToolUse","tool_input":{"command":"git status"},"tool_name":"Bash","tool_use_id":"toolu_01"}'
};

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

```go Allow
package main

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

func main() {

	url := "http://localhost:8100/v1/hooks/claude-code"

	payload := strings.NewReader("{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git status\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_01\"\n}")

	req, _ := http.NewRequest("POST", 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 Allow
require 'uri'
require 'net/http'

url = URI("http://localhost:8100/v1/hooks/claude-code")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git status\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_01\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8100/v1/hooks/claude-code")
  .header("Content-Type", "application/json")
  .body("{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git status\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_01\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8100/v1/hooks/claude-code', [
  'body' => '{
  "hook_event_name": "PreToolUse",
  "tool_input": {
    "command": "git status"
  },
  "tool_name": "Bash",
  "tool_use_id": "toolu_01"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Allow
using RestSharp;

var client = new RestClient("http://localhost:8100/v1/hooks/claude-code");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"hook_event_name\": \"PreToolUse\",\n  \"tool_input\": {\n    \"command\": \"git status\"\n  },\n  \"tool_name\": \"Bash\",\n  \"tool_use_id\": \"toolu_01\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Allow
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "hook_event_name": "PreToolUse",
  "tool_input": ["command": "git status"],
  "tool_name": "Bash",
  "tool_use_id": "toolu_01"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8100/v1/hooks/claude-code")! 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()
```