# Notion API Block Children Response Payload Slimming

> Notion responses include fields Frontend / Web never renders. Map id, status, and UI columns at the edge after calling https://api.notion.com/v1/databases/{{query.databaseId}}/query.

- Canonical page: https://realcomposer.com/recipes/slim-notion-block-children-payload
- Client platform: Frontend / Web
- Upstream services: Notion
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/slim-notion-block-children-payload.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=slim-notion-block-children-payload&via=agent

## Problem: Unmapped Notion fields waste bandwidth

Notion returns nested CRM, audit, and configuration objects. Frontend / Web parses them on the main thread even when the UI binds three fields.

- Large arrays kept in memory after navigation
- Analytics showing poor LCP on API-heavy screens
- Developers shipping defensive null checks for unused paths

## Solution steps

1. **Add vault secrets for this pipeline**: Create NOTION_API_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Configure upstream steps and output mapping**: Use POST against https://api.notion.com/v1/databases/{{query.databaseId}}/query. Allowed origins on the client token should match post pipelines set cache ttl to 0 because realcomposer only stores get responses at the edge.

3. **Call from Frontend / Web**: Allowed origins on the token should list every Frontend / Web host that calls this URL.

```
const res = await fetch('https://realcomposer.com/v1/workspace/slim-notion-block-children-payload', {
  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": "Notion API Block Children Response Payload Slimming",
  "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/slim-notion-block-children-payload" \
  -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_slim-not",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "slim-notion-block-children-payload"
  },
  "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

### Is it safe to log Notion responses in Frontend / Web?

Point Frontend / Web at /recipes/slim-notion-block-children-payload edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.

### Will Anthropic or Linear prompt bodies be rewritten?

slim-notion-block-children-payload POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.

### How do I rotate upstream credentials?

Upstream steps in slim-notion-block-children-payload honor timeoutMs and optional fallback JSON without leaking secrets.
