# Paddle subscription api trim json for dashboard

> Select subscription id status and next bill date from Paddle objects. For "paddle subscription api trim json for dashboard", store PADDLE_API_KEY in Secret Vault, call https://api.paddle.com/subscriptions/{{query.subscriptionId}} from a Worker, and let React hit only https://realcomposer.com/v1/workspace/paddle-subscription-json-trim-dashboard with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/paddle-subscription-json-trim-dashboard
- Client platform: React
- Upstream services: Paddle
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/paddle-subscription-json-trim-dashboard.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=paddle-subscription-json-trim-dashboard&via=agent

## Problem: Paddle JSON bloat on React

Oversized Paddle payloads inflate parse time and mobile data charges for React users.

- Main-thread JSON parse stalls on low-end phones
- Accidentally exposing PII fields to the client
- Downstream components re-render on unused keys

## Solution steps

1. **Store upstream credentials in Secret Vault**: Create PADDLE_API_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Configure upstream steps and output mapping**: Use GET against https://api.paddle.com/subscriptions/{{query.subscriptionId}}. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache).

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

```
const res = await fetch('https://realcomposer.com/v1/workspace/paddle-subscription-json-trim-dashboard', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
const data = await res.json();
```

## 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": "Paddle subscription api trim json for dashboard",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "paddle",
      "upstreamUrlTemplate": "https://api.paddle.com/subscriptions/{{query.subscriptionId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.PADDLE_API_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "subscriptionId",
        "sourcePath": "data.id",
        "type": "string",
        "sourceStep": "paddle"
      },
      {
        "targetPath": "status",
        "sourcePath": "data.status",
        "type": "string",
        "sourceStep": "paddle"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/paddle-subscription-json-trim-dashboard" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_paddle-s",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "paddle-subscription-json-trim-dashboard"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "subscriptionId": "sample",
  "status": "sample"
}
```

## FAQ

### Does React need CORS changes after adding RealComposer?

Log request IDs for paddle-subscription-json-trim-dashboard, not raw Paddle payloads, because upstream bodies may include PII.

### What cache key does RealComposer use?

paddle-subscription-json-trim-dashboard keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.

### How do I rotate upstream credentials?

Upstream steps in paddle-subscription-json-trim-dashboard honor timeoutMs and optional fallback JSON without leaking secrets.
