Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Add endpoint for updating organization plan

Tuan Danga8502377c718
diff --git a/backend/src/ee/controllers/v1/organizationsController.ts b/backend/src/ee/controllers/v1/organizationsController.ts
index 1a19eef2df..b79379f291 100644
--- a/backend/src/ee/controllers/v1/organizationsController.ts
+++ b/backend/src/ee/controllers/v1/organizationsController.ts
@@ -36,6 +36,27 @@ export const getOrganizationPlan = async (req: Request, res: Response) => {
});
}
+/**
+ * Update the organization plan to product with id [productId]
+ * @param req
+ * @param res
+ * @returns
+ */
+export const updateOrganizationPlan = async (req: Request, res: Response) => {
+ const {
+ productId
+ } = req.body;
+
+ const { data } = await licenseServerKeyRequest.patch(
+ `${await getLicenseServerUrl()}/api/license-server/v1/customers/${req.organization.customerId}/cloud-plan`,
+ {
+ productId
+ }
+ );
+
+ return res.status(200).send(data);
+}
+
/**
* Return the organization's payment methods on file
*/
diff --git a/backend/src/ee/routes/v1/organizations.ts b/backend/src/ee/routes/v1/organizations.ts
index b41e493342..fd9fd08e94 100644
--- a/backend/src/ee/routes/v1/organizations.ts
+++ b/backend/src/ee/routes/v1/organizations.ts
@@ -25,6 +25,21 @@ router.get(
organizationsController.getOrganizationPlan
);
+router.patch(
+ '/:organizationId/plan',
+ requireAuth({
+ acceptedAuthModes: ['jwt', 'apiKey']
+ }),
+ requireOrganizationAuth({
+ acceptedRoles: [OWNER, ADMIN, MEMBER],
+ acceptedStatuses: [ACCEPTED]
+ }),
+ param('organizationId').exists().trim(),
+ body('productId').exists().isString(),
+ validateRequest,
+ organizationsController.updateOrganizationPlan
+);
+
router.get(
'/:organizationId/billing-details/payment-methods',
requireAuth({