# Merge linear issues with notion database tasks

> Linear issues and Notion database rows returned as one timeline JSON. For "merge linear issues with notion database tasks", store LINEAR_API_KEY, NOTION_API_KEY in Secret Vault, call https://api.linear.app/graphql from a Worker, and let Frontend / Web hit only https://realcomposer.com/v1/workspace/merge-linear-with-notion-tasks with an rc_live_ client token. POST upstream calls are not stored in caches.default; clients must send JSON bodies and headers forward unchanged.

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

## Problem: Waterfall latency from multiple Linear and Notion requests

Frontend / Web widgets often await Linear and Notion sequentially, multiplying TLS handshakes on cellular networks and amplifying failure rates.

- Race conditions between parallel manual fetches
- Higher mobile data usage from redundant JSON
- Timeouts when any upstream exceeds cellular RTT

## Solution steps

1. **Bind vault keys to the Worker**: Add LINEAR_API_KEY, NOTION_API_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Set headers, mapping, and cache TTL**: Configure headersTemplate to inject vault secrets, target https://api.linear.app/graphql, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Call from Frontend / Web**: Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.

```
const res = await fetch('https://realcomposer.com/v1/workspace/merge-linear-with-notion-tasks', {
  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 linear issues with notion database tasks",
  "method": "POST",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "linear",
      "upstreamUrlTemplate": "https://api.linear.app/graphql",
      "httpMethod": "POST",
      "headersTemplate": {
        "Authorization": "{{secrets.LINEAR_API_KEY}}",
        "Content-Type": "application/json"
      },
      "timeoutMs": 10000
    },
    {
      "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": "linear.issueId",
        "sourcePath": "data.issue.id",
        "type": "string",
        "sourceStep": "linear"
      },
      {
        "targetPath": "linear.title",
        "sourcePath": "data.issue.title",
        "type": "string",
        "sourceStep": "linear"
      },
      {
        "targetPath": "notion.pageId",
        "sourcePath": "results.0.id",
        "type": "string",
        "sourceStep": "notion"
      },
      {
        "targetPath": "notion.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-linear-with-notion-tasks" \
  -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-li",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "merge-linear-with-notion-tasks"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "linear_issueId": "sample",
  "linear_title": "sample",
  "notion_pageId": "sample",
  "notion_title": "sample"
}
```

## FAQ

### Does Frontend / Web need CORS changes after adding RealComposer?

Yes for merge-linear-with-notion-tasks. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects LINEAR_API_KEY on https://api.linear.app/graphql.

### What cache key does RealComposer use?

merge-linear-with-notion-tasks forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.

### Can I restrict which domains call this pipeline?

Rotate vault secrets for merge-linear-with-notion-tasks anytime; clients keep the same rc_live_ token.
