{
  "openapi": "3.0.1",
  "info": {
    "title": "Bulk File & Image Downloader — S3, Cloudflare R2, ZIP & WebP",
    "description": "Bulk download public images, PDFs, audio, and media files from URLs or Apify Datasets. Optimize images to WebP/AVIF, deduplicate by SHA-256, create ZIP archives, or sync to AWS S3, Cloudflare R2, and Backblaze B2.",
    "version": "1.0",
    "x-build-id": "knm4dELnCaBVBPSLL"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/structmint~bulk-file-media-downloader/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-structmint-bulk-file-media-downloader",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/structmint~bulk-file-media-downloader/runs": {
      "post": {
        "operationId": "runs-sync-structmint-bulk-file-media-downloader",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/structmint~bulk-file-media-downloader/run-sync": {
      "post": {
        "operationId": "run-sync-structmint-bulk-file-media-downloader",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "urls": {
            "title": "File & Media URLs",
            "type": "array",
            "description": "Array of public HTTP/HTTPS URLs to download. Each entry may be a plain URL string or an object { \"url\": \"https://...\", \"filename\": \"optional.webp\", \"folder\": \"catalog/2026\", \"metadata\": { \"sku\": \"A1\" } }. Private, loopback, link-local, and metadata IP addresses are blocked across initial requests and redirects."
          },
          "sourceDatasetId": {
            "title": "Source Apify Dataset",
            "type": "string",
            "description": "Optional Apify Dataset to read records from and extract URLs using urlFieldPaths. Uses Apify's native Dataset Resource Picker with READ-only scope under LIMITED_PERMISSIONS, and supports direct Actor-to-Actor Add integration triggers (pass {{resource.defaultDatasetId}} or rely on automatic payload.resource.defaultDatasetId fallback when omitted)."
          },
          "sourceDatasetUrl": {
            "title": "Source Dataset JSON URL",
            "type": "string",
            "description": "Optional public or token-authorized HTTP/HTTPS URL returning a JSON array (or { \"items\": [...] } / NDJSON) of records whose URLs are extracted using urlFieldPaths."
          },
          "urlFieldPaths": {
            "title": "Dataset URL Field Paths",
            "type": "array",
            "description": "Dot and bracket paths used to extract URLs from each dataset item (supports nested arrays such as 'imageUrl', 'images[].url', 'media.files[].href', or 'attachments[]').",
            "default": [
              "url",
              "imageUrl",
              "fileUrl",
              "pdfUrl",
              "downloadUrl",
              "images[].url",
              "media.files[].href"
            ],
            "items": {
              "type": "string"
            }
          },
          "maxFiles": {
            "title": "Maximum Files to Process",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Upper limit on unique URLs queued per run (1 to 50,000).",
            "default": 1000
          },
          "concurrency": {
            "title": "Concurrent Downloads",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "Number of simultaneous HTTP download workers (1 to 20). Keep between 4 and 10 for balanced throughput without overwhelming origin servers.",
            "default": 5
          },
          "timeoutSecs": {
            "title": "Per-Request Timeout (Seconds)",
            "minimum": 5,
            "maximum": 300,
            "type": "integer",
            "description": "Maximum seconds to wait per HTTP request before aborting and retrying if eligible.",
            "default": 30
          },
          "maxRetries": {
            "title": "Max Retries on Transient Errors",
            "minimum": 0,
            "maximum": 5,
            "type": "integer",
            "description": "Number of automatic retries with exponential backoff on HTTP 429, 502, 503, 504, or temporary network errors.",
            "default": 2
          },
          "maxRedirects": {
            "title": "Maximum HTTP Redirect Hops",
            "minimum": 0,
            "maximum": 15,
            "type": "integer",
            "description": "Maximum redirect hops followed per URL. Every redirect hop is validated against SSRF network rules before connecting.",
            "default": 5
          },
          "maxFileSizeMb": {
            "title": "Max File Size (MB)",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Hard streaming byte cap per file in megabytes. Downloads exceeding this limit are aborted mid-stream before consuming excess memory and are never billed.",
            "default": 50
          },
          "allowedMimePrefixes": {
            "title": "Allowed MIME Type Prefixes",
            "type": "array",
            "description": "Optional allowlist of MIME type prefixes (for example ['image/', 'application/pdf']). Leave empty to accept all content types. Rejected files are aborted before buffering and are never billed.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "customHeaders": {
            "title": "Custom HTTP Request Headers",
            "type": "object",
            "description": "Optional key-value HTTP headers sent on download requests (for example { \"Accept\": \"image/*,application/pdf\" }). Sensitive Authorization and Cookie headers are automatically stripped on cross-origin redirects.",
            "default": {}
          },
          "filenameStrategy": {
            "title": "Filename Generation Strategy",
            "enum": [
              "original",
              "hash",
              "sequential",
              "url-slug"
            ],
            "type": "string",
            "description": "How output filenames are chosen when an item does not supply an explicit filename. Collisions are automatically suffixed (-2, -3) so files never overwrite each other.",
            "default": "original"
          },
          "optimizeImages": {
            "title": "Enable Image Optimization",
            "type": "boolean",
            "description": "When enabled, converts and/or resizes supported raster images and records originalBytes, finalBytes, bytesSaved, width, and height in the dataset.",
            "default": false
          },
          "imageFormat": {
            "title": "Target Image Format",
            "enum": [
              "webp",
              "avif",
              "jpeg",
              "png",
              "original"
            ],
            "type": "string",
            "description": "Output format applied to raster images when optimizeImages is true. Select 'original' to re-encode in the source format.",
            "default": "webp"
          },
          "imageQuality": {
            "title": "Image Quality (1–100)",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Encoder quality setting for WebP, AVIF, JPEG, or PNG optimization (1 to 100).",
            "default": 82
          },
          "maxWidth": {
            "title": "Max Image Width (Pixels)",
            "minimum": 16,
            "maximum": 16384,
            "type": "integer",
            "description": "Optional maximum width in pixels. Aspect ratio is preserved and images smaller than maxWidth are never upscaled."
          },
          "maxHeight": {
            "title": "Max Image Height (Pixels)",
            "minimum": 16,
            "maximum": 16384,
            "type": "integer",
            "description": "Optional maximum height in pixels. Aspect ratio is preserved and images smaller than maxHeight are never upscaled."
          },
          "stripMetadata": {
            "title": "Strip EXIF & Camera Metadata",
            "type": "boolean",
            "description": "When true (default), auto-orients pixels then strips EXIF, GPS, and XMP metadata from optimized images to save bytes and protect privacy.",
            "default": true
          },
          "storeInKvs": {
            "title": "Save Individual Files to Apify Key-Value Store",
            "type": "boolean",
            "description": "Store each downloaded file as a record in the default Key-Value Store and emit its direct kvsUrl in the dataset. Disable when streaming directly to S3/R2 only.",
            "default": true
          },
          "createZipArchive": {
            "title": "Create Streaming ZIP Archive (ARCHIVE.zip)",
            "type": "boolean",
            "description": "Stream all downloaded non-duplicate files into a single ZIP archive saved in the default Key-Value Store (default key ARCHIVE.zip).",
            "default": false
          },
          "zipFilename": {
            "title": "ZIP Archive Key Name",
            "type": "string",
            "description": "Record key name used when saving the ZIP archive to the default Key-Value Store.",
            "default": "ARCHIVE.zip"
          },
          "uploadToS3": {
            "title": "Upload Files to S3-Compatible Bucket",
            "type": "boolean",
            "description": "When enabled, uploads downloaded files directly via PutObject to AWS S3, Cloudflare R2, Backblaze B2, GCS S3-interop, Wasabi, MinIO, or DigitalOcean Spaces.",
            "default": false
          },
          "s3Endpoint": {
            "title": "S3-Compatible Endpoint URL",
            "type": "string",
            "description": "Custom endpoint URL for Cloudflare R2 (https://<account-id>.r2.cloudflarestorage.com), Backblaze B2 (https://s3.<region>.backblazeb2.com), GCS S3-interop, Wasabi, or MinIO. Leave empty for standard AWS S3."
          },
          "s3Region": {
            "title": "Bucket Region",
            "type": "string",
            "description": "Storage region name (use 'auto' for Cloudflare R2, or the AWS/B2 region such as 'us-east-1' or 'eu-central-1').",
            "default": "auto"
          },
          "s3Bucket": {
            "title": "Target Bucket Name",
            "type": "string",
            "description": "Destination S3/R2/B2 bucket name (required when uploadToS3 is true)."
          },
          "s3Prefix": {
            "title": "Object Key Prefix / Folder",
            "type": "string",
            "description": "Optional leading folder prefix prepended to all uploaded object keys (for example 'media/catalog/2026').",
            "default": ""
          },
          "accessKeyId": {
            "title": "S3 / R2 Access Key ID",
            "type": "string",
            "description": "Access Key ID for AWS S3, Cloudflare R2, Backblaze B2, or S3-compatible HMAC authentication. Encrypted at rest by Apify and never written to logs or datasets."
          },
          "secretAccessKey": {
            "title": "S3 / R2 Secret Access Key",
            "type": "string",
            "description": "Secret Access Key paired with accessKeyId. Encrypted at rest by Apify and never written to logs or datasets."
          },
          "s3ForcePathStyle": {
            "title": "Force Path-Style S3 URLs",
            "type": "boolean",
            "description": "Enable path-style addressing (endpoint/bucket/key) when required by MinIO or self-hosted S3-compatible gateways.",
            "default": false
          },
          "s3PublicBaseUrl": {
            "title": "Public CDN Base URL (Optional)",
            "type": "string",
            "description": "Optional custom public CDN or R2 custom domain (for example 'https://cdn.example.com') used to construct clean cloudUrl links in the output dataset."
          },
          "s3CacheControl": {
            "title": "S3 Cache-Control Header",
            "type": "string",
            "description": "Cache-Control HTTP header stored on uploaded cloud objects.",
            "default": "public, max-age=31536000, immutable"
          },
          "s3Acl": {
            "title": "S3 Object ACL (Optional)",
            "enum": [
              "",
              "private",
              "public-read"
            ],
            "type": "string",
            "description": "Optional canned ACL sent on PutObject. Leave empty (recommended) for Cloudflare R2 and buckets with Object Ownership / Bucket Owner Enforced.",
            "default": ""
          },
          "skipExistingInBucket": {
            "title": "Skip Upload If Object Already Exists in Bucket",
            "type": "boolean",
            "description": "Performs a lightweight HeadObject check before uploading. If the exact object key already exists in the bucket, skips re-uploading and avoids cloud upload charges.",
            "default": true
          },
          "deduplicateByHash": {
            "title": "Deduplicate Identical Files by SHA-256",
            "type": "boolean",
            "description": "Computes SHA-256 digests within each run so duplicate binaries served at different URLs are skipped with zero storage, upload, or billing duplication.",
            "default": true
          },
          "watchMode": {
            "title": "Enable Incremental Watch Mode",
            "type": "boolean",
            "description": "Persists processed URL and SHA-256 fingerprints in a user-scoped Named Key-Value Store (structmint-bulk-media-watch-v1, 90-day retention) so recurring schedules process only newly added files.",
            "default": false
          },
          "onlyNew": {
            "title": "Skip Previously Seen Files in Watch Mode",
            "type": "boolean",
            "description": "Used with watchMode=true. Skips URLs and SHA-256 hashes already processed in earlier runs with zero event charges.",
            "default": true
          },
          "watchStateKey": {
            "title": "Watch State Namespace Key",
            "type": "string",
            "description": "Stable namespace separating saved watch checkpoints for different pipelines or schedules (for example 'daily-catalog-r2-sync').",
            "default": "default-media-watch"
          },
          "maxTotalChargeUsd": {
            "title": "Maximum Total Charge (USD)",
            "minimum": 0.01,
            "maximum": 1000,
            "type": "number",
            "description": "Optional hard spend ceiling in USD for this run. If reached, remaining queued URLs are gracefully skipped and marked budget_skipped without exceeding the cap."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}