Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

feat(billing): skip credit checks for organization teams (#2674)

firecrawl-spring[bot]26298c520312
diff --git a/apps/api/src/services/billing/credit_billing.ts b/apps/api/src/services/billing/credit_billing.ts
index 588d28b81..3c6b66a5c 100644
--- a/apps/api/src/services/billing/credit_billing.ts
+++ b/apps/api/src/services/billing/credit_billing.ts
@@ -78,6 +78,38 @@ async function supaCheckTeamCredits(
throw new Error("NULL ACUC passed to supaCheckTeamCredits");
}
+ // If team is part of an organization, skip credit checks
+ try {
+ const orgCacheKey = `team_org_${team_id}`;
+ let isPartOfOrganization = false;
+ const cachedOrgData = await getValue(orgCacheKey);
+ if (cachedOrgData !== null) {
+ isPartOfOrganization = cachedOrgData === "true";
+ } else {
+ const { data: orgData } = await supabase_rr_service
+ .from("organizations")
+ .select("id")
+ .eq("team_id", team_id)
+ .limit(1)
+ .single();
+
+ isPartOfOrganization = !!orgData;
+ await setValue(orgCacheKey, isPartOfOrganization ? "true" : "false", 300); // Cache for 5 minutes
+ }
+
+ if (isPartOfOrganization) {
+ return {
+ success: true,
+ message: "Credit checks skipped for organization team",
+ remainingCredits: Infinity,
+ chunk,
+ };
+ }
+ } catch (error) {
+ // If organization check fails, continue with normal credit checks
+ logger.warn("Organization check failed, continuing with normal credit checks", { team_id, error });
+ }
+
// If bypassCreditChecks flag is set, return success with infinite credits (infinitely graceful)
if (chunk.flags?.bypassCreditChecks) {
return {