Skip to main content

Managing Secrets with Node.js SDK

This guide covers how to manage secrets using the Julep Node.js SDK. Secrets allow you to securely store and use sensitive information like API keys, passwords, and access tokens in your Julep applications.

Installation

Ensure you have the latest version of the Node.js SDK:

Authentication

Initialize the client with your API key:

Creating Secrets

Create a new secret:

Required Parameters

  • name: The name of the secret (must be a valid identifier)
  • value: The secret value to encrypt and store

Optional Parameters

  • description: A description of what the secret is used for
  • metadata: An object of metadata to associate with the secret

Listing Secrets

List all available secrets:

Pagination

Use pagination to handle large numbers of secrets:

Filtering by Metadata

Filter secrets based on metadata:

Retrieving Secrets

Get a specific secret by name:
Note: For security, when listing secrets, the .value field will always show “ENCRYPTED”. The actual secret value is only returned when specifically requesting a single secret by name.

Updating Secrets

Update an existing secret:

Partial Updates

You can update specific fields without changing others:

Deleting Secrets

Delete a secret when it’s no longer needed:

Using Secrets in Tasks

Reference secrets when executing tasks:

Using Secrets in Expressions

You can reference secrets in expressions:

Using Multiple Secrets

For tools that require multiple secrets:

Error Handling

Handle common errors when working with secrets:

Secret Rotation Example

Implement a secret rotation policy:

Working with Async/Await

All methods in the Node.js SDK return Promises, making them compatible with async/await:

Best Practices

  1. Use a consistent naming convention for all secrets
  2. Add detailed descriptions and metadata to make secrets discoverable
  3. Implement a rotation policy for sensitive secrets
  4. Log secret operations (creation, updates, deletions) but never log values
  5. Use try/catch blocks to handle potential errors gracefully
  6. Consider automating secret rotation for important credentials
  7. Use metadata to track important dates and ownership information

Next Steps