{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge & Dedupe Datasets – Company & Lead Deduplication",
    "description": "Datasets, files or inline JSON in, one merged dataset without duplicates out – streaming, on small memory, with limited permissions. Company mode to deduplicate leads: lead lists in, one row per company out, matched by company name, website domain, email domain or phone, with the reason in each row.",
    "version": "0.1",
    "x-build-id": "BfUgPROFLZZom8o6Y"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/perceptr0n~merge-dedupe-datasets-company-leads/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-perceptr0n-merge-dedupe-datasets-company-leads",
        "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/perceptr0n~merge-dedupe-datasets-company-leads/runs": {
      "post": {
        "operationId": "runs-sync-perceptr0n-merge-dedupe-datasets-company-leads",
        "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/perceptr0n~merge-dedupe-datasets-company-leads/run-sync": {
      "post": {
        "operationId": "run-sync-perceptr0n-merge-dedupe-datasets-company-leads",
        "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": {
          "datasets": {
            "title": "Datasets",
            "type": "array",
            "description": "Apify datasets to merge, as dataset IDs — pick them here or pass `[\"id1\", \"id2\"]` over the API. Their order is their rank: when rows are merged, the row from the top dataset is the base. Read access to exactly these datasets is all the run gets (limited permissions). `datasetIds` is read as the same field."
          },
          "fileUrls": {
            "title": "File addresses (CSV, JSON, JSON Lines)",
            "type": "array",
            "description": "Public addresses of files with rows: a JSON list of objects, JSON Lines, or CSV with a header row (comma, semicolon or tab; .gz is unpacked). Up to 400 MB per file. Files come after the datasets in rank.",
            "items": {
              "type": "string"
            }
          },
          "items": {
            "title": "Rows in the input (JSON)",
            "type": "array",
            "description": "Rows given directly, as a JSON list of objects, e.g. `[{\"company\": \"Acme GmbH\", \"website\": \"acme.example\"}]`. They come last in rank. An ID written here is plain text: a dataset must be given in `datasets` to be read."
          },
          "keyValueStore": {
            "title": "Key-value store with records to read",
            "type": "string",
            "description": "A key-value store that holds records with rows (JSON list, JSON Lines or CSV). Name the records in `recordKeys`."
          },
          "recordKeys": {
            "title": "Record keys",
            "type": "array",
            "description": "Keys of the records to read from `keyValueStore`, e.g. `OUTPUT` or `leads.csv`.",
            "items": {
              "type": "string"
            }
          },
          "mode": {
            "title": "What to do",
            "type": "string",
            "description": "`dedupe` (default) = remove duplicates: rows that agree in `dedupeFields` (or in every field) count once. `merge` = only put the sources together, remove nothing. `companies` = one row per company: rows that share a website domain, an email domain, a phone number, or the same company name without its legal form at the same place become one row, with the reason in `matchedBy`. `companies` is charged at the higher `company-row` price.",
            "default": "dedupe"
          },
          "dedupeFields": {
            "title": "Fields that make two rows the same",
            "type": "array",
            "description": "Mode `dedupe`: two rows are duplicates when they agree in all of these fields, e.g. `[\"url\"]` or `[\"email\", \"lastName\"]`; nested fields as `address.city`. Empty = the whole row must agree. A row with no value in any of these fields is always kept. In mode `companies` the fields are an additional exact link (`exact_key`). `fields` is read as the same field.",
            "items": {
              "type": "string"
            }
          },
          "normalize": {
            "title": "Ignore case, blanks and the way addresses and phone numbers are written",
            "type": "boolean",
            "description": "On (default): `ACME` = `acme`, `https://www.example.com/?utm_source=x` = `example.com`, `+49 30 123 45 67` = `+49301234567`, runs of blanks count once. Off: values must be equal as stored. A missing field, null and an empty text are always the same.",
            "default": true
          },
          "keep": {
            "title": "Which row stays",
            "enum": [
              "first",
              "last",
              "mostComplete",
              "merge"
            ],
            "type": "string",
            "description": "`first` (default in `dedupe`) = the first row in the order of the sources. `last` = the last. `mostComplete` = the row with the most filled fields. `merge` (default in `companies`) = the first row, with its empty fields filled from the others in order; a filled value is never overwritten. `first` needs one pass over the rows, the others two."
          },
          "output": {
            "title": "What to write",
            "type": "string",
            "description": "`unique` (default) = the cleaned rows. `duplicates` = only the rows that were removed, each with its `matchGroup`. `all` = every row with its `matchGroup` (and `companyNameKey` in mode `companies`), to check every decision. No row disappears silently: `unique` plus `duplicates` is the input.",
            "default": "unique"
          },
          "matchOn": {
            "title": "What may link two rows to one company",
            "type": "array",
            "description": "Mode `companies`. `domain` = same registrable domain of the website (`shop.example.com` = `example.com`; social profiles, map links, marketplaces and link lists do not count). `email_domain` = same domain of the email address (public mailbox providers do not count). `phone` = same number after normalisation, at least 7 digits. `company_name` = same name without legal form, see `nameMatch`. Default: all four.",
            "items": {
              "type": "string",
              "enum": [
                "domain",
                "email_domain",
                "phone",
                "company_name"
              ],
              "enumTitles": [
                "Website domain",
                "Email domain",
                "Phone number",
                "Company name without legal form"
              ]
            },
            "default": [
              "domain",
              "email_domain",
              "phone",
              "company_name"
            ]
          },
          "nameMatch": {
            "title": "When the company name counts",
            "enum": [
              "with_place",
              "anywhere"
            ],
            "type": "string",
            "description": "`with_place` (default) = the same name without legal form links two rows only when the postal code or the town is the same too (`Elektro Müller` in two towns stays two companies). `anywhere` = the name alone is enough — for lists of large companies with branches. One-word everyday names such as `Hotel` never link on the name alone.",
            "default": "with_place"
          },
          "companyNameField": {
            "title": "Field with the company name",
            "type": "string",
            "description": "Leave empty to have it found: `companyName`, `company`, `organization`, `employer`, `title`, `name` and similar, in every source separately. Name a field (e.g. `employer.name`) to use it first. The fields actually used are listed in the record `SUMMARY`."
          },
          "websiteField": {
            "title": "Field with the website",
            "type": "string",
            "description": "Leave empty to have it found (`website`, `domain`, `homepage`, `companyWebsite` …). A field `url` is not used unless you name it here, because it usually holds the address of the listing, not of the company."
          },
          "emailField": {
            "title": "Field with the email address",
            "type": "string",
            "description": "Leave empty to have it found (`email`, `emails`, `contactEmail` …). Lists of addresses are read entry by entry."
          },
          "phoneField": {
            "title": "Field with the phone number",
            "type": "string",
            "description": "Leave empty to have it found (`phone`, `phones`, `telephone`, `phoneUnformatted` …)."
          },
          "cityField": {
            "title": "Field with the town",
            "type": "string",
            "description": "Leave empty to have it found (`city`, `town`, `address.city` …). Without a town or postal code field, both are read from a one-line `address`."
          },
          "postalCodeField": {
            "title": "Field with the postal code",
            "type": "string",
            "description": "Leave empty to have it found (`postalCode`, `zip`, `plz`, `address.postalCode` …)."
          },
          "defaultCountry": {
            "title": "Country of phone numbers without a country code",
            "enum": [
              "DE",
              "AT",
              "CH",
              "FR",
              "NL",
              "BE",
              "LU",
              "GB",
              "IE",
              "IT",
              "ES",
              "PT",
              "DK",
              "SE",
              "NO",
              "FI",
              "PL",
              "CZ",
              "SK",
              "HU",
              "RO",
              "BG",
              "HR",
              "SI",
              "GR",
              "TR",
              "US",
              "CA",
              "MX",
              "BR",
              "AU",
              "NZ",
              "IN",
              "JP",
              "SG",
              "AE",
              "ZA"
            ],
            "type": "string",
            "description": "`030 1234567` and `+49 30 1234567` are the same number only when the country is known. It is taken from the row (`countryCode`, `country`) when there is one; otherwise from here. Without a country, numbers match only when they are written with the same digits."
          },
          "keepFields": {
            "title": "Columns to keep",
            "type": "array",
            "description": "Only these fields are written, in this order (nested fields as `address.city`). Empty = all. Applied after duplicates are found, so a field can be compared and still left out. `fieldsToLoad` is read as the same field.",
            "items": {
              "type": "string"
            }
          },
          "dropFields": {
            "title": "Columns to drop",
            "type": "array",
            "description": "Fields that are not written.",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Columns to rename",
            "type": "object",
            "description": "Old name → new name, e.g. `{\"title\": \"companyName\", \"phoneUnformatted\": \"phone\"}`. Applied to the rows written, after duplicates are found."
          },
          "filters": {
            "title": "Keep only rows that match",
            "type": "array",
            "description": "A list of conditions, e.g. `[{\"field\": \"countryCode\", \"op\": \"eq\", \"value\": \"DE\"}, {\"field\": \"website\", \"op\": \"exists\"}]`. Comparisons: `eq`, `ne`, `contains`, `notContains`, `exists`, `missing`, `gt`, `gte`, `lt`, `lte`. Rows that do not match are read and charged, but not written."
          },
          "filterMode": {
            "title": "A row must match",
            "enum": [
              "all",
              "any"
            ],
            "type": "string",
            "description": "`all` (default) = every condition; `any` = at least one.",
            "default": "all"
          },
          "addSourceField": {
            "title": "Add where each row came from",
            "type": "boolean",
            "description": "Adds the field `sources` to every row: the source and the row number in it. Merged rows always carry it.",
            "default": false
          },
          "outputDataset": {
            "title": "Also append the rows to this dataset",
            "type": "string",
            "description": "Optional: an existing dataset of yours that also receives the rows written, for example a named dataset that collects the results of every run. The run gets read and write access to exactly this dataset. `outputDatasetId` is read as the same field."
          },
          "maxRows": {
            "title": "Read at most this many rows",
            "minimum": 1,
            "type": "integer",
            "description": "Stops reading after this many input rows, counted over all sources in order — for a small trial on a large dataset. Empty = all rows. `limit` and `maxItems` are read as the same field."
          },
          "outputDatasetId": {
            "title": "Output dataset (other name of `outputDataset`)",
            "type": "string",
            "description": "The same as `outputDataset`, under the name other merge tools use. Hidden in the form."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}