MysteryBox has been renamed to SecretStash. In CLI commands, SDK imports and role IDs, use
secretstash instead of mysterybox.Prerequisites
- Web console
- CLI
- Go SDK
- Python SDK
- JavaScript SDK
Creating a secret or a version of a secret does not automatically grant you access to view payloads in that secret or version. The
editor role is enough to create a secret or a version, but viewing payloads requires the secretstash.payload-viewer role, which is a sub-role of admin but not editor.- Install and configure the Nebius AI Cloud CLI.
Creating a secret or a version of a secret does not automatically grant you access to view payloads in that secret or version. The
editor role is enough to create a secret or a version, but viewing payloads requires the secretstash.payload-viewer role, which is a sub-role of admin but not editor.Creating a secret or a version of a secret does not automatically grant you access to view payloads in that secret or version. The
editor role is enough to create a secret or a version, but viewing payloads requires the secretstash.payload-viewer role, which is a sub-role of admin but not editor.Creating a secret or a version of a secret does not automatically grant you access to view payloads in that secret or version. The
editor role is enough to create a secret or a version, but viewing payloads requires the secretstash.payload-viewer role, which is a sub-role of admin but not editor.Creating a secret or a version of a secret does not automatically grant you access to view payloads in that secret or version. The
editor role is enough to create a secret or a version, but viewing payloads requires the secretstash.payload-viewer role, which is a sub-role of admin but not editor.How to create a secret without a version
You can create a secret without a version by using the CLI or an SDK. If you want to use the web console, follow How to create a secret with a version.- CLI
- Go SDK
- Python SDK
- JavaScript SDK
Run the following command:In the command, specify the following values:
nebius secretstash secret create \
--name "<secret_name>" \
--description "<description>"
name: Name of the secret.description(optional): Secret description.
Create a secret:In the code, specify the following values:
emptySecretService := sdk.Services().Secretstash().V1().
Secret()
emptySecretOperation, err := emptySecretService.Create(
ctx,
&mb.CreateSecretRequest{
Metadata: &common.ResourceMetadata{
Name: "<secret_name>",
},
Spec: &mb.SecretSpec{
Description: "<description>",
},
},
)
if err != nil {
return fmt.Errorf("create secret: %w", err)
}
emptySecretOperation, err = emptySecretOperation.Wait(ctx)
if err != nil {
return fmt.Errorf("wait for creation: %w", err)
}
emptySecret, err := emptySecretService.Get(
ctx,
&mb.GetSecretRequest{Id: emptySecretOperation.ResourceID()},
)
if err != nil {
return fmt.Errorf("get created resource: %w", err)
}
fmt.Println(emptySecret)
Metadata.Name: Name of the secret.Spec.Description(optional): Secret description.
Create a secret:In the code, specify the following values:
service = SecretServiceClient(sdk)
operation = await service.create(
CreateSecretRequest(
metadata=ResourceMetadata(name="<secret_name>"),
spec=SecretSpec(
description="<description>",
),
),
)
await operation.wait()
resource = await service.get(
GetSecretRequest(id=operation.resource_id),
)
print(resource)
metadata.name: Name of the secret.spec.description(optional): Secret description.
Create a secret:In the code, specify the following values:
const emptySecretService = new SecretService(sdk);
const emptySecretOperation = await emptySecretService.create(
CreateSecretRequest.create({
metadata: { name: "<secret_name>" },
spec: {
description: "<description>",
},
}),
).result;
await emptySecretOperation.wait();
const emptySecret = await emptySecretService.get(
GetSecretRequest.create({
id: emptySecretOperation.resourceId(),
}),
).result;
console.log(emptySecret);
metadata.name: Name of the secret.spec.description(optional): Secret description.
How to create a secret with a version
You can specify one or several key-value pairs in the version payload. Every pair contains a string value or binary data.- Web console
- CLI
- Go SDK
- Python SDK
- JavaScript SDK
-
In the web console, go to
Cryptography → SecretStash.
-
Click
Create secret.
-
In the window that opens, specify a unique name for the secret. For example,
db-credentials. - (Optional) Add a description that explains what the secret is used for. For example, “Credentials for the production database.”
-
In the Key and Value fields, specify a key-value pair that the secret should store. This pair will be the payload of this secret.
In the Value field, select a data type:
- Text: Specify a plain string. Commonly used for passwords, tokens and API keys.
- File: Upload a binary file. Convenient for certificates, private keys and configuration files.
-
(Optional) To store multiple key-value pairs in a single version, click
Add pair. Then, specify additional key-value pairs.
- Click Create secret.
Run the
nebius secretstash secret create command.-
Strings:
nebius secretstash secret create \ --name "<secret_name>" \ --description "<description>" \ --secret-version-payload '[ {"key": "<key_name>", "string_value": "<value>"}, {"key": "<key_name>", "string_value": "<value>"}, ... ]' -
Binary files, Ubuntu:
nebius secretstash secret create \ --name "<secret_name>" \ --description "<description>" \ --secret-version-payload "[ {\"key\": \"<key_name>\", \"binary_value\": \"$(base64 -w 0 <path/to/file>)\"}, {\"key\": \"<key_name>\", \"binary_value\": \"$(base64 -w 0 <path/to/file>)\"}, ... ]" -
Binary files, macOS:
nebius secretstash secret create \ --name "<secret_name>" \ --description "<description>" \ --secret-version-payload "[ {\"key\": \"<key_name>\", \"binary_value\": \"$(base64 -i <path/to/file>)\"}, {\"key\": \"<key_name>\", \"binary_value\": \"$(base64 -i <path/to/file>)\"}, ... ]" -
Both strings and binary files, Ubuntu:
nebius secretstash secret create \ --name "<secret_name>" \ --description "<description>" \ --secret-version-payload "[ {\"key\": \"<key_name>\", \"string_value\": \"<value>\"}, {\"key\": \"<key_name>\", \"binary_value\": \"$(base64 -w 0 <path/to/file>)\"}, ... ]" -
Both strings and binary files, macOS:
nebius secretstash secret create \ --name "<secret_name>" \ --description "<description>" \ --secret-version-payload "[ {\"key\": \"<key_name>\", \"string_value\": \"<value>\"}, {\"key\": \"<key_name>\", \"binary_value\": \"$(base64 -i <path/to/file>)\"}, ... ]"
name: Name of the secret.description(optional): Secret description.key: Name of the key.string_value: For each key with a string value, a sensitive secret value.path/to/file: For each key with a binary value, a local path to the file whose contents you want to store as binary data in the secret.
Create a secret together with its first version:
-
Strings:
stringSecretService := sdk.Services().Secretstash().V1(). Secret() stringSecretPayload := []*mb.Payload{ { Key: "<key_name>", Payload: &mb.Payload_StringValue{ StringValue: "<value>", }, }, { Key: "<key_name>", Payload: &mb.Payload_StringValue{ StringValue: "<value>", }, }, } stringSecretOperation, err := stringSecretService.Create( ctx, &mb.CreateSecretRequest{ Metadata: &common.ResourceMetadata{ Name: "<secret_name>", }, Spec: &mb.SecretSpec{ Description: "<description>", SecretVersion: &mb.SecretVersionSpec{ Payload: stringSecretPayload, }, }, }, ) if err != nil { return fmt.Errorf("create secret: %w", err) } stringSecretOperation, err = stringSecretOperation.Wait(ctx) if err != nil { return fmt.Errorf("wait for creation: %w", err) } stringSecret, err := stringSecretService.Get( ctx, &mb.GetSecretRequest{Id: stringSecretOperation.ResourceID()}, ) if err != nil { return fmt.Errorf("get created resource: %w", err) } fmt.Println(stringSecret) -
Binary files:
binaryUbuntuService := sdk.Services().Secretstash().V1(). Secret() binaryUbuntuData, err := os.ReadFile("<path/to/file>") if err != nil { return fmt.Errorf("read payload file: %w", err) } binaryUbuntuPayload := []*mb.Payload{ { Key: "<key_name>", Payload: &mb.Payload_BinaryValue{ BinaryValue: binaryUbuntuData, }, }, { Key: "<key_name>", Payload: &mb.Payload_BinaryValue{ BinaryValue: binaryUbuntuData, }, }, } binaryUbuntuOperation, err := binaryUbuntuService.Create( ctx, &mb.CreateSecretRequest{ Metadata: &common.ResourceMetadata{ Name: "<secret_name>", }, Spec: &mb.SecretSpec{ Description: "<description>", SecretVersion: &mb.SecretVersionSpec{ Payload: binaryUbuntuPayload, }, }, }, ) if err != nil { return fmt.Errorf("create secret: %w", err) } binaryUbuntuOperation, err = binaryUbuntuOperation.Wait(ctx) if err != nil { return fmt.Errorf("wait for creation: %w", err) } binaryUbuntu, err := binaryUbuntuService.Get( ctx, &mb.GetSecretRequest{Id: binaryUbuntuOperation.ResourceID()}, ) if err != nil { return fmt.Errorf("get created resource: %w", err) } fmt.Println(binaryUbuntu) -
Both strings and binary files:
mixedUbuntuService := sdk.Services().Secretstash().V1(). Secret() mixedUbuntuData, err := os.ReadFile("<path/to/file>") if err != nil { return fmt.Errorf("read payload file: %w", err) } mixedUbuntuPayload := []*mb.Payload{ { Key: "<key_name>", Payload: &mb.Payload_StringValue{ StringValue: "<value>", }, }, { Key: "<key_name>", Payload: &mb.Payload_BinaryValue{ BinaryValue: mixedUbuntuData, }, }, } mixedUbuntuOperation, err := mixedUbuntuService.Create( ctx, &mb.CreateSecretRequest{ Metadata: &common.ResourceMetadata{ Name: "<secret_name>", }, Spec: &mb.SecretSpec{ Description: "<description>", SecretVersion: &mb.SecretVersionSpec{ Payload: mixedUbuntuPayload, }, }, }, ) if err != nil { return fmt.Errorf("create secret: %w", err) } mixedUbuntuOperation, err = mixedUbuntuOperation.Wait(ctx) if err != nil { return fmt.Errorf("wait for creation: %w", err) } mixedUbuntu, err := mixedUbuntuService.Get( ctx, &mb.GetSecretRequest{Id: mixedUbuntuOperation.ResourceID()}, ) if err != nil { return fmt.Errorf("get created resource: %w", err) } fmt.Println(mixedUbuntu)
Key: Name of the key.StringValue: For each key with a string value, a sensitive secret value.BinaryValue: For each key with a binary value, the file contents to store as binary data in the secret. In the examples,os.ReadFilereads them from a local path.Metadata.Name: Name of the secret.Spec.Description(optional): Secret description.
Create a secret together with its first version:
-
Strings:
service = SecretServiceClient(sdk) payload = [ Payload( key="<key_name>", string_value="<value>", ), Payload( key="<key_name>", string_value="<value>", ), ] operation = await service.create( CreateSecretRequest( metadata=ResourceMetadata(name="<secret_name>"), spec=SecretSpec( description="<description>", secret_version=SecretVersionSpec(payload=payload), ), ), ) await operation.wait() resource = await service.get( GetSecretRequest(id=operation.resource_id), ) print(resource) -
Binary files:
service = SecretServiceClient(sdk) file_data = Path("<path/to/file>").read_bytes() payload = [ Payload( key="<key_name>", binary_value=file_data, ), Payload( key="<key_name>", binary_value=file_data, ), ] operation = await service.create( CreateSecretRequest( metadata=ResourceMetadata(name="<secret_name>"), spec=SecretSpec( description="<description>", secret_version=SecretVersionSpec(payload=payload), ), ), ) await operation.wait() resource = await service.get( GetSecretRequest(id=operation.resource_id), ) print(resource) -
Both strings and binary files:
service = SecretServiceClient(sdk) file_data = Path("<path/to/file>").read_bytes() payload = [ Payload( key="<key_name>", string_value="<value>", ), Payload( key="<key_name>", binary_value=file_data, ), ] operation = await service.create( CreateSecretRequest( metadata=ResourceMetadata(name="<secret_name>"), spec=SecretSpec( description="<description>", secret_version=SecretVersionSpec(payload=payload), ), ), ) await operation.wait() resource = await service.get( GetSecretRequest(id=operation.resource_id), ) print(resource)
key: Name of the key.string_value: For each key with a string value, a sensitive secret value.binary_value: For each key with a binary value, the file contents to store as binary data in the secret. In the examples,Path.read_bytesreads them from a local path.metadata.name: Name of the secret.spec.description(optional): Secret description.
Create a secret together with its first version:
-
Strings:
const stringSecretService = new SecretService(sdk); const stringSecretPayload = [ { key: "<key_name>", payload: { $case: "stringValue", stringValue: "<value>", }, }, { key: "<key_name>", payload: { $case: "stringValue", stringValue: "<value>", }, }, ]; const stringSecretOperation = await stringSecretService.create( CreateSecretRequest.create({ metadata: { name: "<secret_name>" }, spec: { description: "<description>", secretVersion: { payload: stringSecretPayload }, }, }), ).result; await stringSecretOperation.wait(); const stringSecret = await stringSecretService.get( GetSecretRequest.create({ id: stringSecretOperation.resourceId(), }), ).result; console.log(stringSecret); -
Binary files:
const binaryUbuntuService = new SecretService(sdk); const binaryUbuntuData = await readFile("<path/to/file>"); const binaryUbuntuPayload = [ { key: "<key_name>", payload: { $case: "binaryValue", binaryValue: binaryUbuntuData, }, }, { key: "<key_name>", payload: { $case: "binaryValue", binaryValue: binaryUbuntuData, }, }, ]; const binaryUbuntuOperation = await binaryUbuntuService.create( CreateSecretRequest.create({ metadata: { name: "<secret_name>" }, spec: { description: "<description>", secretVersion: { payload: binaryUbuntuPayload }, }, }), ).result; await binaryUbuntuOperation.wait(); const binaryUbuntu = await binaryUbuntuService.get( GetSecretRequest.create({ id: binaryUbuntuOperation.resourceId(), }), ).result; console.log(binaryUbuntu); -
Both strings and binary files:
const mixedUbuntuService = new SecretService(sdk); const mixedUbuntuData = await readFile("<path/to/file>"); const mixedUbuntuPayload = [ { key: "<key_name>", payload: { $case: "stringValue", stringValue: "<value>", }, }, { key: "<key_name>", payload: { $case: "binaryValue", binaryValue: mixedUbuntuData, }, }, ]; const mixedUbuntuOperation = await mixedUbuntuService.create( CreateSecretRequest.create({ metadata: { name: "<secret_name>" }, spec: { description: "<description>", secretVersion: { payload: mixedUbuntuPayload }, }, }), ).result; await mixedUbuntuOperation.wait(); const mixedUbuntu = await mixedUbuntuService.get( GetSecretRequest.create({ id: mixedUbuntuOperation.resourceId(), }), ).result; console.log(mixedUbuntu);
key: Name of the key.payload.$case: Type of the value:stringValuefor a string orbinaryValuefor binary data.stringValue: For each key with a string value, a sensitive secret value.binaryValue: For each key with a binary value, the file contents to store as binary data in the secret. In the examples,readFilereads them from a local path.metadata.name: Name of the secret.spec.description(optional): Secret description.