# Notion Automation Toolkit (`waxlike_polecat/notion-automation-toolkit`) Actor

Automate your Notion workspace - Export, backup, migrate, and manage your Notion content at scale with 9 powerful automation tasks.

- **URL**: https://apify.com/waxlike\_polecat/notion-automation-toolkit.md
- **Developed by:** [Mohamed Ali DHIBA](https://apify.com/waxlike_polecat) (community)
- **Categories:** Automation, Agents, AI
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.10 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Notion Automation Toolkit

**Automate your Notion workspace** - Export, backup, migrate, and manage your Notion content at scale with 9 powerful automation tasks.

### 🚀 Features

#### 9 Powerful Automation Tasks

1. **📦 Export Workspace** - Export entire workspace to JSON/Markdown
2. **💾 Backup Database** - Complete database backup with all records
3. **📊 Database to CSV** - Convert databases to CSV/Excel format
4. **📝 Bulk Page Creation** - Create multiple pages from templates or data
5. **🚚 Content Migration** - Import content from external sources
6. **🔍 Search and Export** - Advanced search with bulk export
7. **🔗 Export Relations** - Map database relations and connections
8. **📈 Workspace Analytics** - Generate usage statistics and insights
9. **📋 Duplicate Pages** - Clone pages with or without children

#### Why Use This Toolkit?

- ✅ **User-Owned API Keys** - You provide your own Notion API key for full control
- ✅ **No Third-Party Access** - Your data stays secure between you and Notion
- ✅ **9 Professional Tasks** - Cover all major automation needs
- ✅ **Multiple Export Formats** - JSON, CSV, Markdown, HTML
- ✅ **Bulk Operations** - Process thousands of pages/records efficiently
- ✅ **Smart Rate Limiting** - Respects Notion API limits automatically
- ✅ **Scheduled Automation** - Set up recurring backups and exports

***

### 📖 Quick Start

#### 1. Get Your Notion API Key

1. Go to [Notion Integrations](https://www.notion.so/my-integrations)
2. Click "**+ New integration**"
3. Give it a name (e.g., "My Automation Toolkit")
4. Select the workspace to integrate with
5. Copy your **Internal Integration Token** (starts with `secret_`)

#### 2. Grant Access to Your Content

Your integration needs permission to access your pages/databases:

1. Open the page or database in Notion
2. Click **"•••"** (three dots) in the top right
3. Click **"Add connections"**
4. Select your integration

#### 3. Run the Actor

Configure your task and API key in the Apify console and run!

***

### 💡 Use Cases

#### For Individuals

- **Backup Workspace** - Regular automated backups of all content
- **Export to Markdown** - Migrate content to static site generators
- **Search and Export** - Find and extract specific pages quickly
- **Duplicate Templates** - Clone page structures for new projects

#### For Teams

- **Database Exports** - Pull reports and analytics from databases
- **Content Migration** - Move content between workspaces
- **Bulk Page Creation** - Create pages for new team members or projects
- **Workspace Analytics** - Monitor team activity and content growth

#### For Agencies

- **Client Workspace Backups** - Automated backups for multiple clients
- **Multi-Workspace Management** - Manage content across workspaces
- **Reporting** - Generate usage reports and analytics
- **Bulk Operations** - Scale operations across many workspaces

***

### 🛠️ Task Documentation

#### 1. Export Workspace

Export your entire Notion workspace to JSON or Markdown.

**Required Fields:**

- `task`: `export_workspace`
- `notionApiKey`: Your Notion API key

**Optional Fields:**

- `format`: `json` | `markdown` (default: `json`)
- `includeArchived`: Include archived pages (default: `false`)
- `includeChildren`: Include block content (default: `true`)
- `maxDepth`: Maximum nesting depth (default: `3`)

**Example Input:**

```json
{
  "task": "export_workspace",
  "notionApiKey": "secret_xxxxx",
  "format": "markdown",
  "includeArchived": false,
  "includeChildren": true
}
```

**Output:**

```json
{
  "success": true,
  "task": "export_workspace",
  "pagesExported": 156,
  "databasesExported": 12,
  "totalBlocks": 2453,
  "format": "markdown",
  "data": [...]
}
```

***

#### 2. Backup Database

Create complete backups of Notion databases with all records and properties.

**Required Fields:**

- `task`: `backup_database`
- `notionApiKey`: Your Notion API key
- `databaseId`: Database ID or URL

**Optional Fields:**

- `filters`: Notion API filter object
- `sorts`: Array of sort configurations

**Example Input:**

```json
{
  "task": "backup_database",
  "notionApiKey": "secret_xxxxx",
  "databaseId": "https://notion.so/myworkspace/abc123...",
  "filters": {
    "property": "Status",
    "select": {
      "equals": "Active"
    }
  }
}
```

**Output:**

```json
{
  "success": true,
  "task": "backup_database",
  "databaseName": "Projects Database",
  "recordsBackedUp": 234,
  "propertiesBackedUp": 15,
  "backupSize": "2.3 MB",
  "data": [...]
}
```

***

#### 3. Database to CSV

Convert Notion databases to CSV format for analysis in Excel, Google Sheets, or other tools.

**Required Fields:**

- `task`: `database_to_csv`
- `notionApiKey`: Your Notion API key
- `databaseId`: Database ID or URL

**Example Input:**

```json
{
  "task": "database_to_csv",
  "notionApiKey": "secret_xxxxx",
  "databaseId": "abc123def456"
}
```

**Output:**
CSV-formatted data with:

- Header row with property names
- Data rows with all record values
- Proper formatting for all Notion property types

***

#### 4. Bulk Page Creation

Create multiple pages at once from templates or data arrays.

**Required Fields:**

- `task`: `bulk_page_creation`
- `notionApiKey`: Your Notion API key
- `pageId` OR `databaseId`: Parent location
- `properties`: Array of page properties

**Example Input:**

```json
{
  "task": "bulk_page_creation",
  "notionApiKey": "secret_xxxxx",
  "databaseId": "abc123",
  "properties": [
    {
      "properties": {
        "Name": { "title": [{ "text": { "content": "Page 1" } }] },
        "Status": { "select": { "name": "Not Started" } }
      }
    },
    {
      "properties": {
        "Name": { "title": [{ "text": { "content": "Page 2" } }] },
        "Status": { "select": { "name": "In Progress" } }
      }
    }
  ]
}
```

***

#### 5. Content Migration

Import content from external sources into Notion databases.

**Required Fields:**

- `task`: `content_migration`
- `notionApiKey`: Your Notion API key
- `targetDatabaseId`: Destination database
- `properties`: Content to import

**Optional Fields:**

- `sourceFormat`: `markdown` | `html` | `notion` (default: `markdown`)

***

#### 6. Search and Export

Search your workspace and export matching results.

**Required Fields:**

- `task`: `search_and_export`
- `notionApiKey`: Your Notion API key
- `filters`: Must include `query` field

**Example Input:**

```json
{
  "task": "search_and_export",
  "notionApiKey": "secret_xxxxx",
  "filters": {
    "query": "project planning",
    "filter": {
      "property": "object",
      "value": "page"
    }
  },
  "format": "markdown",
  "includeChildren": true
}
```

***

#### 7. Export Relations

Map and export database relation properties and connections.

**Required Fields:**

- `task`: `export_relations`
- `notionApiKey`: Your Notion API key
- `databaseId`: Database to analyze

***

#### 8. Workspace Analytics

Generate comprehensive workspace statistics and insights.

**Required Fields:**

- `task`: `workspace_analytics`
- `notionApiKey`: Your Notion API key

**Output Includes:**

- Total pages and databases
- Active vs. archived content
- Recently modified pages
- Database property counts
- User activity metrics

***

#### 9. Duplicate Pages

Clone pages with or without their content blocks.

**Required Fields:**

- `task`: `duplicate_pages`
- `notionApiKey`: Your Notion API key
- `pageId`: Page to duplicate

**Optional Fields:**

- `includeChildren`: Copy content blocks (default: `true`)

***

### 🔐 Security & Privacy

#### Your Data is Safe

- ✅ **You Own the API Key** - You create and control your own Notion API key
- ✅ **No Third-Party Access** - Data flows only between Apify and Notion
- ✅ **Secure Storage** - API keys stored encrypted in Apify secrets
- ✅ **No Data Retention** - Actor doesn't store your Notion data
- ✅ **Transparent Code** - All source code is available for review

#### Best Practices

1. **Use Integration-Specific Keys** - Create dedicated integrations for automation
2. **Grant Minimal Access** - Only share pages/databases that need automation
3. **Rotate Keys Regularly** - Regenerate API keys periodically
4. **Monitor Activity** - Check Notion audit logs for integration activity
5. **Test with Dry Run** - Use `dryRun: true` to preview changes

***

### 📊 Pricing

Pay only for what you use:

**Apify Platform Pricing:**

- FREE tier: $5/month platform credit
- Computation: ~$0.25/hour
- Storage: $0.25/GB/month

**Typical Costs:**

- Export 1,000 pages: ~$0.10-0.30
- Backup 5 databases: ~$0.05-0.15
- Daily automated backup: ~$3-8/month

***

### 🔄 Scheduled Automation

Set up recurring tasks for automated backups and exports:

1. Go to **Schedules** in Apify Console
2. Create a new schedule
3. Set frequency (daily, weekly, monthly)
4. Configure your task input
5. Enable the schedule

**Example Schedule:**

- **Daily Database Backups** - 2:00 AM every day
- **Weekly Workspace Export** - Every Monday
- **Monthly Analytics Report** - 1st of each month

***

### 📝 Advanced Examples

#### Export All Active Projects

```json
{
  "task": "database_to_csv",
  "notionApiKey": "secret_xxxxx",
  "databaseId": "projects-db-id",
  "filters": {
    "and": [
      {
        "property": "Status",
        "select": {
          "equals": "Active"
        }
      },
      {
        "property": "Priority",
        "select": {
          "equals": "High"
        }
      }
    ]
  },
  "sorts": [
    {
      "property": "Due Date",
      "direction": "ascending"
    }
  ]
}
```

#### Create Onboarding Pages for New Team Members

```json
{
  "task": "bulk_page_creation",
  "notionApiKey": "secret_xxxxx",
  "databaseId": "team-members-db",
  "properties": [
    {
      "properties": {
        "Name": { "title": [{ "text": { "content": "Alice Smith - Onboarding" } }] },
        "Department": { "select": { "name": "Engineering" } },
        "Start Date": { "date": { "start": "2024-02-01" } }
      }
    },
    {
      "properties": {
        "Name": { "title": [{ "text": { "content": "Bob Jones - Onboarding" } }] },
        "Department": { "select": { "name": "Marketing" } },
        "Start Date": { "date": { "start": "2024-02-01" } }
      }
    }
  ]
}
```

***

### ❓ FAQ

#### Q: How do I get my Database ID?

**A:** There are two ways:

1. **From URL**: Open the database in Notion and copy the ID from the URL:
   ```
   https://notion.so/workspace/abc123def456?v=xxx
                              ^^^^^^^^^^^^
                              This is your ID
   ```

2. **Full URL**: Just paste the entire database URL - the Actor will extract the ID

#### Q: Can I use this with multiple workspaces?

**A:** Yes! Create separate integrations for each workspace and configure them individually.

#### Q: What's the rate limit?

**A:** Notion allows 3 requests/second. The Actor handles rate limiting automatically with built-in delays.

#### Q: Can I export to Google Sheets?

**A:** Yes! Use `database_to_csv` task, then use the CSV output with Google Sheets import or Zapier/Make integration.

#### Q: How large can exports be?

**A:** There's no hard limit, but very large exports (10,000+ pages) may take significant time and computation.

#### Q: Does this work with Notion AI?

**A:** This Actor exports and manages your existing Notion content. It doesn't interact with Notion AI features.

***

### 🐛 Troubleshooting

#### Error: "Invalid API key format"

**Solution:** Make sure your API key starts with `secret_` or `ntn_`

#### Error: "Object not found"

**Solutions:**

1. Verify the integration has access to the page/database
2. Click "•••" → "Add connections" → Select your integration
3. Check the database/page ID is correct

#### Error: "Rate limit exceeded"

**Solution:** The Actor has automatic rate limiting, but if you hit limits, try reducing `maxDepth` or processing fewer items at once.

#### Empty Export Results

**Solutions:**

1. Make sure `includeArchived: false` if you want active pages only
2. Check that your integration has access permissions
3. Verify filters aren't too restrictive

***

### 🤝 Support

- **Documentation**: This README
- **Issues**: Use the feedback button in Apify Console
- **Community**: Apify Discord community

***

### 📄 License

MIT License - See LICENSE file

***

### 🌟 About

Created by **Ali Dhiba** to help Notion users automate workspace management, backups, and data operations.

**Connect with the developer:**

- GitHub: \[Your GitHub]
- Twitter: \[Your Twitter]
- LinkedIn: \[Your LinkedIn]

***

### 🎯 Roadmap

Future enhancements planned:

- ✨ Template library for common automation workflows
- ✨ Direct integration with Google Drive
- ✨ Advanced analytics dashboards
- ✨ Multi-workspace batch operations
- ✨ Real-time sync capabilities

***

**Made with ❤️ for the Notion community**

# Actor input Schema

## `task` (type: `string`):

Select the automation task to perform

## `notionApiKey` (type: `string`):

Your Notion integration API key (starts with 'secret\_' or 'ntn\_'). Create one at: https://www.notion.so/my-integrations

## `databaseId` (type: `string`):

Notion database ID or full URL (required for database operations)

## `pageId` (type: `string`):

Notion page ID or full URL (required for page operations)

## `targetDatabaseId` (type: `string`):

Target database ID for migration tasks

## `format` (type: `string`):

Format for exported data

## `includeArchived` (type: `boolean`):

Include archived pages/databases in export

## `includeChildren` (type: `boolean`):

Include child blocks/pages in export

## `maxDepth` (type: `integer`):

Maximum depth for nested content (1-10)

## `filters` (type: `object`):

Notion API filters in JSON format. Example: {"property": "Status", "select": {"equals": "Done"}}

## `sorts` (type: `array`):

Notion API sorts. Example: \[{"property": "Name", "direction": "ascending"}]

## `limit` (type: `integer`):

Maximum number of records to process

## `properties` (type: `object`):

Properties for bulk operations in JSON format. For bulk page creation, provide an array of page properties.

## `sourceFormat` (type: `string`):

Source content format for migration

## `dryRun` (type: `boolean`):

Preview changes without actually executing them

## `outputTo` (type: `string`):

Where to store the results

## `webhook` (type: `string`):

HTTP endpoint to receive completion notification

## `notifyOnComplete` (type: `boolean`):

Send webhook notification when task completes

## Actor input object example

```json
{
  "task": "export_workspace",
  "format": "json",
  "includeArchived": false,
  "includeChildren": true,
  "maxDepth": 3,
  "sourceFormat": "markdown",
  "dryRun": false,
  "outputTo": "dataset",
  "notifyOnComplete": false
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("waxlike_polecat/notion-automation-toolkit").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("waxlike_polecat/notion-automation-toolkit").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call waxlike_polecat/notion-automation-toolkit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=waxlike_polecat/notion-automation-toolkit",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Lymd0tSxWU6c1iGyy/builds/Wot4DYMU1w0a12X8u/openapi.json
