Skip to main content
skill CX Codex

rc-backend — Claude Code skill for RevenueCat backends

A skill for reading and updating RevenueCat state from your server: subscribers, promotional entitlements, attributes over the REST API.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add RevenueCat/ai-toolkit --skill rc-backend -a claude-code
Open on GitHub

What rc-backend does

This skill covers what your backend actually does when Android purchases run through RevenueCat. The short version: you do not build a receipt verification server, RevenueCat already runs one. Your job is to consume and change subscriber state, not to validate Google Play purchase tokens.

It walks through the REST API: GET /v1/subscribers/{app_user_id} for current status, POST .../entitlements/{entitlement_id}/promotional to grant access, .../revoke_promotionals to take it back, POST .../attributes for server-side CRM fields. A table spells out which key belongs where: the public Android SDK key ships inside the app, the secret key lives in a server environment variable. There is also a webhook receiver outline that checks the Authorization header and answers 2xx fast, since RevenueCat retries on anything else.

Keep the secret key out of the APK, out of a BuildConfig field, out of any client bundle, and rotate it if it leaks. If your app only gates features on the client, you may not need a backend component at all.

What it helps with

  • read a subscriber's current entitlement from your server
  • grant promotional access after a support request
  • revoke a promotional entitlement
  • receive purchase and renewal webhooks
  • sort out which responsibilities stay on your backend and which RevenueCat handles

Example prompts for the agent

  • Show me how to read a RevenueCat subscriber's state from my server by app_user_id
  • Write a Ktor webhook receiver for RevenueCat with Authorization header checks
  • How do I grant a promotional entitlement through the RevenueCat REST API?

How to install rc-backend

1Skills CLI (Vercel)

npx skills add RevenueCat/ai-toolkit --skill rc-backend -a claude-code

2Manually: put the files in place

~/.claude/skills/rc-backend/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/rc-backend/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about rc-backend

How do I install rc-backend in Claude?

Run npx skills add RevenueCat/ai-toolkit --skill rc-backend -a claude-code. The skill lands in ~/.claude/skills/rc-backend/SKILL.md.

What does rc-backend do?

It tells the agent how a RevenueCat backend is put together: which REST API calls to make, how to handle webhooks, and why you should not write your own receipt verification server.

What do I need before writing backend code?

A RevenueCat project with an Android app configured, a secret API key from Project Settings, the app_user_id your SDK uses, and a decision between real-time REST API state and event-driven webhooks.

Source text

SKILL.md · MIT
---
name: rc-backend
description: Use this skill when your backend needs to read or update RevenueCat state on Android. Covers the RevenueCat REST API (v1 subscribers endpoint, grant/revoke entitlements, attributes), secret vs public SDK API key usage, and why you do not build a receipt verification backend with RevenueCat.
license: Apache-2.0; see LICENSE
metadata:
  author: RevenueCat
  source: revenuecat-handbook chapter 9
  keywords:
  - android
  - revenuecat
  - backend
  - rest-api
  - entitlement-grant
  - secret-api-key
---

# Backend Architecture with RevenueCat

You do not build a receipt verification server with RevenueCat. Your backend still has a role, but that role is consuming RevenueCat state, not validating Google Play purchase tokens.

## Phase 1: Discovery

RevenueCat's backend is the receipt verification server. When the Android SDK posts a purchase token, RevenueCat's backend:

1. Calls `purchases.subscriptionsv2.get` or `purchases.products.get` against the Google Play Developer API.
2. Validates the receipt is genuine and matches the expected product.
3. Records the transaction in its database.
4. Returns `CustomerInfo` to the SDK.

Your Android app never calls the Google Play Developer API. Your server does not call it either.

Before writing any backend code, confirm these facts about your deployment:

- You have a RevenueCat project with an Android app configured.
- You have a secret API key from Project Settings to API Keys (not the public Android SDK key embedded in the app).
- You know which `app_user_id` your SDK uses (the same identifier your auth system uses).
- You have decided whether the backend needs real time state (REST API) or event driven state (webhooks).

If your app only gates features inside the client, you may not need a backend component at all. RevenueCat verifies `CustomerInfo` server side before it reaches the SDK, and `EntitlementVerificationMode.INFORMATIONAL` or `.ENFORCED` adds signature verification on the client. Serve premium content from a server only when you can verify entitlement on the server.

## Phase 2: Plan

Map each backend responsibility to a RevenueCat mechanism.

| Use case | Mechanism | Notes |
|---|---|---|
| React to purchase, renewal, cancellation | Webhook receiver | RevenueCat posts normalized events; your server updates its own DB. |
| Check current entitlement for a user | `GET /v1/subscribers/{app_user_id}` | Secret API key in `Authorization` header. |
| Grant promotional access (support, refunds, comps) | `POST /v1/subscribers/{app_user_id}/entitlements/{entitlement_id}/promotional` | Server side only. |
| Revoke promotional access | `POST /v1/subscribers/{app_user_id}/entitlements/{entitlement_id}/revoke_promotionals` | Server side only. |
| Set subscriber attributes from server side data | `POST /v1/subscribers/{app_user_id}/attributes` | Useful for CRM fields the SDK does not know. |
| Bulk data export | RevenueCat data export | Scheduled exports to your warehouse. |

What your backend still owns:

- User authentication.
- Your database of users and their access levels.
- API endpoints that serve premium content.
- The webhook receiver that processes RevenueCat events.

What your backend does not own:

- Google Play Developer API credentials.
- Receipt verification code.
- `linkedPurchaseToken` chain traversal.
- Subscription state computation across the seven subscription states.

## Phase 3: Execute

### Read a subscriber

```http
GET https://api.revenuecat.com/v1/subscribers/{app_user_id}
Authorization: Bearer sk_...
X-Platform: android
```

The response body is the same `CustomerInfo` structure the Android SDK returns. Use it in a server side endpoint that gates premium API responses.

### Grant a promotional entitlement

```http
POST https://api.revenuecat.com/v1/subscribers/{app_user_id}/entitlements/{entitlement_id}/promotional
Authorization: Bearer sk_...
Content-Type: application/json

{"duration": "monthly"}
```

Valid `duration` values include `daily`, `three_day`, `weekly`, `monthly`, `two_month`, `three_month`, `six_month`, `yearly`, `lifetime`. Use this for support workflows, never from the client.

### Example: Kotlin Ktor call from your server

```kotlin
val response = client.get("https://api.revenuecat.com/v1/subscribers/$appUserId") {
    header("Authorization", "Bearer ${System.getenv("RC_SECRET_KEY")}")
    header("X-Platform", "android")
}
```

### API key rules

| Key | Where it lives | What it can do |
|---|---|---|
| Android public SDK key | Embedded in the Android app | Post purchases, fetch `CustomerInfo` for the current user. |
| Secret API key | Server environment variable only | Read any subscriber, grant or revoke promotionals, set attributes, bulk operations. |

Never ship the secret key in the Android APK, in a BuildConfig field, or in any client bundle. Rotate it if it leaks. Treat it like a database password.

### Webhook receiver outline

```kotlin
post("/revenuecat/webhook") {
    val auth = call.request.header("Authorization")
    require(auth == "Bearer ${System.getenv("RC_WEBHOOK_SECRET")}")
    val event = call.receive<RevenueCatEvent>()
    when (event.type) {
        "INITIAL_PURCHASE", "RENEWAL" -> grantAccess(event.appUserId, event.entitlements)
        "CANCELLATION", "EXPIRATION" -> scheduleRevocation(event.appUserId)
    }
    call.respond(HttpStatusCode.OK)
}
```

Verify the authorization header you configured in the RevenueCat dashboard. Respond 2xx fast; RevenueCat retries on non 2xx responses.

### What not to build

- Do not build a Google Play receipt verification endpoint. RevenueCat already did.
- Do not pass purchase tokens from the Android client to your server for manual verification. The SDK handles the round trip.
- Do not query Google Play Developer API from your backend unless you are building a custom integration that bypasses the SDK.
- Do not mirror the seven subscription state machine in your DB. Consume `CustomerInfo.entitlements.active` or webhook events instead.

## References

- [Full chapter](https://www.revenuecat.com/guides/revenuecat-android-sdk/backend-architecture)

© RevenueCat · MIT · RevenueCat/ai-toolkit

Similar skills

Everything for Backend and APIs →

From the same set25

revenuecat-customer-center Adds RevenueCat's ready-made Customer Center screen so subscribers can cancel, request refunds and restore purchases without custom UI. CX Codex +1 715installs revenuecat-migrate A skill that walks an app through adopting RevenueCat or bumping the SDK to a new major version. It detects the platform first, then follows the steps. CX Codex +1 700installs rc-webhooks A skill for handling RevenueCat webhooks server-side: the event schema, deduplication by event.id, and the difference between cancellation, expiration and renewal. CX Codex +1 650installs rc-security Walks an agent through a RevenueCat security review on Android: signature verification mode, API key hygiene, user identity and server-side entitlement checks. CX Codex +1 649installs rc-setup Walks you through the RevenueCat dashboard and the Google Play connection: app, service account, entitlements, offerings, and the public API key. CX Codex +1 638installs rc-configuring-the-sdk A skill that walks the agent through wiring RevenueCat into an Android app: the Gradle dependency, Purchases.configure, app user id strategy and log level. CX Codex +1 636installs rc-catalog-management Walks through the Android product catalog across Play Console and the RevenueCat dashboard: import products, attach entitlements, wire offerings. CX Codex +1 627installs rc-subscription-states A skill for Android apps on RevenueCat that tells the agent how to gate paid features through CustomerInfo and EntitlementInfo. CX Codex +1 623installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor