@runloop/api-client - v1.10.3
    Preparing search index...

    Class SecretOps

    Secret SDK interface for managing secrets.

    The SecretOps class provides methods for managing secrets, which are encrypted key-value pairs that can be injected into devboxes as environment variables. Secrets are identified by their globally unique name.

    This interface is accessed via RunloopSDK.secret. You should construct a RunloopSDK instance and use it from there:

    const runloop = new RunloopSDK();

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

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

    // The secret is now available as $API_KEY in the devbox
    const result = await devbox.cmd.exec('echo $API_KEY');
    Index

    Methods

    • Create a new secret.

      Parameters

      • params: SecretCreateParams

        Parameters for creating the secret.

      • Optionaloptions: RequestOptions<unknown>

        Request options.

      Returns Promise<RunloopSDK.Secret>

      The created Secret instance.

      const runloop = new RunloopSDK();
      const secret = await runloop.secret.create({
      name: 'DATABASE_PASSWORD',
      value: 'my-secure-password',
      });
      console.log(`Created secret: ${secret.name}`);
    • Get a Secret instance by name without making an API call. Use getInfo() on the returned Secret to fetch the actual data.

      Parameters

      • name: string

        The globally unique name of the secret.

      Returns RunloopSDK.Secret

      A Secret instance.

      const runloop = new RunloopSDK();
      const secret = runloop.secret.fromName('MY_API_KEY');
      const info = await secret.getInfo();
      console.log(`Secret ID: ${info.id}`);
    • Update an existing secret's value.

      Parameters

      • secret: string | RunloopSDK.Secret

        The secret to update (Secret object or name string).

      • params: SecretUpdateParams

        Parameters for updating the secret.

      • Optionaloptions: RequestOptions<unknown>

        Request options.

      Returns Promise<RunloopSDK.Secret>

      The updated Secret instance.

      const runloop = new RunloopSDK();
      // Using a secret name string
      const updated = await runloop.secret.update('DATABASE_PASSWORD', {
      value: 'my-new-password',
      });

      // Or using a Secret object
      const secret = runloop.secret.fromName('DATABASE_PASSWORD');
      const updated2 = await runloop.secret.update(secret, {
      value: 'another-new-password',
      });
    • List all secrets.

      Parameters

      • Optionalparams: SecretListParams

        Optional filter parameters.

      • Optionaloptions: RequestOptions<unknown>

        Request options.

      Returns Promise<RunloopSDK.Secret[]>

      An array of Secret instances.

      const runloop = new RunloopSDK();
      const secrets = await runloop.secret.list();
      for (const secret of secrets) {
      console.log(`${secret.name}`);
      }
      // With pagination
      const secrets = await runloop.secret.list({ limit: 10 });
    • Delete a secret.

      Parameters

      • secret: string | RunloopSDK.Secret

        The secret to delete (Secret object or name string).

      • Optionaloptions: RequestOptions<unknown>

        Request options.

      Returns Promise<SecretView>

      The deleted secret metadata.

      const runloop = new RunloopSDK();
      // Using a secret name string
      const deleted = await runloop.secret.delete('DATABASE_PASSWORD');

      // Or using a Secret object
      const secret = runloop.secret.fromName('MY_SECRET');
      await runloop.secret.delete(secret);