{
  "openapi": "3.0.1",
  "info": {
    "title": "AI CLINIC — Memory Cleaning",
    "description": "Non-destructive memory diagnosis for AI agents. Finds duplicate, contradictory, stale, and unconfirmed memories and returns owner-review suggestions.",
    "version": "0.2",
    "x-build-id": "VetcVkK4wbsRl5nbS"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/jp-public-data~ai-clinic-memory-cleaning/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-jp-public-data-ai-clinic-memory-cleaning",
        "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/jp-public-data~ai-clinic-memory-cleaning/runs": {
      "post": {
        "operationId": "runs-sync-jp-public-data-ai-clinic-memory-cleaning",
        "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/jp-public-data~ai-clinic-memory-cleaning/run-sync": {
      "post": {
        "operationId": "run-sync-jp-public-data-ai-clinic-memory-cleaning",
        "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": [
          "owner_authorized",
          "memories"
        ],
        "properties": {
          "schema_version": {
            "title": "Schema version",
            "type": "string",
            "description": "AI CLINIC request schema version.",
            "default": "1.0"
          },
          "request_id": {
            "title": "Request ID",
            "minLength": 1,
            "maxLength": 200,
            "type": "string",
            "description": "Optional caller-supplied correlation ID. Memory content must not be placed in this field."
          },
          "owner_authorized": {
            "title": "Owner authorization confirmed",
            "type": "boolean",
            "description": "Must be true. Confirms that the memory owner authorized this advisory diagnosis. Runtime validation rejects false."
          },
          "memories": {
            "title": "Memory records",
            "minItems": 1,
            "maxItems": 10000,
            "type": "array",
            "description": "JSON array of 1–10,000 memory records. Each record requires id and content. Optional structured contradiction fields scope, key, and value accept JSON scalar values. Protected memories remain review-only.",
            "items": {
              "type": "object",
              "required": [
                "id",
                "content"
              ],
              "additionalProperties": true,
              "properties": {
                "id": {
                  "title": "Memory ID",
                  "description": "Unique memory identifier.",
                  "type": "string",
                  "minLength": 1
                },
                "content": {
                  "title": "Memory content",
                  "description": "Memory text to diagnose.",
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 20000
                },
                "scope": {
                  "title": "Scope",
                  "description": "Optional namespace used for structured contradiction detection.",
                  "type": "string"
                },
                "created_at": {
                  "title": "Created at",
                  "description": "Optional ISO 8601 timestamp.",
                  "type": "string"
                },
                "updated_at": {
                  "title": "Updated at",
                  "description": "Optional ISO 8601 timestamp.",
                  "type": "string"
                },
                "last_confirmed_at": {
                  "title": "Last confirmed at",
                  "description": "Optional ISO 8601 owner-confirmation timestamp.",
                  "type": "string"
                },
                "observed_at": {
                  "title": "Observed at",
                  "description": "Optional ISO 8601 observation timestamp.",
                  "type": "string"
                },
                "valid_from": {
                  "title": "Valid from",
                  "description": "Optional ISO 8601 validity start. A later value alone does not supersede another memory.",
                  "type": "string"
                },
                "valid_to": {
                  "title": "Valid to",
                  "description": "Optional explicit ISO 8601 validity end.",
                  "type": "string"
                },
                "language": {
                  "title": "Language",
                  "description": "Optional BCP 47 language tag such as en or ja.",
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 35
                },
                "source": {
                  "title": "Source",
                  "description": "Optional source label. Do not place credentials here.",
                  "type": "string"
                },
                "tags": {
                  "title": "Tags",
                  "description": "Optional memory tags.",
                  "type": "array",
                  "editor": "stringList",
                  "items": {
                    "type": "string"
                  }
                },
                "importance": {
                  "title": "Importance",
                  "description": "Optional importance score from 0 to 1.",
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "protected": {
                  "title": "Protected memory",
                  "description": "Protected memories never receive an automatic primary/replacement choice.",
                  "type": "boolean"
                },
                "context": {
                  "title": "Context",
                  "description": "Optional flat JSON object whose values are string, number, boolean, or null.",
                  "type": "object",
                  "editor": "json"
                },
                "metadata": {
                  "title": "Metadata",
                  "description": "Optional caller metadata. Avoid personal data and secrets.",
                  "type": "object",
                  "editor": "json"
                }
              }
            }
          },
          "options": {
            "title": "Diagnosis options",
            "type": "object",
            "description": "Optional deterministic analysis controls. Defaults are applied by the existing AI CLINIC engine.",
            "properties": {
              "stale_after_days": {
                "title": "Stale after days",
                "description": "Age after which an unconfirmed memory is flagged for review.",
                "type": "integer",
                "minimum": 1,
                "maximum": 3650
              },
              "near_duplicate_threshold": {
                "title": "Near-duplicate threshold",
                "description": "Similarity threshold from 0.5 to 1.",
                "type": "number",
                "minimum": 0.5,
                "maximum": 1
              },
              "include_unstructured_contradictions": {
                "title": "Include unstructured contradictions",
                "description": "Enable deterministic English/Japanese opposite-polarity candidate detection.",
                "type": "boolean"
              },
              "reference_time": {
                "title": "Reference time",
                "description": "Optional ISO 8601 time used for staleness checks.",
                "type": "string"
              },
              "language": {
                "title": "Preferred language",
                "description": "Optional caller language preference. Use auto for mixed data.",
                "type": "string"
              },
              "max_candidate_pairs": {
                "title": "Maximum candidate pairs",
                "description": "Bound on pair generation. If reached, status is partial and coverage reports the unchecked scope.",
                "type": "integer",
                "minimum": 1,
                "maximum": 10000000
              }
            },
            "additionalProperties": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}