> 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.

# Approve a pending agent action

POST https://api.withwrit.com/v1/agent/actions/{actionId}/approve
Content-Type: application/json

Approve and execute a pending agent action. The server re-runs the
policy check (a flip to deny stops the write), verifies the TOTP code
when the verb requires step-up, verifies the fresh auth token
immediately before the write, then executes the tool. The pending
action is deleted on success. An optional `params` object edits the
staged diff; edited params are re-validated and re-checked.


Reference: https://docs.withwrit.com/api-reference/agent/approve-a-pending-agent-action

## Servers

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

## Request

### Path parameters

- `actionId` (string, required)

### Body (application/json)

This endpoint expects an object.

- `totpCode` (string, optional) — TOTP code from the authenticator app or a backup code; required when the action's verb requires step-up.
- `params` (V1AgentActionsActionIdApprovePostRequestBodyContentApplicationJsonSchemaParams, optional) — Edited tool params (Edit). Keys must be valid for the staged tool; the edit is re-validated against the meta-policy and re-checked before apply.

## Response

### 200

Action approved and applied (or denied by a flipped policy, with receipt).

- `type` (string, optional)
- `message` (string, optional)
- `result` (V1AgentActionsActionIdApprovePostResponsesContentApplicationJsonSchemaResult, optional)
- `receipt` (V1AgentActionsActionIdApprovePostResponsesContentApplicationJsonSchemaReceipt, optional)
- `revertActionId` (string, optional)
- `revertMessage` (string, optional)

## Errors

### 401 Unauthorized Error

TOTP code required or invalid.

- `any`

### 404 Not Found Error

Action not found or expired.

- `any`

## Types

### V1AgentActionsActionIdApprovePostRequestBodyContentApplicationJsonSchemaParams

Edited tool params (Edit). Keys must be valid for the staged tool; the edit is re-validated against the meta-policy and re-checked before apply.

### V1AgentActionsActionIdApprovePostResponsesContentApplicationJsonSchemaResult

### V1AgentActionsActionIdApprovePostResponsesContentApplicationJsonSchemaReceipt

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "type": "string",
  "message": "string",
  "result": {},
  "receipt": {},
  "revertActionId": "string",
  "revertMessage": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.withwrit.com/v1/agent/actions/actionId/approve"

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

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

print(response.json())
```

```javascript
const url = 'https://api.withwrit.com/v1/agent/actions/actionId/approve';
const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{}'};

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.withwrit.com/v1/agent/actions/actionId/approve"

	payload := strings.NewReader("{}")

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

url = URI("https://api.withwrit.com/v1/agent/actions/actionId/approve")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

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.withwrit.com/v1/agent/actions/actionId/approve")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.withwrit.com/v1/agent/actions/actionId/approve', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.withwrit.com/v1/agent/actions/actionId/approve");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

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