Securely store configuration data like user secrets and API keys and reuse them in transformations.
Available Plans
starter
growth
enterprise
4 minute read
The credential store is a central repository in the RudderStack dashboard for securely storing and efficiently managing your configuration data.
By storing secrets and variables in RudderStack’s credential store, you can avoid hardcoding sensitive information in your transformations and avoid any security risks.
Credentials overview
RudderStack supports two types of credentials - Secrets and Variables.
You must have Admin privileges to create, edit, and delete secrets and variables.
Create secrets
Go to the Secrets tab of the credential store.
Click New secret.
Enter the secret name and value.
Secret names can contain only alphanumeric characters and underscores and they cannot start with a number.
Click Add to save the secret.
To edit a secret, click the edit icon, enter the new secret value, and click Save. Note that the previous secret value will not be visible.
Create variables
Go to the Variables tab of the credential store.
Click New variable.
Enter the variable name and value.
Variable names must contain only alphanumeric characters and underscores and they cannot start with a number.
Click Add to save the variable.
To edit a variable, click the edit icon, enter the new value, and click Save.
Use credentials in transformations
Once you create the credentials in the credential store, you can easily reuse them by referencing them within the getCredential() function in your transformations.
Note the following while using credentials in transformations:
Any workspace member can use the credentials in their transformations.
getCredential is a restricted keyword in transformations. You must not use it for naming functions or variables.
RudderStack drops the event in case of any error while using the getCredential function in a transformation that is connected to a destination.
Do not log or embed secrets in the event payload from the transformation.
All workspace users (including read-only users) have access to the transformation logs and live events and can get access to these secrets if you do not handle them properly in the transformation.
Examples
The following example shows a custom transformation that:
Fetches a variable named dev_url from the credential store,
The following example highlights the usage of credentials within a fetchV2 function:
exportasyncfunctiontransformEvent(event,metadata){consturl=getCredential('URL');// Variable named URL
constid=getCredential('ID');// Credential named ID
constauthToken=getCredential('authToken');// Secret named authToken
constresponse=awaitfetchV2(`${url}/${id}`,{headers:{Authorization:"Bearer "+authToken}});event.value=response.bodyreturnevent;}
Considerations for using getCredential function
Note the following scenarios and the expected behavior when using the getCredential function:
Scenario
Behavior (JavaScript)
Behavior (Python)
getCredential function called without a key
You will get the following error:
TypeError: Key should be valid and defined
You will get the following error:
TypeError('Key should be valid and defined')
getCredential function called with multiple arguments
Credential function takes the first argument as the key.
Credential function takes the first argument as the key.
getCredential function called with a non-string key (for example, integers, Boolean)
No credential value is passed and the event remains unchanged.
Credential value is passed as null.
getCredential function called with a non-existent key
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.