Zum Inhalt springen

Artefakte-API-Referenz

GET /v1/artifacts/*: die Bytes hinter dem screenshotKey eines Workflow-Blocks, auf die Organisation geprüft, mit Content-Type und Digest, bis die Aufbewahrung endet.

Zuletzt aktualisiert:

GET /v1/artifacts/*

Liefert ein gespeichertes Artefakt anhand seines Schlüssels als Bytes. Der Schlüssel stammt aus `blocks[].screenshotKey` eines Workflow-Laufs.

Antwort-Header

Ein Schlüssel einer anderen Organisation, ein abgelaufenes Artefakt und ein fehlerhafter Schlüssel antworten alle mit `not_found`; nichts unterscheidet sie, mit Absicht.

Name Typ Beschreibung
Content-Type Header Der Typ des Artefakts, `image/png` bei Screenshots.
X-Browserberg-Digest Header `sha256=<hex>` der Bytes, derselbe Digest, den der Audit-Eintrag für den Block festgehalten hat, sodass sich ein Bild an eine Protokollzeile binden lässt.
Cache-Control Header `private, no-store`.

Den Screenshot eines Laufs holen

BASE="https://browserberg.com"
AUTH="Authorization: Bearer $BROWSERBERG_API_KEY"

# The newest workflow run with a screenshot; the guide-workflow-run snippet created one.
KEY=$(curl -s "$BASE/v1/workflow-runs?limit=20" -H "$AUTH" \
  | python3 -c 'import json,sys; runs=json.load(sys.stdin)["runs"]; keys=[b["screenshotKey"] for r in runs for b in r["blocks"] if b.get("screenshotKey")]; print(keys[0] if keys else "")')

if [ -z "$KEY" ]; then echo "no screenshot yet"; exit 0; fi

curl -s "$BASE/v1/artifacts/$KEY" -H "$AUTH" -D /tmp/artifact-headers -o /tmp/artifact.bin
grep -i '^content-type' /tmp/artifact-headers | tr -d '\r'
grep -i '^x-browserberg-digest' /tmp/artifact-headers | cut -c1-30 | tr -d '\r'
echo "bytes: $(wc -c < /tmp/artifact.bin | tr -d ' ')"

Hinweis · Aufbewahrung

Artefakte laufen mit dem Aufbewahrungsfenster ab, standardmäßig 72 Stunden. Ein Lauf behält seinen `screenshotKey` danach; der Abruf antwortet mit `not_found`.

Verwandt

  • Workflows-Referenz Wo screenshotKey auftaucht
  • Audit-Log artifactDigests an einem Eintrag