> Call POST /v1/check before a tool that writes. DENY means do not invoke the tool. For clean Markdown of any page, append .md to the page URL. For the complete index, fetch https://docs.withwrit.com/llms.txt.

# Kill switch — revoke the principal

POST https://api.withwrit.com/v1/revoke
Content-Type: application/json

**Sponsor token** required. Revokes the principal identified by
sponsorId + agentId within the sponsor's tenant: **every later check
for that principal is DENY, even under an allow policy**, until
`POST /v1/reinstate` undoes it. Use it the moment an agent looks
compromised or a runaway loop starts issuing checks. Revocation
itself writes a REVOKE receipt, so the kill-switch action is in the
audit log too.


Reference: https://docs.withwrit.com/api-reference/grants-and-approvals/kill-switch-revoke-the-principal

## Authentication

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

## Servers

- `https://api.withwrit.com` (Writ gate, default)
- `https://j72ckh66ukck2kcbq3oiwxaalm0olxwb.lambda-url.us-east-1.on.aws` (Direct Lambda Function URL (fallback))

## Request

### Headers

- `Authorization` (string, required) — Bearer \<sponsor token>.

### Body (application/json)

This endpoint expects an object.

- `sponsorId` (string, required) — The human sponsor on whose behalf the agent acts.
- `agentId` (string, required) — The agent to revoke.
- `reason` (string, optional) — Recorded in the revocation and the REVOKE receipt. Defaults to 'revoked by sponsor'.

## Response

### 201

Principal revoked.

## Errors

### 400 Bad Request Error

sponsorId and agentId are required.

### 401 Unauthorized Error

Sponsor token required — missing or unknown token.

- `any`

## Examples

**Request**

```json
{
  "sponsorId": "s_42",
  "agentId": "support-agent-07",
  "reason": "agent issuing refunds outside its ticket queue"
}
```

**Response**

```json
{
  "agentId": "support-agent-07",
  "principal": "s_42#support-agent-07#ten_3fa8b91c2d44",
  "reason": "agent issuing refunds outside its ticket queue",
  "revokedAt": 1759000000,
  "sponsorId": "s_42",
  "tenantId": "ten_3fa8b91c2d44"
}
```

**SDK Code**

```python Grants and approvals_killSwitchRevokeThePrincipal_example
import requests

url = "https://api.withwrit.com/v1/revoke"

payload = {
    "sponsorId": "s_42",
    "agentId": "support-agent-07",
    "reason": "agent issuing refunds outside its ticket queue"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Grants and approvals_killSwitchRevokeThePrincipal_example
const url = 'https://api.withwrit.com/v1/revoke';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"sponsorId":"s_42","agentId":"support-agent-07","reason":"agent issuing refunds outside its ticket queue"}'
};

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

```go Grants and approvals_killSwitchRevokeThePrincipal_example
package main

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

func main() {

	url := "https://api.withwrit.com/v1/revoke"

	payload := strings.NewReader("{\n  \"sponsorId\": \"s_42\",\n  \"agentId\": \"support-agent-07\",\n  \"reason\": \"agent issuing refunds outside its ticket queue\"\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 Grants and approvals_killSwitchRevokeThePrincipal_example
require 'uri'
require 'net/http'

url = URI("https://api.withwrit.com/v1/revoke")

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  \"sponsorId\": \"s_42\",\n  \"agentId\": \"support-agent-07\",\n  \"reason\": \"agent issuing refunds outside its ticket queue\"\n}"

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

```java Grants and approvals_killSwitchRevokeThePrincipal_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.withwrit.com/v1/revoke")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"sponsorId\": \"s_42\",\n  \"agentId\": \"support-agent-07\",\n  \"reason\": \"agent issuing refunds outside its ticket queue\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.withwrit.com/v1/revoke', [
  'body' => '{
  "sponsorId": "s_42",
  "agentId": "support-agent-07",
  "reason": "agent issuing refunds outside its ticket queue"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Grants and approvals_killSwitchRevokeThePrincipal_example
using RestSharp;

var client = new RestClient("https://api.withwrit.com/v1/revoke");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"sponsorId\": \"s_42\",\n  \"agentId\": \"support-agent-07\",\n  \"reason\": \"agent issuing refunds outside its ticket queue\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Grants and approvals_killSwitchRevokeThePrincipal_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "sponsorId": "s_42",
  "agentId": "support-agent-07",
  "reason": "agent issuing refunds outside its ticket queue"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.withwrit.com/v1/revoke")! 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()
```