# Create an artifact Declare the exact filename, byte size and SHA-256 before uploading content. `POST /v1/artifacts` ## Start a file upload Calculate size and SHA-256 from the bytes you will upload. Save the returned id, upload\_url and complete\_url. ## What to do next The example hash is illustrative. The upload helper calculates real values for you. [Read the step-by-step guide →](https://www.security.run/docs/upload-inputs.html) Send an `Idempotency-Key`. Keep the same key and body when retrying this operation. ### Parameters #### `authorization` · `header · string | null` · required #### `idempotency-key` · `header · string | null` · required ### Request body #### `filename` · `string` · required Filename Max length: 240 · Pattern: "^\[^/\\\\\\\\\\\\x00-\\\\x1f\]+$" #### `size` · `integer` · required Size Minimum: 1.0 · Maximum: 67108864.0 #### `sha256` · `string` · required Sha256 Pattern: "^\[a-f0-9\]{64}$" #### `retention_seconds` · `integer` Retention Seconds Default: 604800 · Minimum: 3600.0 · Maximum: 7776000.0 ### Responses - `201` Successful Response - `422` Validation Error ## Request ```bash curl -X POST "$SECURITY_RUN_URL/v1/artifacts" \ -H "Authorization: Bearer $SECURITY_RUN_API_KEY" \ -H "Idempotency-Key: unique-request-key" \ -H "Content-Type: application/json" \ --data '{"filename": "sample.txt", "size": 18, "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}' ``` ## Request ```python import os, httpx headers = {'Idempotency-Key': 'unique-request-key', 'Content-Type': 'application/json'} headers["Authorization"] = "Bearer " + os.environ["SECURITY_RUN_API_KEY"] response = httpx.request('POST', os.environ["SECURITY_RUN_URL"].rstrip("/") + '/v1/artifacts', headers=headers, json={'filename': 'sample.txt', 'size': 18, 'sha256': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}) response.raise_for_status() print(response.text) ``` ## Request ```javascript const base = process.env.SECURITY_RUN_URL.replace(/\/$/, ""); const headers = { "Idempotency-Key": "unique-request-key", "Content-Type": "application/json" }; headers.Authorization = `Bearer ${process.env.SECURITY_RUN_API_KEY}`; const response = await fetch(base + "/v1/artifacts", { method: "POST", headers, body: JSON.stringify({ "filename": "sample.txt", "size": 18, "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }) }); if (!response.ok) throw new Error(`HTTP ${response.status}`); console.log(await response.text()); ```