> 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. # Create a single-use execution lease POST https://api.withwrit.com/v1/leases Content-Type: application/json Converts a live ALLOW token into a single-use lease bound to a specific upstream request (method + path + body). The lease TTL is capped to the token's remaining life. Requires an active vaulted credential for the target system. Phase 1 supports `systemId: stripe` only. Reference: https://docs.withwrit.com/api-reference/enforcement/create-a-single-use-execution-lease ## Servers - `https://api.withwrit.com` (Writ gate, default) - `https://j72ckh66ukck2kcbq3oiwxaalm0olxwb.lambda-url.us-east-1.on.aws` (Direct Lambda Function URL (fallback)) ## Request ### Body (application/json) This endpoint expects an object. - `token` (string, required) — ALLOW token from POST /v1/check - `method` (string, required) - `path` (string, required) - `body` (V1LeasesPostRequestBodyContentApplicationJsonSchemaBody, optional) — JSON body that will be executed - `ttlSeconds` (integer, optional) — defaults to token remaining life ## Response ### 200 Lease denied (token invalid, expired, or no active credential). - `ok` (boolean, optional) - `reason` (string, optional) ### 201 Lease created. - `leaseId` (string, optional) - `systemId` (string, optional) - `verb` (string, optional) - `target` (string, optional) - `purpose` (string, optional) - `expiresAt` (integer, optional) - `ttlSeconds` (integer, optional) ## Errors ### 400 Bad Request Error Missing required fields or body too large. - `any` ## Types ### V1LeasesPostRequestBodyContentApplicationJsonSchemaBody JSON body that will be executed ## Examples ### Example 1 **Request** ```json { "token": "string", "method": "POST", "path": "/v1/refunds" } ``` **Response** ```json { "ok": true, "reason": "string" } ``` **SDK Code** ```python import requests url = "https://api.withwrit.com/v1/leases" payload = { "token": "string", "method": "POST", "path": "/v1/refunds" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.withwrit.com/v1/leases'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"token":"string","method":"POST","path":"/v1/refunds"}' }; 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/leases" payload := strings.NewReader("{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\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 require 'uri' require 'net/http' url = URI("https://api.withwrit.com/v1/leases") 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 = "{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withwrit.com/v1/leases") .header("Content-Type", "application/json") .body("{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\n}") .asString(); ``` ```php request('POST', 'https://api.withwrit.com/v1/leases', [ 'body' => '{ "token": "string", "method": "POST", "path": "/v1/refunds" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.withwrit.com/v1/leases"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "token": "string", "method": "POST", "path": "/v1/refunds" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.withwrit.com/v1/leases")! 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() ``` ### Example 2 **Request** ```json { "token": "string", "method": "POST", "path": "/v1/refunds" } ``` **Response** ```json { "ok": true, "reason": "string" } ``` **SDK Code** ```python import requests url = "https://api.withwrit.com/v1/leases" payload = { "token": "string", "method": "POST", "path": "/v1/refunds" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.withwrit.com/v1/leases'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"token":"string","method":"POST","path":"/v1/refunds"}' }; 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/leases" payload := strings.NewReader("{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\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 require 'uri' require 'net/http' url = URI("https://api.withwrit.com/v1/leases") 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 = "{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withwrit.com/v1/leases") .header("Content-Type", "application/json") .body("{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\n}") .asString(); ``` ```php request('POST', 'https://api.withwrit.com/v1/leases', [ 'body' => '{ "token": "string", "method": "POST", "path": "/v1/refunds" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.withwrit.com/v1/leases"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"token\": \"string\",\n \"method\": \"POST\",\n \"path\": \"/v1/refunds\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "token": "string", "method": "POST", "path": "/v1/refunds" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.withwrit.com/v1/leases")! 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() ```