{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge & Deduplicate Datasets: CSV/Excel Cleaner, Only New Rows",
    "description": "Merge scraper datasets and CSV or Excel files, remove duplicates across all of them, and get only the new rows on scheduled runs. Standardizes emails, phones, dates, names, addresses and countries, and logs each change. $0.01 per 1,000 rows.",
    "version": "1.2",
    "x-build-id": "tr9GlINqlzWMZRQiI"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/patchwell~patchwell-clean-data/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-patchwell-patchwell-clean-data",
        "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/patchwell~patchwell-clean-data/runs": {
      "post": {
        "operationId": "runs-sync-patchwell-patchwell-clean-data",
        "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/patchwell~patchwell-clean-data/run-sync": {
      "post": {
        "operationId": "run-sync-patchwell-patchwell-clean-data",
        "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": {
          "url": {
            "title": "File URL",
            "type": "string",
            "description": "Public link to a CSV, XLSX or JSON file, up to 1 GB. Use this or a dataset ID.",
            "default": "https://api.apify.com/v2/key-value-stores/7MDnpHF243bNUL5C3/records/customers_messy.csv"
          },
          "datasetId": {
            "title": "Or: a dataset from another Actor",
            "type": "string",
            "description": "Pick the dataset of another run, such as a scraper's output, to clean it. Nested fields become columns like address.city."
          },
          "datasetIds": {
            "title": "More datasets to merge in",
            "type": "array",
            "description": "Other datasets (another scraper, or the same scraper's earlier runs) merged with the one above into one table, so duplicates are found across them. Each row gets a source column. Up to 19."
          },
          "urls": {
            "title": "More file URLs to merge in",
            "type": "array",
            "description": "Other CSV, Excel or JSON links merged into the same table. Columns with the same meaning are matched (E-mail / Email Address, phone / phoneNumber / phone_number, website / domain); other columns are kept. The key-value store record columns_matched lists each match.",
            "items": {
              "type": "string"
            }
          },
          "collapseLists": {
            "title": "Turn list columns into one column",
            "type": "boolean",
            "description": "Contact scrapers export lists as many columns (emails/0, emails/1, phones/0 ...). With this on, each list becomes one column (emails) with its values separated by \"; \", and each value is cleaned. Lists in a dataset ([\"a@x.com\", \"b@x.com\"]) are joined the same way.",
            "default": true
          },
          "sheet": {
            "title": "Excel sheet",
            "type": "string",
            "description": "Excel files only: the sheet to clean. Leave it empty to use the first sheet with data."
          },
          "headerRow": {
            "title": "Header line",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "The line that holds the column names, if the cleaner picks the wrong one. It skips title lines above the header on its own."
          },
          "dedupeOn": {
            "title": "Columns that identify a record",
            "type": "array",
            "description": "Rows that match on these columns become one record. Leave it empty and the cleaner picks: the email column, else a place ID (placeId), a profile link, the website or domain (with the phone, so a chain's branches stay apart) or the record's link, else the whole row. The run says which columns it used.",
            "items": {
              "type": "string"
            }
          },
          "required": {
            "title": "Required columns",
            "type": "array",
            "description": "Rows missing any of these go to the review list instead of the clean output.",
            "items": {
              "type": "string"
            }
          },
          "onlyNew": {
            "title": "Only new rows (for scheduled runs)",
            "type": "boolean",
            "description": "Output only the rows this account hasn't sent before under the name below, so a daily scrape gives you just what's new. Patchwell keeps a one-way fingerprint of each record's key, never the values; it is deleted after 90 days without a run.",
            "default": false
          },
          "onlyNewState": {
            "title": "Name of this feed",
            "type": "string",
            "description": "Each name remembers its own rows: use one per scraper or list (letters, digits, dots, dashes).",
            "default": "default"
          },
          "onlyNewKey": {
            "title": "Columns that identify a record",
            "type": "array",
            "description": "How a row is recognised as seen before, e.g. Email or url. Leave it empty to use the email or ID column the cleaner finds.",
            "items": {
              "type": "string"
            }
          },
          "includeChanged": {
            "title": "Also output rows that changed",
            "type": "boolean",
            "description": "A row seen before whose other fields changed (a new price, a new title) is output too.",
            "default": false
          },
          "outputDatasetName": {
            "title": "Also add clean records to this named dataset",
            "type": "string",
            "description": "A name like daily-leads. Each run also appends its clean records to this dataset in your account, created on the first run, so a schedule builds one feed in one place. Use a new name: this Actor can only write to a dataset it created. Letters, digits and dashes."
          },
          "rules": {
            "title": "Rules",
            "type": "array",
            "description": "Checks on the clean records. Failing records are flagged and listed in the review list as rule_failed. Example: [{\"column\": \"Age\", \"range\": [0, 120]}, {\"column\": \"Plan\", \"one_of\": [\"free\", \"pro\"], \"fix\": true}, {\"column\": \"Email\", \"unique\": true}, {\"column\": \"End\", \"after\": \"Start\"}]. Add \"action\": \"review\" to hold failing records back."
          },
          "target": {
            "title": "Import template",
            "type": "object",
            "description": "Map the output onto your format, in its order: {\"columns\": [{\"name\": \"email\", \"required\": true}, {\"name\": \"contact\", \"from\": [\"Full Name\"]}], \"extra\": \"drop\"}. Columns without \"from\" match by meaning."
          },
          "phoneRegion": {
            "title": "Phone region",
            "type": "string",
            "description": "Country for phone numbers written without a country code, as a two-letter code: US, GB, DE, IN...",
            "default": "US"
          },
          "phoneFormat": {
            "title": "Phone output format",
            "enum": [
              "national",
              "e164"
            ],
            "type": "string",
            "description": "How cleaned phone numbers are written.",
            "default": "national"
          },
          "fixEmailTypos": {
            "title": "Fix typos in email domains",
            "type": "boolean",
            "description": "Correct obvious typos in big mail providers, like gmial.com to gmail.com. Each fix is in the change log.",
            "default": true
          },
          "keepRaw": {
            "title": "Columns to leave exactly as they are",
            "type": "array",
            "description": "Passed through byte for byte: no trimming, no encoding repair, never typed.",
            "items": {
              "type": "string"
            }
          },
          "applyClusters": {
            "title": "Make spellings consistent",
            "enum": [
              "off",
              "same_words",
              "all"
            ],
            "type": "string",
            "description": "Writes each value the way most of the column writes it. Each change is in the change log.",
            "default": "off"
          },
          "checkEmailDomains": {
            "title": "Check that email domains can receive mail",
            "type": "boolean",
            "description": "One DNS lookup per domain; never contacts a mailbox. A domain that doesn't exist gets a note.",
            "default": true
          },
          "encoding": {
            "title": "Text encoding",
            "type": "string",
            "description": "Only if the automatic choice garbles characters: utf-8, cp1252, latin-1, shift_jis, cp1251, gb18030..."
          },
          "minDuplicateConfidence": {
            "title": "List possible duplicates from",
            "enum": [
              "0.3",
              "0.5",
              "0.7",
              "0.9"
            ],
            "type": "string",
            "description": "Records that look like the same person or company under a different email are listed for review, never merged. This sets how likely a pair must be to appear in that list.",
            "default": "0.5"
          },
          "table": {
            "title": "Main table",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "For a file that holds several tables: which one to return as the main result (1 = the first). By default the largest; every other table is saved cleaned in the key-value store as other_tables."
          },
          "recipe": {
            "title": "Recipe from an earlier run",
            "type": "object",
            "description": "Each run saves a recipe in its key-value store. Paste it here to clean next month's file with the same column types and rules."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}