@runloop/api-client - v3.0.0
    Preparing search index...

    Object-oriented interface for working with Secrets.

    The Secret class provides a high-level, object-oriented API for managing secrets. Secrets are encrypted key-value pairs that can be securely stored and used in Devboxes as environment variables. This wrapper always operates by its account-scoped name, even when it contains an ID from an earlier response. Reads and updates select the greatest ID at lookup; deletion removes every selected match nonatomically. Use sdk.secret.fromId(id) for exact row operations.

    import { RunloopSDK } from '@runloop/api-client-ts';

    const runloop = new RunloopSDK();

    // Create a secret
    const secret = await runloop.secret.create({
    name: 'MY_API_KEY',
    value: 'secret-value',
    });

    // Use the secret in a devbox
    const devbox = await runloop.devbox.create({
    name: 'my-devbox',
    secrets: { 'API_KEY': secret }, // Can use Secret object directly
    });

    // Get secret info
    const info = await secret.getInfo();
    console.log(`Secret: ${info.name}, ID: ${info.id}`);
    Index

    Accessors

    Methods

    Accessors

    • get id(): string | undefined

      Get the secret ID.

      Returns string | undefined

      The ID captured when this wrapper was constructed, or undefined. Fetching does not refresh it.

    • get name(): string

      Get the secret name.

      Returns string

      The literal account-scoped secret name

    Methods

    • Get the complete secret data from the API. This retrieves the full SecretView including id, name, create_time_ms, and update_time_ms.

      Note: The secret value is never returned for security reasons.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<SecretView>

      The secret data (value is not included)

      const info = await secret.getInfo();
      console.log(`Secret: ${info.name}, ID: ${info.id}, Created: ${info.create_time_ms}`);
    • Update the value of the greatest-ID row matching this name at lookup. This wrapper remains name-bound and its captured ID is unchanged.

      Parameters

      • params: SecretUpdateParams

        Parameters for updating the secret

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<RunloopSDK.Secret>

      The updated Secret instance

      const updated = await secret.update({
      value: 'new-secret-value',
      });
      console.log(`Updated at: ${(await updated.getInfo()).update_time_ms}`);