Skip to main content
Question

500 Internal Server Error: RevenueCat Entitlement Grant after Gift Code Validation and Bad Request

  • September 26, 2025
  • 1 reply
  • 30 views

Forum|alt.badge.img

 

  • We are implementing a gift code redemption feature for our app, integrating with Airtable for code validation and RevenueCat for entitlement management. The backend is built with Strapi (Node.js), and the app is Kotlin Multiplatform (Android & ios). We have two plans monthly and annual.
  •  
  • **The Flow:**
  • 1. User redeems a gift code in the app
  • 2. App calls our backend `/api/grant-entitlement` endpoint
  • 3. Backend validates the code in Airtable
  • 4. Backend attempts to grant an entitlement via RevenueCat API
  •  
  • **The Problem:**
  • We are consistently encountering a **500 Internal Server Error** from our backend (`dev-api.myatlas-health.com/api/grant-entitlement`) when it tries to call the RevenueCat API.
  •  
  • **Debugging Steps Taken:**
  • 1. ✅ Initially attempted to use RevenueCat v2 grant endpoint with `expires_at`
  • 2. ❌ Discovered that RevenueCat does not have a v2 grant endpoint (404 error)
  • 3. ✅ Switched to RevenueCat v1 promotional endpoint: `/v1/subscribers/{userId}/entitlements/{entitlementId}/promotional`
  • 4. ❌ Found that v1 promotional endpoint doesn't accept `expires_at`, requires `duration` parameter
  • 5. ✅ Updated backend to use v1 promotional endpoint with `duration` parameter
  • 6. ✅ Confirmed via direct `curl` to `api.revenuecat.com` that the v1 promotional endpoint with `duration` is correct (received "Invalid API Key" instead of 404/illegal parameters)
  • 7. ✅ Identified and fixed Strapi permissions issue - enabled `grantEntitlement` permissions for 'Public' role
  • 8. ✅ Backend has been deployed multiple times after each fix
  •  
  • **Current Status:**
  • Despite these changes, our `dev-api.myatlas-health.com/api/grant-entitlement` endpoint still returns a 500 Internal Server Error.
  •  
  • **Backend Code (Current):**
  • ```javascript
  • // RevenueCat v1 promotional endpoint
  • const revenueCatUrl = `https://api.revenuecat.com/v1/subscribers/${userId}/entitlements/${encodedEntitlementId}/promotional`;
  •  
  • const response = await axios.post(revenueCatUrl,
  • { duration: duration }, // "monthly" or "yearly"
  • {
  • headers: {
  • Authorization: `Bearer ${appConfig.revenueCatApiToken}`,
  • 'Content-Type': 'application/json',
  • },
  • }
  • );
  • ```
  •  
  • **What We Need Help With:**
  • - Why is our deployed Strapi backend still failing with a 500 error when calling RevenueCat v1 promotional API?
  • - Could this be related to environment variables (RevenueCat API key configuration)?
  • - Are there additional Strapi configuration requirements we're missing?
  • - Is there an unhandled exception in our backend logic that we should catch?
  •  
  • **Environment:**
  • - Strapi v4.14.4 (Node.js)
  • - RevenueCat API v1 promotional endpoint
  • - AWS-hosted backend
  • - Gift codes validated via Airtable integration
  •  
  • Any guidance on debugging this 500 error would be greatly appreciated!
  • ```
This post has been closed for comments

1 reply

chris_perriam
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • September 26, 2025

Hi ​@nita-akoh-792301, thanks for reaching out! This appears to be a duplicate of the question here: 

Let’s keep the discussion on the existing thread