{
  "openapi": "3.0.1",
  "info": {
    "title": "Notion AI Database Extractor & Sync Tool",
    "description": "Extract, summarize, and sync your Notion databases automatically. Supports AI summaries (GPT-4o), incremental updates, and secure HMAC webhooks. Ideal for analytics, CRM sync, or automation workflows.",
    "version": "1.3",
    "x-build-id": "ykRpqJa52IF4RLAv0"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/tuguidragos~notion-ai-database-sync/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-tuguidragos-notion-ai-database-sync",
        "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/tuguidragos~notion-ai-database-sync/runs": {
      "post": {
        "operationId": "runs-sync-tuguidragos-notion-ai-database-sync",
        "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/tuguidragos~notion-ai-database-sync/run-sync": {
      "post": {
        "operationId": "run-sync-tuguidragos-notion-ai-database-sync",
        "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": [
          "NOTION_TOKEN",
          "DATABASE_ID"
        ],
        "properties": {
          "NOTION_TOKEN": {
            "title": "Notion integration token",
            "type": "string",
            "description": "Required. Paste the internal integration token that can read the target workspace."
          },
          "DATABASE_ID": {
            "title": "Database ID",
            "type": "string",
            "description": "Required. 32-character ID from the Notion database URL (copy it without dashes)."
          },
          "PAGE_SIZE": {
            "title": "Items per batch",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Number of rows pulled per Notion API request (1–100).",
            "default": 100
          },
          "enableIncremental": {
            "title": "Incremental sync",
            "type": "boolean",
            "description": "Read only items created or edited since the last successful run.",
            "default": false
          },
          "since": {
            "title": "Custom starting point",
            "type": "string",
            "description": "ISO timestamp override for incremental sync (e.g., 2024-01-01T00:00:00.000Z)."
          },
          "maxItems": {
            "title": "Item limit",
            "minimum": 1,
            "type": "integer",
            "description": "Stop after this many rows (leave empty for no limit)."
          },
          "dryRun": {
            "title": "Dry run",
            "type": "boolean",
            "description": "Skip state persistence and webhooks while still writing the dataset.",
            "default": false
          },
          "strictMode": {
            "title": "Strict mode",
            "type": "boolean",
            "description": "Fail the entire run if AI summarization encounters an error (instead of skipping the summary).",
            "default": false
          },
          "enableAi": {
            "title": "AI summaries",
            "type": "boolean",
            "description": "Toggle OpenAI summarization for each row (language is inferred automatically).",
            "default": false
          },
          "OPENAI_API_KEY": {
            "title": "OpenAI API key",
            "type": "string",
            "description": "Needed only when AI summaries are enabled."
          },
          "aiModel": {
            "title": "Model",
            "enum": [
              "gpt-4o-mini",
              "gpt-4o"
            ],
            "type": "string",
            "description": "Choose the OpenAI model that generates the summary.",
            "default": "gpt-4o-mini"
          },
          "aiMaxTokens": {
            "title": "Max tokens",
            "minimum": 50,
            "maximum": 1000,
            "type": "integer",
            "description": "Token cap for each summary (higher = longer text).",
            "default": 256
          },
          "aiConcurrency": {
            "title": "AI concurrency",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Maximum number of parallel AI summarization requests (1-50). Higher values speed up processing but may hit rate limits.",
            "default": 5
          },
          "summarizeFields": {
            "title": "Fields to summarize",
            "uniqueItems": true,
            "type": "array",
            "description": "List the payload fields that should feed the AI prompt.",
            "items": {
              "type": "string",
              "enum": [
                "title",
                "properties"
              ],
              "enumTitles": [
                "Title property",
                "Database properties"
              ]
            },
            "default": [
              "title",
              "properties"
            ]
          },
          "aiPromptTemplate": {
            "title": "AI prompt template",
            "type": "string",
            "description": "Custom GPT instructions. Use {{CONTENT}} for Notion data (language is auto-detected).",
            "default": "Summarize this Notion item focusing on the most important updates.\n\n{{CONTENT}}"
          },
          "webhookUrl": {
            "title": "Webhook URL",
            "type": "string",
            "description": "Send a POST notification with run stats after a successful sync."
          },
          "webhookSecret": {
            "title": "Webhook secret",
            "type": "string",
            "description": "HMAC secret used to sign webhook requests."
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}