Manage App Policy

In this guide, we will discuss managing the policy to your MetaKeep App programmatically using the MetaKeep admin APIs. You can find end-to-end working scripts here.

Prerequisites

Please follow the previous guide to create and update MetaKeep apps programmatically using the MetaKeep admin APIs.

Manage Policy

MetaKeep supports setting up an app policy to restrict the management and usage of certain app features. Please refer to the docs here for more details.

To add a new app policy, prepare a JSON request with the quorum that you want to use for the policy. Here's an example:

{
  "appId": "appId",
  "policy": {
    "apiKeysOwnership": {
      "quorum": {
        "members": [
          {
            "type": "ACCOUNT_ADMIN",
          },
          {
            "type": "SOL_ADDRESS",
            "public_key": "external_solana_address",
          },
        ]
      }
    }
  }
}

Then, make a POST request to the /v2/app/update API to update the policy of the app. Once the policy has been updated, any changes to API keys and related features will require quorum approval.

Running the demo Scripts

You can find end-to-end working scripts here. To run the script, follow the steps below:

Step 1: Clone the MetaKeepCodeSamples repository and navigate to the admin-apis directory.

Step 2: Install all dependencies using npm install.

Step 3: Update ACCOUNT_KEY and ACCOUNT_SECRET in the .env file.

Step 4: Update APP_ID in the .env file with the appId of the app where you want to add or delete API keys.

Step 5: Update APP_POLICY_QUORUM_MEMBER_EMAIL in the .env file with the email of the user to use as the quorum member. The sol_address corresponding to the user's email will be used in the policy update request.

Step 6: Run npm run manageAppPolicy to update the app policy.

You have now successfully updated the policy of your app programmatically using your account key.