> 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. # Mint a public badge token for your tenant POST https://api.withwrit.com/v1/badge/tokens Content-Type: application/json API key required. Mints a badge token (`writ_badge_...`) for the caller's tenant and returns the badge image URL plus a ready-to-paste Markdown snippet. Embed the snippet in your README: the badge renders a live count of your tenant's gated writes over the trailing 30 days, straight from your audit log. The token is public by design — it lives in your README image URL — and grants nothing: it cannot be used as an API key (see the 401 below). It maps to your tenant server-side, so the badge image never leaks tenant IDs, keys, or receipt contents. The token is shown exactly once; store it — you need it to revoke the badge. Optional `label` (max 40 chars, `[A-Za-z0-9 _.-]`) is stored for your own bookkeeping and never rendered. Reference: https://docs.withwrit.com/api-reference/badge/mint-a-public-badge-token-for-your-tenant ## 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. - `label` (string, optional) — Optional private label for this badge token (not rendered on the badge). ## Response ### 201 Badge token, image URL, and embed snippet. ## Errors ### 401 Unauthorized Error Missing or unknown API key. ## Examples **Request** ```json { "label": "support-agent repo" } ``` **Response** ```json { "badgeToken": "writ_badge_9dKx2mQvR4tY7wZ1aB3cD5eF6gH8jK0lMn", "badgeUrl": "https://api.withwrit.com/v1/badge/writ_badge_9dKx2mQvR4tY7wZ1aB3cD5eF6gH8jK0lMn.svg", "label": "support-agent repo", "markdown": "[![agent writes gated by Writ](https://api.withwrit.com/v1/badge/writ_badge_9dKx2mQvR4tY7wZ1aB3cD5eF6gH8jK0lMn.svg)](https://withwrit.com)", "note": "The badge token is public by design — it lives in your README. It cannot be used as an API key. Store it: it is shown once and is required to revoke the badge." } ``` **SDK Code** ```python Badge_mintAPublicBadgeTokenForYourTenant_example import requests url = "https://api.withwrit.com/v1/badge/tokens" payload = { "label": "support-agent repo" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Badge_mintAPublicBadgeTokenForYourTenant_example const url = 'https://api.withwrit.com/v1/badge/tokens'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"label":"support-agent repo"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Badge_mintAPublicBadgeTokenForYourTenant_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.withwrit.com/v1/badge/tokens" payload := strings.NewReader("{\n \"label\": \"support-agent repo\"\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 Badge_mintAPublicBadgeTokenForYourTenant_example require 'uri' require 'net/http' url = URI("https://api.withwrit.com/v1/badge/tokens") 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 \"label\": \"support-agent repo\"\n}" response = http.request(request) puts response.read_body ``` ```java Badge_mintAPublicBadgeTokenForYourTenant_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withwrit.com/v1/badge/tokens") .header("Content-Type", "application/json") .body("{\n \"label\": \"support-agent repo\"\n}") .asString(); ``` ```php Badge_mintAPublicBadgeTokenForYourTenant_example request('POST', 'https://api.withwrit.com/v1/badge/tokens', [ 'body' => '{ "label": "support-agent repo" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Badge_mintAPublicBadgeTokenForYourTenant_example using RestSharp; var client = new RestClient("https://api.withwrit.com/v1/badge/tokens"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"label\": \"support-agent repo\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Badge_mintAPublicBadgeTokenForYourTenant_example import Foundation let headers = ["Content-Type": "application/json"] let parameters = ["label": "support-agent repo"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.withwrit.com/v1/badge/tokens")! 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() ```