Migrating to the Policy Rule-Based Framework (v1.5)
8 min
your organization has been onboarded to the more flexible policy rule based framework this guide covers what changed on the platform and the api updates you need to integrate help center article https //docs primevault com/help center/policy engine https //docs primevault com/help center/policy engine user onboarding & device registration login now triggers verification emails, and users are activated through a device registration flow the first user to log into the mobile app is approved automatically and becomes active right away for every subsequent user , after they setup and login, we create a device registration request an admin simply approves that request for the user to become active this extra step ensures every new user is verified before gaining access to the platform what changed at a glance area before now (v1 5) vault create createvault({ vaultname, templateid, chains }) , active immediately createvault({ vaultname, chains, vaultgroupids }) → createvaultapproval(vault) , then poll walletsgenerated templateid required removed — not needed vault groups n/a pass vaultgroupids on create contact create single call createcontact( ) → createcontactapproval(contact) contact groups n/a pass contactgroupids ; update via updatecontact → createcontactapproval transfer create only createtransfertransaction( ) → approvechangerequest({ entityid, action approve }) webhook prior version version "2 0 0" , transaction status changed payload 1\) vaults templateid is no longer required — remove it from your createvault payload to add a vault to vault groups, pass the new vaultgroupids param (array of group ids from the ui) vault creation now needs approval — do it as 2 separate calls , then poll for wallets // 1 create — returns the vault before approval (walletsgenerated false) const vault = await apiclient createvault({ vaultname, chains, vaultgroupids }); // 2 approve the change request await apiclient createvaultapproval(vault); // 3 poll until wallets are generated, then read addresses let v = await apiclient getvaultbyid(vault id); while (!v walletsgenerated) { await new promise((r) => settimeout(r, 1000)); v = await apiclient getvaultbyid(vault id); } console log(v wallets); // wallet addresses // convenience createvaultwithapproval(request) runs create + approve in one call 2\) contacts to add a contact to contact groups, pass the contactgroupids param on create contact creation needs approval — 2 separate calls const contact = await apiclient createcontact({ name, address, chain, assetlist, contactgroupids }); await apiclient createcontactapproval(contact); to update the contact groups on an already created contact const contact = await apiclient updatecontact({ id, contactgroupids }); await apiclient createcontactapproval(contact); 3\) transactions create a transfer const txn = await apiclient createtransfertransaction({ source, destination, amount, asset, chain }); after creation the transaction is pending ; approve it await apiclient approvechangerequest({ entityid txn id, action approvalaction approve }); 4\) webhook structure webhook events now use version "2 0 0" with the following transaction payload { "event" "transaction status changed", "version" "2 0 0", "eventid" "\<uuid>", "data" { "transaction" { "id" "\<uuid>", "orgid" "\<uuid>", "orgentityid" "\<uuid>", "vaultid" "\<uuid>", "toaddress" "\<address>", "status" "completed", "blockchain" "ethereum", "txhash" "\<hash>", "asset" "eth", "amount" "0 0001", "amountinusd" "3", "transactiontype" "outgoing", "category" "transfer", "fees" { "amount" "0 001", "asset" "eth" }, "operations" \[ { "source" {}, "destination" {}, "balancechanges" { "changes" \[] }, "sequence" 1, "type" "transfer", "status" "completed" } ] } } } migration checklist remove templateid from all createvault calls add the createvaultapproval step and poll getvaultbyid until walletsgenerated === true adopt vaultgroupids / contactgroupids where you want group membership on create add createcontactapproval after contact create/update approve transfers via approvechangerequest({ entityid, action approvalaction approve }) update webhook handlers to version 2 0 0 and the new transaction schema above