Access
Preview

Stream the audit entries to a bucket or a webhook

Adds a destination. A bucket (`s3`, `gcs` or `azure`) takes one JSON Lines object for each batch, written with the

POST
/organization/audit-stream/sinks
cookiebetter-auth.session_token<token>

Better Auth session cookie. Production uses the __Secure- prefixed name.

Idempotency-Key?string

Makes retries safe. A repeated key with the same request returns the first result and sets Idempotent-Replayed: true. The same key with a different request answers 409 idempotency.key_reused, and while the first request is still running 409 idempotency.in_progress. Results are kept for 24 hours. Server errors and refusals for lack of sign-in or permission are not kept, so a retry runs again.

Match^[A-Za-z0-9_.:-]+$
Length1 <= length <= 255
application/json
  1. body
kind*AuditStreamSinkKind
Value in"s3""gcs""azure""webhook"
config*

Where the destination is; which fields apply depends on the kind. s3 has bucket, region, accessKeyId and prefix; gcs has bucket and prefix; azure has account, container and prefix; webhook has url. It never holds a credential.

secret?string

The credential the bucket is written with: the S3 secret access key, the Google service account key (the JSON file) or the Azure shared access signature. Required for a bucket and refused for a webhook. It is stored sealed and never returned.

Lengthlength <= 8192
enabled?boolean
Defaulttrue
includeHistory?boolean

Also send the entries that were already kept, from the oldest. Otherwise streaming starts after the newest.

Defaultfalse

Response Body

The destination, and for a webhook its signing secret.

application/json
  1. response
sink*
signingSecret?string

A webhook's signing secret. It is shown here once and cannot be read again.

Example Request
curl -X POST 'https://wardn.example.com/api/v1/organization/audit-stream/sinks' \  -H 'Content-Type: application/json' \  -d '{  "kind": "s3",  "config": {}}'
Example Response
{  "sink": {    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "kind": "s3",    "config": {      "bucket": "string",      "region": "string",      "accessKeyId": "string",      "account": "string",      "container": "string",      "prefix": "string",      "url": "string"    },    "enabled": true,    "state": "active",    "secretHint": "string",    "lastDeliveredAt": "2019-08-24T14:15:22Z",    "lastDeliveredSeq": 0,    "failingSince": "2019-08-24T14:15:22Z",    "lastError": "string",    "pausedAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  },  "signingSecret": "string"}