Deprecation Warning
This method will be deprecated on September 7, 2025.
Replace with Create Secret.
Creates a new secret.
The createSecret() function returns a Promise that resolves to the newly created secret's ID when a secret has been created in the Secrets Manager. Secrets created by this function are available in the Secrets Manager section in your site's dashboard, just like any other secret created using the UI.
Note:
The secret's name cannot start with wix
or be identical to an existing secret's name.
Do not leave private keys in your code! Leaving them in is a security risk. Either delete the keys from the code after running createSecret()
, or pass the parameters in using the Functional Testing tool.
function createSecret(secret: Secret): Promise<string>;
The object including the fields of a new secret to be stored.
import { Permissions, webMethod } from "wix-web-module";
import wixSecretsBackend from "wix-secrets-backend";
export const createNewSecret = webMethod(Permissions.Anyone, () => {
const secret = {
name: "s3_secret_key",
value: "Fm8OfflH6bJOwWjenqAtLurLbkiMNvmhQHZV+118",
description: "AWS secret access key",
};
return wixSecretsBackend
.createSecret(secret)
.then((id) => {
return id;
})
.catch((error) => {
console.error(error);
});
});
/*
* Returns a Promise that resolves to:
*
* "5ec36ffb-2cec-489a-9c0e-d8f53fef5fd1"
*/