# Stripe API Response Too Large: How to Trim JSON Fields for Mobile Apps

> Stripes Customer and Invoice objects return 50+ properties and thousands of bytes when mobile screens only need 3 or 4 fields. RealComposer declarative Payload Slimmer projects only the exact fields your app needs at the edge, cutting payload size by up to 94% and speeding up client parse times.

- Canonical page: https://realcomposer.com/recipes/trim-stripe-json-for-mobile-apps
- Client platform: Flutter / React Native / Swift
- Upstream services: Stripe
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/trim-stripe-json-for-mobile-apps.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=trim-stripe-json-for-mobile-apps&via=agent

## Problem: Mobile JSON Serialization Bottlenecks

Parsing megabytes of unneeded JSON keys burns mobile battery, consumes user cellular data, and causes UI stutter on low-end mobile devices.

- High mobile memory consumption and UI jank
- Wasted cellular bandwidth for end users
- Slow app startup times

## Solution steps

1. **Connect Upstream Endpoint**: Point to Stripe customer or invoice endpoint.

2. **Pick Fields with Tree Picker**: Check only id, email, name, and balance.

3. **Receive Slimmed JSON**: Mobile app downloads 200 bytes instead of 4KB.

## 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": "Stripe Payload Slimmer",
  "method": "GET",
  "cacheTtlSeconds": 300,
  "steps": [
    {
      "stepKey": "stripe",
      "upstreamUrlTemplate": "https://api.stripe.com/v1/customers/{{query.id}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.STRIPE_SECRET_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "id",
        "sourceStep": "stripe",
        "sourcePath": "id"
      },
      {
        "targetPath": "email",
        "sourceStep": "stripe",
        "sourcePath": "email"
      },
      {
        "targetPath": "name",
        "sourceStep": "stripe",
        "sourcePath": "name"
      },
      {
        "targetPath": "balance",
        "sourceStep": "stripe",
        "sourcePath": "balance",
        "type": "number"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/acme/slim-customer?id=cus_123"
```

## Payload before and after

Raw upstream response:

```json
{
  "id": "cus_123",
  "object": "customer",
  "balance": 0,
  "created": 1680000000,
  "currency": "usd",
  "email": "user@example.com",
  "name": "John Doe",
  "invoice_prefix": "ABC",
  "delinquent": false,
  "livemode": true,
  "metadata": {},
  "tax_exempt": "none",
  "preferred_locales": [
    "en-US"
  ]
}
```

Slimmed RealComposer response:

```json
{
  "id": "cus_123",
  "email": "user@example.com",
  "name": "John Doe",
  "balance": 0
}
```

## FAQ

### How much bandwidth can this save?

RealComposer typically cuts 85% to 94% of raw Stripe payload bytes.
