copilot/create-zip-file-again
@replit/revenuecat-sdk SDK Docs
This SDK lets you interact with RevenueCat's Developer API to take actions like creating paywalls, products, entitlements, and more
that wouldn't otherwise be possible with the client-side react-native-purchases SDK.
Usage
Creating a Client
import { createClient } from '@replit/revenuecat-sdk/client';
import { listProjects, getCustomer } from '@replit/revenuecat-sdk';
const client = createClient({
baseUrl: "https://api.revenuecat.com/v2",
headers: {
Authorization: `Bearer ${process.env.REVENUECAT_API_KEY}`,
},
});
Making Requests
Pass the client to each function:
// List all projects
const { data, error } = await listProjects({ client });
// Get a specific customer
const { data: customer } = await getCustomer({
client,
path: {
project_id: 'proj_xxx',
customer_id: 'cust_xxx',
},
});
Using Types
All request/response types are exported:
import type { Customer, Project, GetCustomerData } from '@replit/revenuecat-sdk';
Error Handling
Functions return { data, error, response }:
const { data, error } = await getCustomer({
client,
path: { project_id: 'proj_xxx', customer_id: 'cust_xxx' },
});
if (error) {
console.error('Request failed:', error);
return;
}
Use throwOnError: true to throw on non-2xx responses:
const { data } = await getCustomer({
client,
path: { project_id: 'proj_xxx', customer_id: 'cust_xxx' },
throwOnError: true,
});
Functions
Paywalls
listPaywalls(options)→ListPaywalls- Get a list of paywallscreatePaywall(options)→CreatePaywall- Create a paywalldeletePaywall(options)→DeletePaywall- Delete a paywallgetPaywall(options)→GetPaywall- Get a paywall
Apps
listAppPublicApiKeys(options)→ListAppPublicApiKeys- Get a list of the public API keys of an applistApps(options)→ListApps- Get a list of appscreateApp(options)→CreateApp- Create an appdeleteApp(options)→DeleteApp- Delete an appgetApp(options)→GetApp- Get an appupdateApp(options)→UpdateApp- Update an appgetAppStorekitConfig(options)→GetAppStorekitConfig- Get the StoreKit configuration for an app
Projects
listProjects(options)→ListProjects- Get a list of projectscreateProject(options)→CreateProject- Creates a new project
Audit logs
listAuditLogs(options)→ListAuditLogs- List audit logs
Collaborators
listCollaborators(options)→ListCollaborators- Get a list of collaborators
Customers
listCustomers(options)→ListCustomers- Get a list of customerscreateCustomer(options)→CreateCustomer- Create a customerdeleteCustomer(options)→DeleteCustomer- Delete a customergetCustomer(options)→GetCustomer- Get a customertransferCustomerData(options)→TransferCustomerData- Transfer customer's subscriptions and one-time purchases to another customergrantCustomerEntitlement(options)→GrantCustomerEntitlement- Grant an entitlement to a customerrevokeCustomerGrantedEntitlement(options)→RevokeCustomerGrantedEntitlement- Revoke a granted entitlement from a customerassignCustomerOffering(options)→AssignCustomerOffering- Assign or clear an offering override for a customerlistSubscriptions(options)→ListSubscriptions- Get a list of subscriptions associated with a customerlistPurchases(options)→ListPurchases- Get a list of purchases associated with a customerlistCustomerActiveEntitlements(options)→ListCustomerActiveEntitlements- Get a list of customer's active entitlementslistCustomerAliases(options)→ListCustomerAliases- Get a list of the customer's aliaseslistVirtualCurrenciesBalances(options)→ListVirtualCurrenciesBalances- Get a list of customer's virtual currencies balancescreateVirtualCurrenciesTransaction(options)→CreateVirtualCurrenciesTransaction- Create a virtual currencies transactionupdateVirtualCurrenciesBalance(options)→UpdateVirtualCurrenciesBalance- Update a virtual currencies balance without creating a transactionlistCustomerAttributes(options)→ListCustomerAttributes- Get a list of the customer's attributessetCustomerAttributes(options)→SetCustomerAttributes- Set a customer's attributeslistCustomerInvoices(options)→ListCustomerInvoices- Get a list of the customer's invoicesgetInvoice(options)→unknown- Get an invoice
Integrations
listWebhookIntegrations(options)→ListWebhookIntegrations- List webhook integrationscreateWebhookIntegration(options)→CreateWebhookIntegration- Create a webhook integrationdeleteWebhookIntegration(options)→DeleteWebhookIntegration- Delete a webhook integrationgetWebhookIntegration(options)→GetWebhookIntegration- Get a webhook integrationupdateWebhookIntegration(options)→UpdateWebhookIntegration- Update a webhook integration
Products
deleteProduct(options)→DeleteProduct- Delete a productgetProduct(options)→GetProduct- Get a productupdateProduct(options)→UpdateProduct- Update a productarchiveProduct(options)→ArchiveProduct- Archive a productunarchiveProduct(options)→UnarchiveProduct- Unarchive a productcreateProductInStore(options)→CreateProductInStore- Push a product to the storelistProducts(options)→ListProducts- Get a list of productscreateProduct(options)→CreateProduct- Create a productgetProductStoreState(options)→GetProductStoreState- Get a product store statesetProductStoreState(options)→SetProductStoreState- Set a product store stategetProductStoreStateOperation(options)→GetProductStoreStateOperation- Get a product store state operationuploadProductStoreStateScreenshot(options)→UploadProductStoreStateScreenshot- Reserve a product store state screenshot upload
Virtual currencies
listVirtualCurrencies(options)→ListVirtualCurrencies- Get a list of virtual currenciescreateVirtualCurrency(options)→CreateVirtualCurrency- Create a virtual currencydeleteVirtualCurrency(options)→DeleteVirtualCurrency- Delete a virtual currencygetVirtualCurrency(options)→GetVirtualCurrency- Get a virtual currencyupdateVirtualCurrency(options)→UpdateVirtualCurrency- Update a virtual currencyarchiveVirtualCurrency(options)→ArchiveVirtualCurrency- Archive a virtual currencyunarchiveVirtualCurrency(options)→UnarchiveVirtualCurrency- Unarchive a virtual currency
Entitlements
deleteEntitlement(options)→DeleteEntitlement- Delete an entitlementgetEntitlement(options)→GetEntitlement- Get an entitlementupdateEntitlement(options)→UpdateEntitlement- Update an entitlementlistEntitlements(options)→ListEntitlements- Get a list of entitlementscreateEntitlement(options)→CreateEntitlement- Create an entitlementgetProductsFromEntitlement(options)→GetProductsFromEntitlement- Get a list of products attached to a given entitlementarchiveEntitlement(options)→ArchiveEntitlement- Archive an entitlementunarchiveEntitlement(options)→UnarchiveEntitlement- Unarchive an entitlementattachProductsToEntitlement(options)→AttachProductsToEntitlement- Attach a set of products to an entitlementdetachProductsFromEntitlement(options)→DetachProductsFromEntitlement- Detach a set of product from an entitlement
Offerings
deleteOffering(options)→DeleteOffering- Delete an offering and its attached packagesgetOffering(options)→GetOffering- Get an offeringupdateOffering(options)→UpdateOffering- Update an offeringarchiveOffering(options)→ArchiveOffering- Archive an offeringunarchiveOffering(options)→UnarchiveOffering- Unarchive an offeringlistOfferings(options)→ListOfferings- Get a list of offeringscreateOffering(options)→CreateOffering- Create an offeringlistPackages(options)→ListPackages- Get a list of packages in an offeringcreatePackages(options)→CreatePackages- Create a package
Packages
deletePackageFromOffering(options)→DeletePackageFromOffering- Delete a packagegetPackage(options)→GetPackage- Get a packageupdatePackage(options)→UpdatePackage- Update a packagegetProductsFromPackage(options)→GetProductsFromPackage- Get a list of products attached to a given package of an offeringattachProductsToPackage(options)→AttachProductsToPackage- Attach a set of products to a packagedetachProductsFromPackage(options)→DetachProductsFromPackage- Detach a set of products from a package
Subscriptions
getSubscription(options)→GetSubscription- Get a subscriptiongetPlayStoreOrAppStoreSubscriptionTransactions(options)→GetPlayStoreOrAppStoreSubscriptionTransactions- Get a Play Store or App Store subscription's transactionsrefundPlayStoreSubscriptionTransaction(options)→RefundPlayStoreSubscriptionTransaction- Refund a Play Store subscription's transactionlistSubscriptionEntitlements(options)→ListSubscriptionEntitlements- Get a list of entitlements associated with a subscriptioncancelSubscription(options)→CancelSubscription- Cancel an active Web Billing subscriptionrefundSubscription(options)→RefundSubscription- Refund an active Web Billing subscriptiongetAuthorizedSubscriptionManagementUrl(options)→GetAuthorizedSubscriptionManagementUrl- Get an authenticated Web Billing customer portal URLsearchSubscriptions(options)→SearchSubscriptions- Search subscriptions by store subscription identifier
Purchases
getPurchase(options)→GetPurchase- Get a purchaselistPurchaseEntitlements(options)→ListPurchaseEntitlements- Get a list of entitlements associated with a purchaserefundPurchase(options)→RefundPurchase- Refund a Web Billing purchasesearchPurchases(options)→SearchPurchases- Search one-time purchases by store purchase identifier
Metrics
getOverviewMetrics(options)→GetOverviewMetrics- Get overview metrics for a project
Charts
getChartData(options)→GetChartData- Get chart datagetChartOptions(options)→GetChartOptions- Get available options for a chart
Undocumented Endpoints
The RevenueCat API has endpoints that are not implemented in this SDK.
They can be accessed directly using the client's HTTP methods (get, post, etc.).
Add Price to Test Store Product
POST /projects/{project_id}/products/{product_id}/test_store_prices
Request Body:
{
"prices": [
{ "amount_micros": 9990000, "currency": "USD" },
{ "amount_micros": 8990000, "currency": "EUR" }
]
}
Usage:
const { data } = await client.post({
url: '/projects/{project_id}/products/{product_id}/test_store_prices',
path: { project_id, product_id },
body: {
prices: [
{ amount_micros: 9990000, currency: 'USD' },
{ amount_micros: 8990000, currency: 'EUR' },
],
},
});
List Test Store Product Prices
GET /projects/{project_id}/products/{product_id}/test_store_prices
Usage:
const { data } = await client.get({
url: '/projects/{project_id}/products/{product_id}/test_store_prices',
path: { project_id, product_id },
});
Response:
[
{ "amount": 599, "amount_micros": 5990000, "currency": "USD" },
{ "amount": 549, "amount_micros": 5490000, "currency": "EUR" }
]