

# **WORKFORCEOS**

**FRONTEND GUIDE FOR AI CODING AGENTS - PART 15 - SubscriptionManagement Service**

This document is a part of a REST API guide for the workforceos project.
It is designed for AI agents that will generate frontend code to consume the project’s backend.

This document provides extensive instruction for the usage of subscriptionManagement

## Service Access

SubscriptionManagement service management is handled through service specific base urls.

SubscriptionManagement  service may be deployed to the preview server, staging server, or production server. Therefore,it has 3 access URLs.
The frontend application must support all deployment environments during development, and the user should be able to select the target API server on the login page (already handled in first part.).

For the subscriptionManagement service, the base URLs are:

* **Preview:** `https://workforceos.prw.mindbricks.com/subscriptionmanagement-api`
* **Staging:** `https://workforceos-stage.mindbricks.co/subscriptionmanagement-api`
* **Production:** `https://workforceos.mindbricks.co/subscriptionmanagement-api`

### Tenant URL Prefix and Header Forwarding

Tenant context is resolved by frontend routing strategy:
- preview/test: URL prefix `/{tenantCodename}` (example: `/babil/products`)
- production: tenant subdomain (example: `babil.appname...`)

Then backend API calls must always claim target tenant with header:

```js
headers["mbx-company-codename"] = tenantCodenameFromUrl;
```

URL prefix/subdomain is frontend-only tenant selection. Use header forwarding for all tenant-scoped calls to `subscriptionManagement` service.

## Scope

**SubscriptionManagement Service Description**

Manages company AI subscriptions through Stripe payments. Companies must pay via Stripe to activate AI features—no manual subscription creation allowed. Handles the full Stripe payment lifecycle: checkout, payment confirmation, activation, and cancellation. The subscription status is entirely driven by Stripe webhook events. SuperAdmin/saasAdmin bypass payment for platform management.

SubscriptionManagement service provides apis and business logic for following data objects in workforceos application. 
Each data object may be either a central domain of the application data structure or a related helper data object for a central concept.
Note that data object concept is equal to table concept in the database, in the service database each data object is represented as a db table scheme and the object instances as table rows.  


**`companySubscription` Data Object**: Represents a company's active or inactive subscription record for feature gating (AI, analytics, etc.). Used to track activation/expiry, status, available features, and audit trail of renewals. 1 per company; used for entitlement checking.

**`sys_companySubscriptionPayment` Data Object**: A payment storage object to store the payment life cyle of orders based on companySubscription object. It is autocreated based on the source object's checkout config

**`sys_paymentCustomer` Data Object**: A payment storage object to store the customer values of the payment platform

**`sys_paymentMethod` Data Object**: A payment storage object to store the payment methods of the platform customers


## SubscriptionManagement Service Frontend Description By The Backend Architect

This service handles AI subscription payments. Company admins (tenantOwner/tenantAdmin) initiate a subscription via createCompanySubscription, which triggers a Stripe checkout. After payment, the subscription becomes active automatically. Users can cancel via cancelCompanySubscription. No manual status changes allowed—everything is Stripe-driven. The frontend should show a 'Subscribe to AI' button that calls create, then redirects to the Stripe checkout URL from the response. Show subscription status from getCompanySubscription. Show a 'Cancel' button that calls cancelCompanySubscription.

## API Structure

### Object Structure of a Successful Response

When the service processes requests successfully, it wraps the requested resource(s) within a JSON envelope. This envelope includes the data and essential metadata such as configuration details and pagination information, providing context to the client.

**HTTP Status Codes:**

* **200 OK**: Returned for successful GET, LIST, UPDATE, or DELETE operations, indicating that the request was processed successfully.
* **201 Created**: Returned for CREATE operations, indicating that the resource was created successfully.

**Success Response Format:**

For successful operations, the response includes a `"status": "OK"` property, signaling that the request executed successfully. The structure of a successful response is outlined below:

```json
{
  "status":"OK",
  "statusCode": 200,   
  "elapsedMs":126,
  "ssoTime":120,
  "source": "db",
  "cacheKey": "hexCode",
  "userId": "ID",
  "sessionId": "ID",
  "requestId": "ID",
  "dataName":"products",
  "method":"GET",
  "action":"list",
  "appVersion":"Version",
  "rowCount":3,
  "products":[{},{},{}],
  "paging": {
    "pageNumber":1, 
    "pageRowCount":25, 
    "totalRowCount":3,
    "pageCount":1
  },
  "filters": [],
  "uiPermissions": []
}
```
* **`products`**: In this example, this key contains the actual response content, which may be a single object or an array of objects depending on the operation.

### Additional Data

Each API may include additional data besides the main data object, depending on the business logic of the API. These will be provided in each API’s response signature.

### Error Response

If a request encounters an issue—whether due to a logical fault or a technical problem—the service responds with a standardized JSON error structure. The HTTP status code indicates the nature of the error, using commonly recognized codes for clarity:

* **400 Bad Request**: The request was improperly formatted or contained invalid parameters.
* **401 Unauthorized**: The request lacked a valid authentication token; login is required.
* **403 Forbidden**: The current token does not grant access to the requested resource.
* **404 Not Found**: The requested resource was not found on the server.
* **500 Internal Server Error**: The server encountered an unexpected condition.

Each error response is structured to provide meaningful insight into the problem, assisting in efficient diagnosis and resolution.

```js
{
  "result": "ERR",
  "status": 400,
  "message": "errMsg_organizationIdisNotAValidID",
  "errCode": 400,
  "date": "2024-03-19T12:13:54.124Z",
  "detail": "String"
}
```


## CompanySubscription Data Object

Represents a company's active or inactive subscription record for feature gating (AI, analytics, etc.). Used to track activation/expiry, status, available features, and audit trail of renewals. 1 per company; used for entitlement checking.

### CompanySubscription  Data Object Frontend Description By The Backend Architect

This represents a company's subscription status and feature access. Each company should have at most 1 active record; only admins can view or update it. The properties reflect when the subscription starts/ends, current status (active/pending/expired), feature entitlements, and audit trail (last renewed by whom). Subscription status is used by all frontend modules to determine access to AI/analytics panels. Employees cannot access this object directly; only admins see/edit (via admin views or SaaS support dashboards).


### CompanySubscription Data Object Properties

CompanySubscription data object has got following properties that are represented as table fields in the database scheme. 
These properties don't stand just for data storage, but each may have different settings to manage the business logic. 

| Property | Type | IsArray | Required | Secret | Description |
|----------|------|---------|----------|--------|-------------|
| `activationDate` | Date | false | Yes | No | Start date/time when subscription is (re)activated. |
| `expiryDate` | Date | false | Yes | No | Planned end date/time of subscription validity (inclusive). |
| `status` | Enum | false | Yes | No | Subscription status: active, inactive, pending, or expired. |
| `subscribedFeatures` | String | true | No | No | Array of enabled feature flags for this company's subscription (e.g., aiAnalytics, reporting, notifications). |
| `lastRenewedBy` | ID | false | No | No | ID of user (admin/mod) who last renewed or updated the subscription record; for audit. |
| `currency` | String | false | No | No | ISO currency code for the subscription payment. Defaults to usd. |
| `paymentStatus` | Enum | false | Yes | No | Stripe payment status: pending (awaiting payment), paid (success), failed, canceled. |
| `paymentStatusUpdatedAt` | Date | false | No | No | Timestamp of the last payment status change from Stripe. |
| `ownerId` | ID | false | Yes | No | The user who initiated the subscription purchase. Used for Stripe payment ownership. |
| `stripeSubscriptionId` | String | false | No | No | Stripe subscription ID for recurring billing management. Set after successful payment. |
| `amount` | Integer | false | Yes | No | Subscription price in cents (e.g. 4999 = $49.99). Used by Stripe payment flow. |
| `companyId` | ID | false | Yes | No | An ID value to represent the tenant id of the company |
| `paymentConfirmation` | Enum | false | Yes | No | An automatic property that is used to check the confirmed status of the payment set by webhooks. |
* Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.


### Array Properties 

`subscribedFeatures`

Array properties can hold multiple values. 
Array properties should be respected according to their multiple structure in the frontend in any user input for them.
Please use multiple input components for the array proeprties when needed.


### Enum Properties
Enum properties are defined with a set of allowed values, ensuring that only valid options can be assigned to them. 
The enum options value will be stored as strings in the database, 
but when a data object is created an additional property with the same name plus an idx suffix will be created, which will hold the index of the selected enum option.
You can use the {fieldName_idx} property to sort by the enum value or when your enum options represent a hiyerarchy of values.
In the frontend input components, enum type properties should only accept values from an option component that lists the enum options.

- **status**: [active, inactive, pending, expired]

- **paymentStatus**: [pending, paid, failed, canceled]

- **paymentConfirmation**: [pending, processing, paid, canceled]


### Relation Properties

`lastRenewedBy` `ownerId`

Mindbricks supports relations between data objects, allowing you to define how objects are linked together.
The relations may reference to a data object either in this service or in another service. Id the reference is remote, backend handles the relations through service communication or elastic search.
These relations should be respected in the frontend so that instaead of showing the related objects id, the frontend should list human readable values from other data objects.
If the relation points to another service, frontend should use the referenced service api in case it needs related data.
The relation logic is montly handled in backend so the api responses feeds the frontend about the relational data. 
In mmost cases the api response will provide the relational data as well as the main one.

In frontend, please ensure that, 

1- instaead of these relational ids you show the main human readable field of the related target data (like name),
2- if this data object needs a user input of these relational ids, you should provide a combobox with the list of possible records or (a searchbox) to select with the realted target data object main human readable field.


- **lastRenewedBy**: ID
Relation to `user`.id

The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.

Required: No

- **ownerId**: ID
Relation to `user`.id

The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.

Required: Yes


### Filter Properties

`activationDate` `expiryDate` `status` `paymentStatus` `companyId` `paymentConfirmation`

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria.
These properties are automatically mapped as API parameters in the listing API's.

- **activationDate**: Date  has a filter named `activationDate`

- **expiryDate**: Date  has a filter named `expiryDate`

- **status**: Enum  has a filter named `status`

- **paymentStatus**: Enum  has a filter named `paymentStatus`

- **companyId**: ID  has a filter named `companyId`

- **paymentConfirmation**: Enum  has a filter named `paymentConfirmation`


## Sys_companySubscriptionPayment Data Object

A payment storage object to store the payment life cyle of orders based on companySubscription object. It is autocreated based on the source object's checkout config



### Sys_companySubscriptionPayment Data Object Properties

Sys_companySubscriptionPayment data object has got following properties that are represented as table fields in the database scheme. 
These properties don't stand just for data storage, but each may have different settings to manage the business logic. 

| Property | Type | IsArray | Required | Secret | Description |
|----------|------|---------|----------|--------|-------------|
| `ownerId` | ID | false | No | No |  An ID value to represent owner user who created the order |
| `orderId` | ID | false | Yes | No | an ID value to represent the orderId which is the ID parameter of the source companySubscription object |
| `paymentId` | String | false | Yes | No | A String value to represent the paymentId which is generated on the Stripe gateway. This id may represent different objects due to the payment gateway and the chosen flow type |
| `paymentStatus` | String | false | Yes | No | A string value to represent the payment status which belongs to the lifecyle of a Stripe payment. |
| `statusLiteral` | String | false | Yes | No | A string value to represent the logical payment status which belongs to the application lifecycle itself. |
| `redirectUrl` | String | false | No | No | A string value to represent return page of the frontend to show the result of the payment, this is used when the callback is made to server not the client. |
| `companyId` | ID | false | Yes | No | An ID value to represent the tenant id of the company |
* Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.





### Filter Properties

`ownerId` `orderId` `paymentId` `paymentStatus` `statusLiteral` `redirectUrl` `companyId`

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria.
These properties are automatically mapped as API parameters in the listing API's.

- **ownerId**: ID  has a filter named `ownerId`

- **orderId**: ID  has a filter named `orderId`

- **paymentId**: String  has a filter named `paymentId`

- **paymentStatus**: String  has a filter named `paymentStatus`

- **statusLiteral**: String  has a filter named `statusLiteral`

- **redirectUrl**: String  has a filter named `redirectUrl`

- **companyId**: ID  has a filter named `companyId`


## Sys_paymentCustomer Data Object

A payment storage object to store the customer values of the payment platform



### Sys_paymentCustomer Data Object Properties

Sys_paymentCustomer data object has got following properties that are represented as table fields in the database scheme. 
These properties don't stand just for data storage, but each may have different settings to manage the business logic. 

| Property | Type | IsArray | Required | Secret | Description |
|----------|------|---------|----------|--------|-------------|
| `userId` | ID | false | No | No |  An ID value to represent the user who is created as a stripe customer |
| `customerId` | String | false | Yes | No | A string value to represent the customer id which is generated on the Stripe gateway. This id is used to represent the customer in the Stripe gateway |
| `platform` | String | false | Yes | No | A String value to represent payment platform which is used to make the payment. It is stripe as default. It will be used to distinguesh the payment gateways in the future. |
| `companyId` | ID | false | Yes | No | An ID value to represent the tenant id of the company |
* Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.





### Filter Properties

`userId` `customerId` `platform` `companyId`

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria.
These properties are automatically mapped as API parameters in the listing API's.

- **userId**: ID  has a filter named `userId`

- **customerId**: String  has a filter named `customerId`

- **platform**: String  has a filter named `platform`

- **companyId**: ID  has a filter named `companyId`


## Sys_paymentMethod Data Object

A payment storage object to store the payment methods of the platform customers



### Sys_paymentMethod Data Object Properties

Sys_paymentMethod data object has got following properties that are represented as table fields in the database scheme. 
These properties don't stand just for data storage, but each may have different settings to manage the business logic. 

| Property | Type | IsArray | Required | Secret | Description |
|----------|------|---------|----------|--------|-------------|
| `paymentMethodId` | String | false | Yes | No | A string value to represent the id of the payment method on the payment platform. |
| `userId` | ID | false | Yes | No |  An ID value to represent the user who owns the payment method |
| `customerId` | String | false | Yes | No | A string value to represent the customer id which is generated on the payment gateway. |
| `cardHolderName` | String | false | No | No | A string value to represent the name of the card holder. It can be different than the registered customer. |
| `cardHolderZip` | String | false | No | No | A string value to represent the zip code of the card holder. It is used for address verification in specific countries. |
| `platform` | String | false | Yes | No | A String value to represent payment platform which teh paymentMethod belongs. It is stripe as default. It will be used to distinguesh the payment gateways in the future. |
| `cardInfo` | Object | false | Yes | No | A Json value to store the card details of the payment method. |
| `companyId` | ID | false | Yes | No | An ID value to represent the tenant id of the company |
* Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.





### Filter Properties

`paymentMethodId` `userId` `customerId` `cardHolderName` `cardHolderZip` `platform` `cardInfo` `companyId`

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria.
These properties are automatically mapped as API parameters in the listing API's.

- **paymentMethodId**: String  has a filter named `paymentMethodId`

- **userId**: ID  has a filter named `userId`

- **customerId**: String  has a filter named `customerId`

- **cardHolderName**: String  has a filter named `cardHolderName`

- **cardHolderZip**: String  has a filter named `cardHolderZip`

- **platform**: String  has a filter named `platform`

- **cardInfo**: Object  has a filter named `cardInfo`

- **companyId**: ID  has a filter named `companyId`



## Default CRUD APIs

For each data object, the backend architect may designate **default APIs** for standard operations (create, update, delete, get, list). These are the APIs that frontend CRUD forms and AI agents should use for basic record management. If no default is explicitly set (`isDefaultApi`), the frontend generator auto-discovers the most general API for each operation.

### CompanySubscription Default APIs

| Operation | API Name | Route | Explicitly Set |
|-----------|----------|-------|----------------|
| Create | `createCompanySubscription` | `/v1/companysubscriptions` | Yes |
| Update | `updateCompanySubscription` | `/v1/companysubscriptions/:companySubscriptionId` | Yes |
| Delete | `deleteCompanySubscription` | `/v1/companysubscriptions/:companySubscriptionId` | Yes |
| Get | `getCompanySubscription` | `/v1/companysubscriptions/:companySubscriptionId` | Yes |
| List | `listCompanySubscriptions` | `/v1/companysubscriptions` | Yes |
### Sys_companySubscriptionPayment Default APIs

| Operation | API Name | Route | Explicitly Set |
|-----------|----------|-------|----------------|
| Create | `createCompanySubscriptionPayment` | `/v1/companysubscriptionpayment` | Auto |
| Update | `updateCompanySubscriptionPayment` | `/v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId` | Auto |
| Delete | `deleteCompanySubscriptionPayment` | `/v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId` | Auto |
| Get | `getCompanySubscriptionPayment` | `/v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId` | Auto |
| List | `listCompanySubscriptionPayments` | `/v1/companysubscriptionpayments` | Auto |
### Sys_paymentCustomer Default APIs

| Operation | API Name | Route | Explicitly Set |
|-----------|----------|-------|----------------|
| Create | _none_ | - | Auto |
| Update | _none_ | - | Auto |
| Delete | _none_ | - | Auto |
| Get | `getPaymentCustomerByUserId` | `/v1/paymentcustomers/:userId` | Auto |
| List | `listPaymentCustomers` | `/v1/paymentcustomers` | Auto |
### Sys_paymentMethod Default APIs

| Operation | API Name | Route | Explicitly Set |
|-----------|----------|-------|----------------|
| Create | _none_ | - | Auto |
| Update | _none_ | - | Auto |
| Delete | _none_ | - | Auto |
| Get | _none_ | - | Auto |
| List | `listPaymentCustomerMethods` | `/v1/paymentcustomermethods/:userId` | Auto |

When building CRUD forms for a data object, use the default create/update APIs listed above. The form fields should correspond to the API's body parameters. For relation fields, render a dropdown loaded from the related object's list API using the display label property.





## API Reference

### `Create Companysubscription` API
**[Default create API]** — This is the designated default `create` API for the `companySubscription` data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Initiates a new subscription purchase for the company. Creates the record in pending state and triggers the Stripe payment flow. The frontend receives a Stripe checkout URL. Once payment succeeds, the edgeFunctionPaymentDone callback automatically activates the subscription. Only tenantOwner/tenantAdmin can initiate. Prevents duplicate active/pending subscriptions.

**API Frontend Description By The Backend Architect**

Company admins use this to start their AI subscription. After calling this API, the response includes a Stripe checkout URL. Redirect the user to that URL to complete payment. Once payment succeeds, the subscription becomes active automatically. Do NOT let users set status or dates—those are system-managed.

**Rest Route**

The `createCompanySubscription` API REST controller can be triggered via the following route:

`/v1/companysubscriptions`


**Rest Request Parameters**


The `createCompanySubscription` api has got 9 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| activationDate  | Date  | true | request.body?.["activationDate"] |
| expiryDate  | Date  | true | request.body?.["expiryDate"] |
| status  | Enum  | true | request.body?.["status"] |
| subscribedFeatures  | String  | false | request.body?.["subscribedFeatures"] |
| lastRenewedBy  | ID  | false | request.body?.["lastRenewedBy"] |
| currency  | String  | false | request.body?.["currency"] |
| paymentStatusUpdatedAt  | Date  | false | request.body?.["paymentStatusUpdatedAt"] |
| ownerId  | ID  | true | request.body?.["ownerId"] |
| stripeSubscriptionId  | String  | false | request.body?.["stripeSubscriptionId"] |
**activationDate** : Start date/time when subscription is (re)activated.
**expiryDate** : Planned end date/time of subscription validity (inclusive).
**status** : Subscription status: active, inactive, pending, or expired.
**subscribedFeatures** : Array of enabled feature flags for this company's subscription (e.g., aiAnalytics, reporting, notifications).
**lastRenewedBy** : ID of user (admin/mod) who last renewed or updated the subscription record; for audit.
**currency** : ISO currency code for the subscription payment. Defaults to usd.
**paymentStatusUpdatedAt** : Timestamp of the last payment status change from Stripe.
**ownerId** : The user who initiated the subscription purchase. Used for Stripe payment ownership.
**stripeSubscriptionId** : Stripe subscription ID for recurring billing management. Set after successful payment.



**REST Request**
To access the api you can use the **REST** controller with the path **POST  /v1/companysubscriptions**
```js
  axios({
    method: 'POST',
    url: '/v1/companysubscriptions',
    data: {
            activationDate:"Date",  
            expiryDate:"Date",  
            status:"Enum",  
            subscribedFeatures:"String",  
            lastRenewedBy:"ID",  
            currency:"String",  
            paymentStatusUpdatedAt:"Date",  
            ownerId:"ID",  
            stripeSubscriptionId:"String",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "201",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "POST",
	"action": "create",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Update Companysubscription` API
**[Default update API]** — This is the designated default `update` API for the `companySubscription` data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Admin-only API for manually adjusting subscription records. Only superAdmin/saasAdmin may use. Company admins cannot manually change their subscription—all status changes are driven by Stripe payment events. Used for platform support cases only.

**API Frontend Description By The Backend Architect**

Only visible to SaaS/SuperAdmin in support dashboards. Company admins have no access. Use for manual corrections only.

**Rest Route**

The `updateCompanySubscription` API REST controller can be triggered via the following route:

`/v1/companysubscriptions/:companySubscriptionId`


**Rest Request Parameters**


The `updateCompanySubscription` api has got 8 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| companySubscriptionId  | ID  | true | request.params?.["companySubscriptionId"] |
| activationDate  | Date  | false | request.body?.["activationDate"] |
| expiryDate  | Date  | false | request.body?.["expiryDate"] |
| status  | Enum  | false | request.body?.["status"] |
| subscribedFeatures  | String  | false | request.body?.["subscribedFeatures"] |
| lastRenewedBy  | ID  | false | request.body?.["lastRenewedBy"] |
| paymentStatusUpdatedAt  | Date  | false | request.body?.["paymentStatusUpdatedAt"] |
| stripeSubscriptionId  | String  | false | request.body?.["stripeSubscriptionId"] |
**companySubscriptionId** : This id paremeter is used to select the required data object that will be updated
**activationDate** : Start date/time when subscription is (re)activated.
**expiryDate** : Planned end date/time of subscription validity (inclusive).
**status** : Subscription status: active, inactive, pending, or expired.
**subscribedFeatures** : Array of enabled feature flags for this company's subscription (e.g., aiAnalytics, reporting, notifications).
**lastRenewedBy** : ID of user (admin/mod) who last renewed or updated the subscription record; for audit.
**paymentStatusUpdatedAt** : Timestamp of the last payment status change from Stripe.
**stripeSubscriptionId** : Stripe subscription ID for recurring billing management. Set after successful payment.



**REST Request**
To access the api you can use the **REST** controller with the path **PATCH  /v1/companysubscriptions/:companySubscriptionId**
```js
  axios({
    method: 'PATCH',
    url: `/v1/companysubscriptions/${companySubscriptionId}`,
    data: {
            activationDate:"Date",  
            expiryDate:"Date",  
            status:"Enum",  
            subscribedFeatures:"String",  
            lastRenewedBy:"ID",  
            paymentStatusUpdatedAt:"Date",  
            stripeSubscriptionId:"String",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Get Companysubscription` API
**[Default get API]** — This is the designated default `get` API for the `companySubscription` data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Retrieves the subscription details for the session's company (tenantOwner/tenantAdmin/tenantUser); SaaS/SuperAdmin can fetch for any company via SaaS-level mode. Used for frontend subscription status checks and for feature gating by other services.

**API Frontend Description By The Backend Architect**

Used by company admins and by microservices/clients to inspect current subscription and its status/features. Access is allowed only to admins of own company unless SaaS/SuperAdmin.

**Rest Route**

The `getCompanySubscription` API REST controller can be triggered via the following route:

`/v1/companysubscriptions/:companySubscriptionId`


**Rest Request Parameters**


The `getCompanySubscription` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| companySubscriptionId  | ID  | true | request.params?.["companySubscriptionId"] |
**companySubscriptionId** : This id paremeter is used to query the required data object.



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/companysubscriptions/:companySubscriptionId**
```js
  axios({
    method: 'GET',
    url: `/v1/companysubscriptions/${companySubscriptionId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `List Companysubscriptions` API
**[Default list API]** — This is the designated default `list` API for the `companySubscription` data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Lists subscriptions. For admins, returns just their company's; for superAdmin/saasAdmin, returns all companies. Useful for SaaS support dashboards or analytics.

**API Frontend Description By The Backend Architect**

Only visible to company admins or SaaS support/admins. Used to render support dashboards showing subscription status across companies or for monitoring purposes. Employees do not have access.

**Rest Route**

The `listCompanySubscriptions` API REST controller can be triggered via the following route:

`/v1/companysubscriptions`


**Rest Request Parameters**



**Filter Parameters**

The `listCompanySubscriptions` api supports 5 optional filter parameters for filtering list results:

**activationDate** (`Date`): Start date/time when subscription is (re)activated.

- Single date: `?activationDate=2024-01-15`
- Multiple dates: `?activationDate=2024-01-15&activationDate=2024-01-20`
- Special: `$today`, `$ltoday`, `$week`, `$lweek`, `$month`, `$leq-<date>`, `$lin-<date>`
- Null: `?activationDate=null`


**expiryDate** (`Date`): Planned end date/time of subscription validity (inclusive).

- Single date: `?expiryDate=2024-01-15`
- Multiple dates: `?expiryDate=2024-01-15&expiryDate=2024-01-20`
- Special: `$today`, `$ltoday`, `$week`, `$lweek`, `$month`, `$leq-<date>`, `$lin-<date>`
- Null: `?expiryDate=null`


**status** (`Enum`): Subscription status: active, inactive, pending, or expired.

- Single: `?status=<value>` (case-insensitive)
- Multiple: `?status=<value1>&status=<value2>`
- Null: `?status=null`


**paymentStatus** (`Enum`): Stripe payment status: pending (awaiting payment), paid (success), failed, canceled.

- Single: `?paymentStatus=<value>` (case-insensitive)
- Multiple: `?paymentStatus=<value1>&paymentStatus=<value2>`
- Null: `?paymentStatus=null`


**paymentConfirmation** (`Enum`): An automatic property that is used to check the confirmed status of the payment set by webhooks.

- Single: `?paymentConfirmation=<value>` (case-insensitive)
- Multiple: `?paymentConfirmation=<value1>&paymentConfirmation=<value2>`
- Null: `?paymentConfirmation=null`



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/companysubscriptions**
```js
  axios({
    method: 'GET',
    url: '/v1/companysubscriptions',
    data: {
    
    },
    params: {
    
        // Filter parameters (see Filter Parameters section above)
        // activationDate: '<value>' // Filter by activationDate
        // expiryDate: '<value>' // Filter by expiryDate
        // status: '<value>' // Filter by status
        // paymentStatus: '<value>' // Filter by paymentStatus
        // paymentConfirmation: '<value>' // Filter by paymentConfirmation
            }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscriptions",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"companySubscriptions": [
		{
			"id": "ID",
			"activationDate": "Date",
			"expiryDate": "Date",
			"status": "Enum",
			"status_idx": "Integer",
			"subscribedFeatures": "String",
			"lastRenewedBy": "ID",
			"currency": "String",
			"paymentStatus": "Enum",
			"paymentStatus_idx": "Integer",
			"paymentStatusUpdatedAt": "Date",
			"ownerId": "ID",
			"stripeSubscriptionId": "String",
			"amount": "Integer",
			"companyId": "ID",
			"paymentConfirmation": "Enum",
			"paymentConfirmation_idx": "Integer",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}
```


### `Delete Companysubscription` API
**[Default delete API]** — This is the designated default `delete` API for the `companySubscription` data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Hard or soft deletes a company's subscription record. Only superAdmin/saasAdmin may use. Should only be used for manual cleanup, not normal workflows (expired/inactive should be handled by update).

**API Frontend Description By The Backend Architect**

Visible only to SaaS/SuperAdmin for data cleanup. Not normally exposed in UI; used for extreme cases or accident cleanup. Company admins cannot delete; must mark as inactive/expired by update instead.

**Rest Route**

The `deleteCompanySubscription` API REST controller can be triggered via the following route:

`/v1/companysubscriptions/:companySubscriptionId`


**Rest Request Parameters**


The `deleteCompanySubscription` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| companySubscriptionId  | ID  | true | request.params?.["companySubscriptionId"] |
**companySubscriptionId** : This id paremeter is used to select the required data object that will be deleted



**REST Request**
To access the api you can use the **REST** controller with the path **DELETE  /v1/companysubscriptions/:companySubscriptionId**
```js
  axios({
    method: 'DELETE',
    url: `/v1/companysubscriptions/${companySubscriptionId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "DELETE",
	"action": "delete",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": false,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Cancel Companysubscription` API
Cancels a company's active subscription. Calls Stripe to cancel the subscription, then updates the local record to canceled status. Only tenantOwner/tenantAdmin of the owning company or superAdmin/saasAdmin can cancel.

**API Frontend Description By The Backend Architect**

Company admins use this to cancel their AI subscription. The Stripe subscription is canceled and the local record is updated. After cancellation, AI features are immediately blocked.

**Rest Route**

The `cancelCompanySubscription` API REST controller can be triggered via the following route:

`/v1/cancelcompanysubscription/:companySubscriptionId`


**Rest Request Parameters**


The `cancelCompanySubscription` api has got 8 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| companySubscriptionId  | ID  | true | request.params?.["companySubscriptionId"] |
| activationDate  | Date  | false | request.body?.["activationDate"] |
| expiryDate  | Date  | false | request.body?.["expiryDate"] |
| status  | Enum  | false | request.body?.["status"] |
| subscribedFeatures  | String  | false | request.body?.["subscribedFeatures"] |
| lastRenewedBy  | ID  | false | request.body?.["lastRenewedBy"] |
| paymentStatusUpdatedAt  | Date  | false | request.body?.["paymentStatusUpdatedAt"] |
| stripeSubscriptionId  | String  | false | request.body?.["stripeSubscriptionId"] |
**companySubscriptionId** : This id paremeter is used to select the required data object that will be updated
**activationDate** : Start date/time when subscription is (re)activated.
**expiryDate** : Planned end date/time of subscription validity (inclusive).
**status** : Subscription status: active, inactive, pending, or expired.
**subscribedFeatures** : Array of enabled feature flags for this company's subscription (e.g., aiAnalytics, reporting, notifications).
**lastRenewedBy** : ID of user (admin/mod) who last renewed or updated the subscription record; for audit.
**paymentStatusUpdatedAt** : Timestamp of the last payment status change from Stripe.
**stripeSubscriptionId** : Stripe subscription ID for recurring billing management. Set after successful payment.



**REST Request**
To access the api you can use the **REST** controller with the path **PATCH  /v1/cancelcompanysubscription/:companySubscriptionId**
```js
  axios({
    method: 'PATCH',
    url: `/v1/cancelcompanysubscription/${companySubscriptionId}`,
    data: {
            activationDate:"Date",  
            expiryDate:"Date",  
            status:"Enum",  
            subscribedFeatures:"String",  
            lastRenewedBy:"ID",  
            paymentStatusUpdatedAt:"Date",  
            stripeSubscriptionId:"String",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Get Companysubscriptionpayment` API
This route is used to get the payment information by ID.


**Rest Route**

The `getCompanySubscriptionPayment` API REST controller can be triggered via the following route:

`/v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId`


**Rest Request Parameters**


The `getCompanySubscriptionPayment` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| sys_companySubscriptionPaymentId  | ID  | true | request.params?.["sys_companySubscriptionPaymentId"] |
**sys_companySubscriptionPaymentId** : This id paremeter is used to query the required data object.



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId**
```js
  axios({
    method: 'GET',
    url: `/v1/companysubscriptionpayment/${sys_companySubscriptionPaymentId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_companySubscriptionPayment",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"sys_companySubscriptionPayment": {
		"id": "ID",
		"ownerId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "String",
		"statusLiteral": "String",
		"redirectUrl": "String",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `List Companysubscriptionpayments` API
This route is used to list all payments.


**Rest Route**

The `listCompanySubscriptionPayments` API REST controller can be triggered via the following route:

`/v1/companysubscriptionpayments`


**Rest Request Parameters**



**Filter Parameters**

The `listCompanySubscriptionPayments` api supports 6 optional filter parameters for filtering list results:

**ownerId** (`ID`):  An ID value to represent owner user who created the order

- Single: `?ownerId=<value>`
- Multiple: `?ownerId=<value1>&ownerId=<value2>`
- Null: `?ownerId=null`


**orderId** (`ID`): an ID value to represent the orderId which is the ID parameter of the source companySubscription object

- Single: `?orderId=<value>`
- Multiple: `?orderId=<value1>&orderId=<value2>`
- Null: `?orderId=null`


**paymentId** (`String`): A String value to represent the paymentId which is generated on the Stripe gateway. This id may represent different objects due to the payment gateway and the chosen flow type

- Single (partial match, case-insensitive): `?paymentId=<value>`
- Multiple: `?paymentId=<value1>&paymentId=<value2>`
- Null: `?paymentId=null`


**paymentStatus** (`String`): A string value to represent the payment status which belongs to the lifecyle of a Stripe payment.

- Single (partial match, case-insensitive): `?paymentStatus=<value>`
- Multiple: `?paymentStatus=<value1>&paymentStatus=<value2>`
- Null: `?paymentStatus=null`


**statusLiteral** (`String`): A string value to represent the logical payment status which belongs to the application lifecycle itself.

- Single (partial match, case-insensitive): `?statusLiteral=<value>`
- Multiple: `?statusLiteral=<value1>&statusLiteral=<value2>`
- Null: `?statusLiteral=null`


**redirectUrl** (`String`): A string value to represent return page of the frontend to show the result of the payment, this is used when the callback is made to server not the client.

- Single (partial match, case-insensitive): `?redirectUrl=<value>`
- Multiple: `?redirectUrl=<value1>&redirectUrl=<value2>`
- Null: `?redirectUrl=null`



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/companysubscriptionpayments**
```js
  axios({
    method: 'GET',
    url: '/v1/companysubscriptionpayments',
    data: {
    
    },
    params: {
    
        // Filter parameters (see Filter Parameters section above)
        // ownerId: '<value>' // Filter by ownerId
        // orderId: '<value>' // Filter by orderId
        // paymentId: '<value>' // Filter by paymentId
        // paymentStatus: '<value>' // Filter by paymentStatus
        // statusLiteral: '<value>' // Filter by statusLiteral
        // redirectUrl: '<value>' // Filter by redirectUrl
            }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_companySubscriptionPayments",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"sys_companySubscriptionPayments": [
		{
			"id": "ID",
			"ownerId": "ID",
			"orderId": "ID",
			"paymentId": "String",
			"paymentStatus": "String",
			"statusLiteral": "String",
			"redirectUrl": "String",
			"companyId": "ID",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}
```


### `Create Companysubscriptionpayment` API
This route is used to create a new payment.


**Rest Route**

The `createCompanySubscriptionPayment` API REST controller can be triggered via the following route:

`/v1/companysubscriptionpayment`


**Rest Request Parameters**


The `createCompanySubscriptionPayment` api has got 4 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| orderId  | ID  | true | request.body?.["orderId"] |
| paymentId  | String  | true | request.body?.["paymentId"] |
| paymentStatus  | String  | true | request.body?.["paymentStatus"] |
| redirectUrl  | String  | false | request.body?.["redirectUrl"] |
**orderId** : an ID value to represent the orderId which is the ID parameter of the source companySubscription object
**paymentId** : A String value to represent the paymentId which is generated on the Stripe gateway. This id may represent different objects due to the payment gateway and the chosen flow type
**paymentStatus** : A string value to represent the payment status which belongs to the lifecyle of a Stripe payment.
**redirectUrl** : A string value to represent return page of the frontend to show the result of the payment, this is used when the callback is made to server not the client.



**REST Request**
To access the api you can use the **REST** controller with the path **POST  /v1/companysubscriptionpayment**
```js
  axios({
    method: 'POST',
    url: '/v1/companysubscriptionpayment',
    data: {
            orderId:"ID",  
            paymentId:"String",  
            paymentStatus:"String",  
            redirectUrl:"String",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "201",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_companySubscriptionPayment",
	"method": "POST",
	"action": "create",
	"appVersion": "Version",
	"rowCount": 1,
	"sys_companySubscriptionPayment": {
		"id": "ID",
		"ownerId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "String",
		"statusLiteral": "String",
		"redirectUrl": "String",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Update Companysubscriptionpayment` API
This route is used to update an existing payment.


**Rest Route**

The `updateCompanySubscriptionPayment` API REST controller can be triggered via the following route:

`/v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId`


**Rest Request Parameters**


The `updateCompanySubscriptionPayment` api has got 4 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| sys_companySubscriptionPaymentId  | ID  | true | request.params?.["sys_companySubscriptionPaymentId"] |
| paymentId  | String  | false | request.body?.["paymentId"] |
| paymentStatus  | String  | false | request.body?.["paymentStatus"] |
| redirectUrl  | String  | false | request.body?.["redirectUrl"] |
**sys_companySubscriptionPaymentId** : This id paremeter is used to select the required data object that will be updated
**paymentId** : A String value to represent the paymentId which is generated on the Stripe gateway. This id may represent different objects due to the payment gateway and the chosen flow type
**paymentStatus** : A string value to represent the payment status which belongs to the lifecyle of a Stripe payment.
**redirectUrl** : A string value to represent return page of the frontend to show the result of the payment, this is used when the callback is made to server not the client.



**REST Request**
To access the api you can use the **REST** controller with the path **PATCH  /v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId**
```js
  axios({
    method: 'PATCH',
    url: `/v1/companysubscriptionpayment/${sys_companySubscriptionPaymentId}`,
    data: {
            paymentId:"String",  
            paymentStatus:"String",  
            redirectUrl:"String",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_companySubscriptionPayment",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"sys_companySubscriptionPayment": {
		"id": "ID",
		"ownerId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "String",
		"statusLiteral": "String",
		"redirectUrl": "String",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Delete Companysubscriptionpayment` API
This route is used to delete a payment.


**Rest Route**

The `deleteCompanySubscriptionPayment` API REST controller can be triggered via the following route:

`/v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId`


**Rest Request Parameters**


The `deleteCompanySubscriptionPayment` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| sys_companySubscriptionPaymentId  | ID  | true | request.params?.["sys_companySubscriptionPaymentId"] |
**sys_companySubscriptionPaymentId** : This id paremeter is used to select the required data object that will be deleted



**REST Request**
To access the api you can use the **REST** controller with the path **DELETE  /v1/companysubscriptionpayment/:sys_companySubscriptionPaymentId**
```js
  axios({
    method: 'DELETE',
    url: `/v1/companysubscriptionpayment/${sys_companySubscriptionPaymentId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_companySubscriptionPayment",
	"method": "DELETE",
	"action": "delete",
	"appVersion": "Version",
	"rowCount": 1,
	"sys_companySubscriptionPayment": {
		"id": "ID",
		"ownerId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "String",
		"statusLiteral": "String",
		"redirectUrl": "String",
		"companyId": "ID",
		"isActive": false,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Get Companysubscriptionpaymentbyorderid` API
This route is used to get the payment information by order id.


**Rest Route**

The `getCompanySubscriptionPaymentByOrderId` API REST controller can be triggered via the following route:

`/v1/companySubscriptionpaymentbyorderid/:orderId`


**Rest Request Parameters**


The `getCompanySubscriptionPaymentByOrderId` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| orderId  | ID  | true | request.params?.["orderId"] |
**orderId** : an ID value to represent the orderId which is the ID parameter of the source companySubscription object. The parameter is used to query data.



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/companySubscriptionpaymentbyorderid/:orderId**
```js
  axios({
    method: 'GET',
    url: `/v1/companySubscriptionpaymentbyorderid/${orderId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_companySubscriptionPayment",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"sys_companySubscriptionPayment": {
		"id": "ID",
		"ownerId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "String",
		"statusLiteral": "String",
		"redirectUrl": "String",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Get Companysubscriptionpaymentbypaymentid` API
This route is used to get the payment information by payment id.


**Rest Route**

The `getCompanySubscriptionPaymentByPaymentId` API REST controller can be triggered via the following route:

`/v1/companySubscriptionpaymentbypaymentid/:paymentId`


**Rest Request Parameters**


The `getCompanySubscriptionPaymentByPaymentId` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| paymentId  | String  | true | request.params?.["paymentId"] |
**paymentId** : A String value to represent the paymentId which is generated on the Stripe gateway. This id may represent different objects due to the payment gateway and the chosen flow type. The parameter is used to query data.



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/companySubscriptionpaymentbypaymentid/:paymentId**
```js
  axios({
    method: 'GET',
    url: `/v1/companySubscriptionpaymentbypaymentid/${paymentId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_companySubscriptionPayment",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"sys_companySubscriptionPayment": {
		"id": "ID",
		"ownerId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "String",
		"statusLiteral": "String",
		"redirectUrl": "String",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `Start Companysubscriptionpayment` API
Start payment for companySubscription


**Rest Route**

The `startCompanySubscriptionPayment` API REST controller can be triggered via the following route:

`/v1/startcompanysubscriptionpayment/:companySubscriptionId`


**Rest Request Parameters**


The `startCompanySubscriptionPayment` api has got 2 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| companySubscriptionId  | ID  | true | request.params?.["companySubscriptionId"] |
| paymentUserParams  | Object  | true | request.body?.["paymentUserParams"] |
**companySubscriptionId** : This id paremeter is used to select the required data object that will be updated
**paymentUserParams** : The user parameters that should be defined to start a stripe payment process. Must include paymentMethodId.



**REST Request**
To access the api you can use the **REST** controller with the path **PATCH  /v1/startcompanysubscriptionpayment/:companySubscriptionId**
```js
  axios({
    method: 'PATCH',
    url: `/v1/startcompanysubscriptionpayment/${companySubscriptionId}`,
    data: {
            paymentUserParams:"Object",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	},
	"paymentResult": {
		"paymentTicketId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "Enum",
		"paymentIntentInfo": "Object",
		"statusLiteral": "String",
		"amount": "Double",
		"currency": "String",
		"success": true,
		"description": "String",
		"metadata": "Object",
		"paymentUserParams": "Object"
	}
}
```


### `Refresh Companysubscriptionpayment` API
Refresh payment info for companySubscription from Stripe


**Rest Route**

The `refreshCompanySubscriptionPayment` API REST controller can be triggered via the following route:

`/v1/refreshcompanysubscriptionpayment/:companySubscriptionId`


**Rest Request Parameters**


The `refreshCompanySubscriptionPayment` api has got 2 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| companySubscriptionId  | ID  | true | request.params?.["companySubscriptionId"] |
| paymentUserParams  | Object  | false | request.body?.["paymentUserParams"] |
**companySubscriptionId** : This id paremeter is used to select the required data object that will be updated
**paymentUserParams** : The user parameters that should be defined to refresh a stripe payment process



**REST Request**
To access the api you can use the **REST** controller with the path **PATCH  /v1/refreshcompanysubscriptionpayment/:companySubscriptionId**
```js
  axios({
    method: 'PATCH',
    url: `/v1/refreshcompanysubscriptionpayment/${companySubscriptionId}`,
    data: {
            paymentUserParams:"Object",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	},
	"paymentResult": {
		"paymentTicketId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "Enum",
		"paymentIntentInfo": "Object",
		"statusLiteral": "String",
		"amount": "Double",
		"currency": "String",
		"success": true,
		"description": "String",
		"metadata": "Object",
		"paymentUserParams": "Object"
	}
}
```


### `Callback Companysubscriptionpayment` API
Refresh payment values by gateway webhook call for companySubscription


**Rest Route**

The `callbackCompanySubscriptionPayment` API REST controller can be triggered via the following route:

`/v1/callbackcompanysubscriptionpayment`


**Rest Request Parameters**


The `callbackCompanySubscriptionPayment` api has got 2 regular request parameters  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| companySubscriptionId  | ID  | false | request.body?.["companySubscriptionId"] |
| companyId  | String  | false | request.body?.["companyId"] |
**companySubscriptionId** : The order id parameter that will be read from webhook callback params
**companyId** : The companyId parameter that will be read from webhook callback params metadata



**REST Request**
To access the api you can use the **REST** controller with the path **POST  /v1/callbackcompanysubscriptionpayment**
```js
  axios({
    method: 'POST',
    url: '/v1/callbackcompanysubscriptionpayment',
    data: {
            companySubscriptionId:"ID",  
            companyId:"String",  
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "companySubscription",
	"method": "POST",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"companySubscription": {
		"id": "ID",
		"activationDate": "Date",
		"expiryDate": "Date",
		"status": "Enum",
		"status_idx": "Integer",
		"subscribedFeatures": "String",
		"lastRenewedBy": "ID",
		"currency": "String",
		"paymentStatus": "Enum",
		"paymentStatus_idx": "Integer",
		"paymentStatusUpdatedAt": "Date",
		"ownerId": "ID",
		"stripeSubscriptionId": "String",
		"amount": "Integer",
		"companyId": "ID",
		"paymentConfirmation": "Enum",
		"paymentConfirmation_idx": "Integer",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	},
	"paymentResult": {
		"paymentTicketId": "ID",
		"orderId": "ID",
		"paymentId": "String",
		"paymentStatus": "Enum",
		"paymentIntentInfo": "Object",
		"statusLiteral": "String",
		"amount": "Double",
		"currency": "String",
		"success": true,
		"description": "String",
		"metadata": "Object",
		"paymentUserParams": "Object"
	}
}
```


### `Get Paymentcustomerbyuserid` API
This route is used to get the payment customer information by user id.


**Rest Route**

The `getPaymentCustomerByUserId` API REST controller can be triggered via the following route:

`/v1/paymentcustomers/:userId`


**Rest Request Parameters**


The `getPaymentCustomerByUserId` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| userId  | ID  | true | request.params?.["userId"] |
**userId** :  An ID value to represent the user who is created as a stripe customer. The parameter is used to query data.



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/paymentcustomers/:userId**
```js
  axios({
    method: 'GET',
    url: `/v1/paymentcustomers/${userId}`,
    data: {
    
    },
    params: {
    
        }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_paymentCustomer",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"sys_paymentCustomer": {
		"id": "ID",
		"userId": "ID",
		"customerId": "String",
		"platform": "String",
		"companyId": "ID",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}
```


### `List Paymentcustomers` API
This route is used to list all payment customers.


**Rest Route**

The `listPaymentCustomers` API REST controller can be triggered via the following route:

`/v1/paymentcustomers`


**Rest Request Parameters**



**Filter Parameters**

The `listPaymentCustomers` api supports 3 optional filter parameters for filtering list results:

**userId** (`ID`):  An ID value to represent the user who is created as a stripe customer

- Single: `?userId=<value>`
- Multiple: `?userId=<value1>&userId=<value2>`
- Null: `?userId=null`


**customerId** (`String`): A string value to represent the customer id which is generated on the Stripe gateway. This id is used to represent the customer in the Stripe gateway

- Single (partial match, case-insensitive): `?customerId=<value>`
- Multiple: `?customerId=<value1>&customerId=<value2>`
- Null: `?customerId=null`


**platform** (`String`): A String value to represent payment platform which is used to make the payment. It is stripe as default. It will be used to distinguesh the payment gateways in the future.

- Single (partial match, case-insensitive): `?platform=<value>`
- Multiple: `?platform=<value1>&platform=<value2>`
- Null: `?platform=null`



**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/paymentcustomers**
```js
  axios({
    method: 'GET',
    url: '/v1/paymentcustomers',
    data: {
    
    },
    params: {
    
        // Filter parameters (see Filter Parameters section above)
        // userId: '<value>' // Filter by userId
        // customerId: '<value>' // Filter by customerId
        // platform: '<value>' // Filter by platform
            }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_paymentCustomers",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"sys_paymentCustomers": [
		{
			"id": "ID",
			"userId": "ID",
			"customerId": "String",
			"platform": "String",
			"companyId": "ID",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}
```


### `List Paymentcustomermethods` API
This route is used to list all payment customer methods.


**Rest Route**

The `listPaymentCustomerMethods` API REST controller can be triggered via the following route:

`/v1/paymentcustomermethods/:userId`


**Rest Request Parameters**


The `listPaymentCustomerMethods` api has got 1 regular request parameter  

| Parameter              | Type                   | Required | Population                   |
| ---------------------- | ---------------------- | -------- | ---------------------------- |
| userId  | ID  | true | request.params?.["userId"] |
**userId** :  An ID value to represent the user who owns the payment method. The parameter is used to query data.


**Filter Parameters**

The `listPaymentCustomerMethods` api supports 6 optional filter parameters for filtering list results:

**paymentMethodId** (`String`): A string value to represent the id of the payment method on the payment platform.

- Single (partial match, case-insensitive): `?paymentMethodId=<value>`
- Multiple: `?paymentMethodId=<value1>&paymentMethodId=<value2>`
- Null: `?paymentMethodId=null`


**customerId** (`String`): A string value to represent the customer id which is generated on the payment gateway.

- Single (partial match, case-insensitive): `?customerId=<value>`
- Multiple: `?customerId=<value1>&customerId=<value2>`
- Null: `?customerId=null`


**cardHolderName** (`String`): A string value to represent the name of the card holder. It can be different than the registered customer.

- Single (partial match, case-insensitive): `?cardHolderName=<value>`
- Multiple: `?cardHolderName=<value1>&cardHolderName=<value2>`
- Null: `?cardHolderName=null`


**cardHolderZip** (`String`): A string value to represent the zip code of the card holder. It is used for address verification in specific countries.

- Single (partial match, case-insensitive): `?cardHolderZip=<value>`
- Multiple: `?cardHolderZip=<value1>&cardHolderZip=<value2>`
- Null: `?cardHolderZip=null`


**platform** (`String`): A String value to represent payment platform which teh paymentMethod belongs. It is stripe as default. It will be used to distinguesh the payment gateways in the future.

- Single (partial match, case-insensitive): `?platform=<value>`
- Multiple: `?platform=<value1>&platform=<value2>`
- Null: `?platform=null`


**cardInfo** (`Object`): A Json value to store the card details of the payment method.

- Single: `?cardInfo=<value>`
- Multiple: `?cardInfo=<value1>&cardInfo=<value2>`
- Null: `?cardInfo=null`


**REST Request**
To access the api you can use the **REST** controller with the path **GET  /v1/paymentcustomermethods/:userId**
```js
  axios({
    method: 'GET',
    url: `/v1/paymentcustomermethods/${userId}`,
    data: {
    
    },
    params: {
    
        // Filter parameters (see Filter Parameters section above)
        // paymentMethodId: '<value>' // Filter by paymentMethodId
        // customerId: '<value>' // Filter by customerId
        // cardHolderName: '<value>' // Filter by cardHolderName
        // cardHolderZip: '<value>' // Filter by cardHolderZip
        // platform: '<value>' // Filter by platform
        // cardInfo: '<value>' // Filter by cardInfo
            }
  });
```   
**REST Response**


```json
{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "sys_paymentMethods",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"sys_paymentMethods": [
		{
			"id": "ID",
			"paymentMethodId": "String",
			"userId": "ID",
			"customerId": "String",
			"cardHolderName": "String",
			"cardHolderZip": "String",
			"platform": "String",
			"cardInfo": "Object",
			"companyId": "ID",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}
```



**After this prompt, the user may give you new instructions to update the output of this prompt or provide subsequent prompts about the project.**


