{
  "openapi": "3.0.1",
  "info": {
    "title": "ESMA MiFID Firm Permissions & Passporting Monitor",
    "description": "Monitor EU/EEA MiFID investment firms for authorisation, investment-service permissions, passporting and ESMA sanction changes from the official registers. First run stores a baseline; later runs emit typed alerts.",
    "version": "0.1",
    "x-build-id": "NQpOe9CZOztG1Tonb"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/automa-flow~esma-mifid-permissions-monitor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-automa-flow-esma-mifid-permissions-monitor",
        "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/automa-flow~esma-mifid-permissions-monitor/runs": {
      "post": {
        "operationId": "runs-sync-automa-flow-esma-mifid-permissions-monitor",
        "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/automa-flow~esma-mifid-permissions-monitor/run-sync": {
      "post": {
        "operationId": "run-sync-automa-flow-esma-mifid-permissions-monitor",
        "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",
        "required": [
          "firms"
        ],
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "watchlist",
              "lookup"
            ],
            "type": "string",
            "description": "watchlist compares each firm with last successful state. lookup returns the current snapshot only and does not write monitor state.",
            "default": "watchlist"
          },
          "monitorKey": {
            "title": "Monitor key",
            "pattern": "^[A-Za-z0-9_-]{1,80}$",
            "minLength": 1,
            "maxLength": 80,
            "type": "string",
            "description": "Use one key per watchlist. The same key compares against its last verified state. lookup ignores stored state.",
            "default": "default"
          },
          "firms": {
            "title": "Firms",
            "minItems": 1,
            "maxItems": 500,
            "type": "array",
            "description": "Up to 500 firms. Resolve in this order: entityId (ae42 or 42), exact LEI, then exact name plus homeMemberState. Duplicate identifiers are fetched once. Ambiguous names are returned, not guessed.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "entityId": {
                  "title": "ESMA entity id",
                  "type": "string",
                  "editor": "textfield",
                  "description": "Stable ESMA id such as ae42 or 42."
                },
                "lei": {
                  "title": "LEI",
                  "type": "string",
                  "editor": "textfield",
                  "description": "20-character ISO 17442 LEI. If it matches a head office and its branches, the head office is watched and branches are attached."
                },
                "name": {
                  "title": "Entity name",
                  "type": "string",
                  "editor": "textfield",
                  "description": "Exact ESMA entity name. Requires homeMemberState. Not used when entityId or lei is set."
                },
                "homeMemberState": {
                  "title": "Home member state",
                  "type": "string",
                  "editor": "textfield",
                  "description": "Required with name. Example: LIECHTENSTEIN."
                }
              }
            }
          },
          "includePermissions": {
            "title": "Include current permissions and activity history",
            "type": "boolean",
            "description": "Current MiFID services and activity history from ESMA. Keep this stable for a monitor key so missing dimensions are not treated as withdrawals.",
            "default": true
          },
          "includePassporting": {
            "title": "Include passporting and branches",
            "type": "boolean",
            "description": "Related MiFID branch records associated by exact LEI or head-office LEI. Freedom-of-services child documents are included only when ESMA attaches them to the watched entity.",
            "default": true
          },
          "includeSanctions": {
            "title": "Include ESMA sanctions",
            "type": "boolean",
            "description": "Sanctions register rows bound by sn_entityEsmaID to the watched firm's ae_dbId. Decision text is omitted.",
            "default": true
          },
          "changesOnly": {
            "title": "Changes only",
            "type": "boolean",
            "description": "When true, later watchlist runs emit baselines, changes and diagnostics. Unchanged firms stay in CHECKS. lookup always emits snapshots. The example keeps it off so every run shows the current record.",
            "default": true
          },
          "baselineMode": {
            "title": "Baseline mode",
            "enum": [
              "emitSnapshot",
              "storeOnly"
            ],
            "type": "string",
            "description": "emitSnapshot returns each firm's first verified observation, including the Console prefill. storeOnly saves that baseline without Dataset rows.",
            "default": "emitSnapshot"
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}