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

# Stream the tenant audit log (SSE)

GET https://api.withwrit.com/v1/receipts/stream

API key required (`Authorization: Bearer <key>`, or `?apiKey=` for
browsers' EventSource, which cannot set headers). Server-sent
events: each `event: receipt` frame's data is one complete receipt,
plus `: ping` heartbeats. On connect, replays the most recent
`replay` receipts (default 20, max 50), then holds the connection
open up to `timeout` seconds (default 10, max 12) emitting new
receipts, then closes. Reconnect and resume with `since` (a
receiptId) or the `Last-Event-ID` header EventSource sends
automatically; the cursor guarantees at-least-once delivery with
no gaps. `decision` filters the replay and the live hold to one
decision (ALLOW, DENY, or STEP\_UP, case-insensitive; anything else
is a 400). One tenant's stream never carries another tenant's
receipts. This is the feed behind `./writ stream` and the
dashboard's live audit log.

Reference: https://docs.withwrit.com/api-reference/audit-log/stream-the-tenant-audit-log-sse

## Servers

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

## Request

### Query parameters

- `since` (string, optional) — Resume after this receiptId; only newer receipts are sent.
- `replay` (integer, optional, default: 20) — How many recent receipts to send on connect when no `since` is given (max 50).
- `timeout` (integer, optional, default: 10) — Seconds to hold the connection open before closing (max 12).
- `decision` (enum, optional) — Only stream receipts with this decision.
  - Allowed values: `ALLOW`, `DENY`, `STEP_UP`

## Response

### 200

SSE stream of receipt frames.

- Streaming response of `string`.

## Errors

### 400 Bad Request Error

Invalid `decision` filter.

### 401 Unauthorized Error

Missing or unknown API key.

## Examples

**SDK Code**

```python
import requests

url = "https://api.withwrit.com/v1/receipts/stream"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://api.withwrit.com/v1/receipts/stream';
const options = {method: 'GET'};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.withwrit.com/v1/receipts/stream"

	req, _ := http.NewRequest("GET", url, nil)

	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/receipts/stream")

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

request = Net::HTTP::Get.new(url)

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.get("https://api.withwrit.com/v1/receipts/stream")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.withwrit.com/v1/receipts/stream');

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

```csharp
using RestSharp;

var client = new RestClient("https://api.withwrit.com/v1/receipts/stream");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.withwrit.com/v1/receipts/stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

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()
```