This topic describes how to use the reset account functionality when working with the GraphQL querying service in Optimizely solutions.
How it works
The reset account functionality provides a way to reset the tenant account data by removing all indices and create new standard indices for the current tenant.
This functionality is helpful when you use the same tenant account for different sites with different content and content types, or you want to reset your data to standard indices.
Note: After resetting your account successfully, you will need to manually run all the
indexing jobs again. Also, be aware that reset account
functionality is an advanced function that can delete all of your indexed data.
There are two ways to use the reset account functionality:
- Reset account UI.
- Reset account mutation.
Using reset account UI
After installing the Optimizely.Search.Synchronizer package, a "Project GraphQL" menu will be added to your admin menus.
- Go to Admin -> Project GraphQL, or go to http://yoursite/EPiServer/ProjectGraphQL/GraphQLAdmin.
- Click Reset Account, and confirm to reset the current account.

Using reset account mutation
mutation {
resetAccount
}
To use reset account mutation, you need to use HMAC authentication for data integrity and message authentication purposes, and have the confirmation header RemoveAllData set to true in your request.
Example using Postman
Url:
POST https://optimizely.gq/content/v2
Headers:
RemoveAllData: true
Body (GraphQL):
mutation {
resetAccount
}
Pre-request Script:
var crypto = require('crypto-js')
var uuid = require('uuid')
// Update this with your keys first
var appKey = "yourProvidedAppKey"
var secret = "yourProvidedSecret"
// Collect data needed for HMAC
var time = (new Date()).getTime()
var path = pm.request.url.getPath()
var bodySignature = CryptoJS.MD5(pm.request.body.toString())
var nonce = uuid.v4()
var method = pm.request.method
// Build Message
var message = appKey+method+path+time+nonce+bodySignature
console.log("Message",message)
// Sign message and create header
var hash = crypto.HmacSHA256(message,secret)
var hashHeader = [
appKey,
time,
nonce,
CryptoJS.enc.Base64.stringify(hash)
].join(':')
// Add Authorization header with computed HMAC to the request
pm.request.headers.add({
key: "Authorization",
value: "epi-hmac "+ hashHeader
});
HMAC keys:
var appKey = "yourProvidedAppKey"
var secret = "yourProvidedSecret"
Above appKey and secret in the Pre-request Script must be replaced with the same keys that are used in Web.config or appsettings.json of your site.
Successful result:

Postman collection
You can import this collection to your Postman then use it:
ResetAccount.postman_collection
Related topics
Last updated: Jul 02, 2021