# Merge Notion Database with Google Calendar API

> To merge notion database with google calendar api, configure parallel steps for Notion. Frontend / Web performs one authorized GET/POST to RealComposer and receives a merged payload.

- Canonical page: https://realcomposer.com/recipes/merge-notion-and-google-calendar
- Client platform: Frontend / Web
- Upstream services: Notion
- Category: Multi-API Aggregation
- JSON version: https://realcomposer.com/recipes/merge-notion-and-google-calendar.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=merge-notion-and-google-calendar&via=agent

## Problem: Serial Notion calls slow Frontend / Web pages

Each extra Notion hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.

- One slow upstream blocking an entire page
- Partial failures leaving UI in inconsistent states
- Duplicate auth refresh logic per service

## Solution steps

1. **Add vault secrets for this pipeline**: Store NOTION_API_KEY in the vault. Frontend / Web never embeds the raw secret, only a revocable rc_live_ client token.

2. **Set headers, mapping, and cache TTL**: Point step notion at https://api.notion.com/v1/databases/{{query.databaseId}}/query with POST. Add output mapping fields that mirror the JSON contract your screen already expects. POST pipelines set cache TTL to 0 because RealComposer only stores GET responses at the edge.

3. **Call from Frontend / Web**: Call https://realcomposer.com/v1/workspace/merge-notion-and-google-calendar with a restricted rc_live_ client token. Frontend / Web never sends upstream secrets.

```
const res = await fetch('https://realcomposer.com/v1/workspace/merge-notion-and-google-calendar', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Merge Notion Database with Google Calendar API",
  "method": "POST",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "notion",
      "upstreamUrlTemplate": "https://api.notion.com/v1/databases/{{query.databaseId}}/query",
      "httpMethod": "POST",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.NOTION_API_KEY}}",
        "Notion-Version": "2022-06-28",
        "Content-Type": "application/json"
      },
      "timeoutMs": 10000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "pageId",
        "sourcePath": "results.0.id",
        "type": "string",
        "sourceStep": "notion"
      },
      {
        "targetPath": "title",
        "sourcePath": "results.0.properties.Name.title.0.plain_text",
        "type": "string",
        "sourceStep": "notion"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X POST "https://realcomposer.com/v1/workspace/merge-notion-and-google-calendar" \
  -H "Authorization: Bearer rc_live_client_token" \
  -H "Content-Type: application/json" \
  -d '{"model":"example"}'
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_merge-no",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "merge-notion-and-google-calendar"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "pageId": "sample",
  "title": "sample"
}
```

## FAQ

### Which Notion credential belongs in the vault for this pipeline?

Log request IDs for merge-notion-and-google-calendar, not raw Notion payloads, because upstream bodies may include PII.

### What cache key does RealComposer use?

Cache key for merge-notion-and-google-calendar: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.

### What happens if an upstream step times out?

Rotate vault secrets for merge-notion-and-google-calendar anytime; clients keep the same rc_live_ token.
