Authentifizierung
Für die öffentliche API nutzt du immer dieselben Token-Muster:
- Sende den Token als
Authorization: Bearer <token>. - Oder sende ihn per Basic Auth mit dem Token als Passwort.
Bei Basic Auth nutzt du als Benutzernamen am besten die Robot-ID, wenn du eine hast. Wenn deine Robot-ID my-robot ist, nutzt du my-robot als Benutzernamen und den Token als Passwort. Der Platzhalter __token__ funktioniert ebenfalls, aber die Robot-ID ist später besser zuzuordnen.
Benutzername: my-robot
Passwort: <token>
Für Token-Erzeugung und Rotation im Tab Robot accounts siehe Robot-Account anlegen und Token nutzen.
OpenAPI-Dateien
Lade den aktuellen maschinenlesbaren Vertrag direkt herunter:
Endpunkt-Übersicht
Klappe einen Endpunkt auf, um ein minimales Request-Beispiel zu sehen und bei Bedarf in den vollständigen Vertrag zu springen.
/api/artifacts/search/
Resolve package artifact IDs
curl \
-H "Authorization: Bearer $CRAFTIFACT_TOKEN" \
"https://packages.example.com/api/artifacts/search/?repository=libs-release&format=maven&group_id=com.example&name=demo&version=1.2.3"
/api/sbom/upload/
Upload a CycloneDX JSON SBOM
curl \
-X POST \
-H "Authorization: Bearer $CRAFTIFACT_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @dist/example-cyclonedx.json \
"https://packages.example.com/api/sbom/upload/?artifact_id=ARTIFACT_ID"
/api/sbom/vulnerabilities/report/
Read the effective SBOM vulnerability report for one subject
curl \
-H "Authorization: Bearer $CRAFTIFACT_TOKEN" \
"https://packages.example.com/api/sbom/vulnerabilities/report/?repository=libs-release&artifact_id=ARTIFACT_ID"
/api/evidence/snapshots/
Create an evidence snapshot
curl \
-X POST \
-H "Authorization: Bearer $CRAFTIFACT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Release 1.0 review","subjects":[{"repository":"libs-release","artifact_id":"ARTIFACT_ID"},{"repository":"containers","oci_digest":"sha256:DIGEST"}]}' \
"https://packages.example.com/api/evidence/snapshots/"
/api/evidence/snapshots/
List evidence snapshots
curl \
-H "Authorization: Bearer $CRAFTIFACT_TOKEN" \
"https://packages.example.com/api/evidence/snapshots/"
/api/evidence/snapshots/{snapshot_id}/
Read an evidence snapshot
curl \
-H "Authorization: Bearer $CRAFTIFACT_TOKEN" \
"https://packages.example.com/api/evidence/snapshots/SNAPSHOT_ID/"
/api/evidence/snapshots/{snapshot_id}/export/
Export an evidence snapshot
curl \
-H "Authorization: Bearer $CRAFTIFACT_TOKEN" \
-o evidence-snapshot.zip \
"https://packages.example.com/api/evidence/snapshots/SNAPSHOT_ID/export/"