RealComposer
Mobile App (iOS & Android)PostHogSecurity & Secret Vault

How to Call Posthog API Securely from Mobile App

Vault-backed PostHog proxy tuned for Mobile App (iOS & Android)

Direct Answer & Architecture Summary

Never place POSTHOG_PERSONAL_API_KEY inside Mobile App (iOS & Android) source. RealComposer injects them when calling https://us.posthog.com/api/projects/{{query.projectId}}/feature_flags, so browsers see only a client token.

Security LevelAES-256-GCM Vault
Edge LatencySub-10ms Response
InfrastructureZero Server Maintenance
The Problem Solved

PostHog keys in Mobile App (iOS & Android) network tabs

Mobile App (iOS & Android) ships code or scripts to end-user devices. Any PostHog bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.

Critical Security & Operational Risks:
  • Shared Mobile App (iOS & Android) projects revealing PostHog tokens
  • Sudden PostHog quota burn from scripted abuse
  • Inability to rotate keys without redeploying clients
Architecture & Step-by-Step Implementation

How RealComposer Solves This at the Edge

1

Add vault secrets for this pipeline

Create POSTHOG_PERSONAL_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://us.posthog.com/api/projects/{{query.projectId}}/feature_flags. 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 Mobile App (iOS & Android)

Allowed origins on the token should list every Mobile App (iOS & Android) host that calls this URL.

                    let url = URL(string: "https://realcomposer.com/v1/workspace/posthog-mobile-proxy")!
var request = URLRequest(url: url)
request.addValue("Bearer rc_live_token", forHTTPHeaderField: "Authorization")
                  
Payload Slimming Comparison
84% Bandwidth Reduction
Raw Upstream Response239 B
              {
  "requestId": "req_posthog-",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "posthog-mobile-proxy"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
            
RealComposer Slimmed Edge Payload38 B
              {
  "flagKey": "sample",
  "active": "sample"
}
            

Recipe Specs

HTTP method
GET
Upstream calls
1
Edge cache TTL
No caching
Client auth
Restricted client token
Mapped output fields
2
Payload
239 B to 38 B (-84%)
Call from Terminal or Client
curl -X GET "https://realcomposer.com/v1/workspace/posthog-mobile-proxy" \
  -H "Authorization: Bearer rc_live_client_token"
Frequently Asked Questions

Developer Questions & Troubleshooting

Which PostHog credential belongs in the vault for this pipeline?

Yes for posthog-mobile-proxy. Ship only an rc_live_ client token in Mobile App (iOS & Android); RealComposer injects POSTHOG_PERSONAL_API_KEY on https://us.posthog.com/api/projects/{{query.projectId}}/feature_flags.

What cache key does RealComposer use?

posthog-mobile-proxy vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body.

How do I rotate upstream credentials?

Upstream steps in posthog-mobile-proxy honor timeoutMs and optional fallback JSON without leaking secrets.

Sources & Definitions Used in This Answer

Instant Deployment

Deploy this Mobile App (iOS & Android) + PostHog Recipe

Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.

CLONE THIS RECIPE
Related Architecture Recipes