I'm building an API marketplace application. The application currently has an API catalogue page which takes me to an API details page which in turn takes me to a an API sample page that shows sample request and response.

I'm trying to bring about a subscription workflow that will let a user subscribe to an API on any of the subscription tiers supported by that API.
When a signed in user clicks the subscribe button, they should be prompted to choose one of the supported tiers. This in turn should call a token generation function(another API with the API name and subscription name)
The generated token should then be attached to the user and any time a user tries to test the API from that page, it should automatically pick up that token for the appropriate API. How to structure the tables in my database for this?

For reference my mongo collections look like this:
userdetails:
```
[{
  "_id": {
    "$oid": "66f4fa82edb13818ea8a1de4"
  },
  "user_name": "venu",
  "user_mail": "venu@yopmail.com",
  "user_mobile": 1234567890,
  "organization": "emudhra limited",
  "type": "admin",
  "password": "ecd71870d1963316a97e3ac3408c9835ad8cf0f3c1bc703527c30265534f75ae"
}]
```

apidetails:
```
[{
  "_id": {
    "$oid": "66f4fa82edb13818ea8a1de9"
  },
  "name": "Finance API",
  "baseURL": "http://localhost:5001",
  "description": "finance_api_description_1",
  "version": "1.0",
  "category": [
    "finance"
  ],
  "group": [
    "finance & banking"
  ],
  "provider": {
    "$oid": "66f4fa82edb13818ea8a1de4"
  },
  "pricingTiers": [
    {
      "name": "Basic",
      "price": 10,
      "currency": "USD",
      "billingCycle": "monthly",
      "features": [
        "feature1",
        "feature2"
      ],
      "rateLimit": {
        "requests": 1000,
        "per": "day"
      }
    }
  ],
  "endpoints": [
    {
      "path": "/test1",
      "method": "POST",
      "description": "example_description_1",
      "parameters": [
        {
          "name": "name",
          "type": "string",
          "description": "example_param_description_1",
          "required": true
        },
        {
          "name": "empid",
          "type": "string",
          "required": true
        },
        {
          "name": "designation",
          "required": true,
          "type": "string"
        }
      ],
      "requestBody": {
        "description": "example_request_body_description_1",
        "required": true,
        "contentType": "application/json",
        "schema": {
          "designation": "string",
          "empid": "string",
          "name": "string"
        }
      },
      "responses": [
        {
          "statusCode": 200,
          "description": "example_response_description_1",
          "schema": {
            "designation": "developer",
            "empid": "21619",
            "name": "Venugopal"
          }
        }
      ]
    },
    {
      "path": "/test2",
      "method": "POST",
      "description": "finance api decription2",
      "parameters": [
        {
          "name": "name1",
          "type": "string",
          "description": "name description 2",
          "required": true
        },
        {
          "name": "emp_id",
          "type": "string",
          "description": "empid description 2",
          "required": true
        },
        {
          "name": "designation1",
          "type": "string",
          "description": "designation description 2",
          "required": true
        }
      ],
      "requestBody": {
        "description": "request body description 2",
        "required": true,
        "contentType": "application/json",
        "schema": {
          "designation": "string",
          "empid": "string",
          "name": "string"
        }
      },
      "responses": [
        {
          "statusCode": "200",
          "description": "example description 200",
          "schema": {
            "designation": "developer",
            "empid": "21619",
            "name": "venugopal"
          }
        },
        {
          "statusCode": "400",
          "description": "example description 400",
          "schema": {
            "designation": "null",
            "empid": "null",
            "name": "null"
          }
        }
      ]
    }
  ],
  "authentication": {
    "type": "apiKey",
    "description": "example_authentication_description_1"
  },
  "samples": {
    "$oid": "66f4fa82edb13818ea8a1de6"
  },
  "status": "active",
  "createdAt": {
    "$date": "2024-09-26T06:09:06.537Z"
  },
  "updatedAt": {
    "$date": "2024-09-26T06:09:06.537Z"
  },
  "averageRating": 4.5,
  "totalSubscribers": 100,
  "documentationUrl": "http://example.com/docs_1",
  "termsOfServiceUrl": "http://example.com/terms_1",
  "healthCheck": {
    "endpoint": "/health_1",
    "method": "GET",
    "expectedStatusCode": 200,
    "frequency": "daily"
  },
  "isHealthy": true,
  "lastHealthCheckTime": {
    "$date": "2024-09-26T06:09:06.537Z"
  }
}
```

I'm felixible with my data schema