Docs

Vault API reference

The Vault API is the set of methods your code calls on a linked Vault, in the TypeScript, Python, and Rust SDKs. A binding is the connection details Alien injects into each workload linked to the resource, which the SDK client reads.

A handle comes from these calls, where name is the resource ID from alien.ts:

  • TypeScript: vault(name) from @alienplatform/sdk
  • Python: vault(name) from alienplatform
  • Rust: Bindings::from_env()?.vault(name).await? from alien-sdk

Creating the handle in TypeScript or Python does no I/O. The binding resolves on the first call and is cached. Secret values aren't cached: every get reads from the secret service.

Methods at a glance

TypeScriptPythonRustWhat it does
get, getJsonget(name)get_secret(name)Read a secret.
put, putJsonput(name, value)set_secret(name, value)Create or overwrite a secret.
deletedelete(name)delete_secret(name)Delete a secret.
listlist()list_secrets()List secret names. Kubernetes and Local only.
create_secret(name, value)Create a secret only if it doesn't exist.
secret_presence(name)Check a secret without reading its value.

Secret names are passed to the backing service as they are, apart from the platform rewrites in Behavior and limits. Values are strings.

get

Reads the current value of a secret. Throws VAULT_SECRET_NOT_FOUND when it doesn't exist.

const token = await credentials.get("github-token")                   // string
const github = await credentials.getJson<{ token: string }>("github")  // parsed JSON

getJson throws a SyntaxError if the value isn't valid JSON.

On GCP, get reads the latest version. On Azure, it reads the newest version.

put

Creates the secret if it doesn't exist and overwrites it if it does.

await credentials.put("github-token", "ghp_example")
await credentials.putJson("github", { token: "ghp_example", scopes: ["repo"] })  // JSON.stringify

How each platform stores an overwrite:

PlatformOverwrite
AWSA new parameter version (Overwrite: true).
GCPA new secret version. Older versions stay enabled and are billed.
AzureA new secret version.
KubernetesThe Secret is replaced.
LocalThe file is rewritten.

delete

Deletes a secret. Deleting a secret that doesn't exist succeeds.

await credentials.delete("github-token")

On GCP, delete removes the secret and all its versions.

On Azure, the secret goes into Key Vault's soft-deleted state and keeps its name. A put with the same name fails until the retention period ends. See Behavior and limits.

list

Returns the names of the secrets in this vault, without the vault's prefix, so each name can be passed back to get.

const names: string[] = await credentials.list()
PlatformSupported
KubernetesYes. Returns the stored names, which are lowercased and use - for _.
LocalYes.
AWS, GCP, AzureNo. Fails with OPERATION_NOT_SUPPORTED.

Why not on the clouds:

  • AWS: parameter names are flat (<prefix>-<secret>), so a prefix search for vault app would also return secrets from a vault named app-prod. Listing is disabled rather than mixing vaults.
  • GCP and Azure: the client doesn't implement listing yet.

create_secret

Rust only. Creates a secret only if no secret with that name exists. If one does, the write is skipped and the call fails with VAULT_SECRET_ALREADY_EXISTS.

use alien_sdk::ErrorData;

match credentials.create_secret("signing-key", &generated).await {
    Ok(()) => {}
    Err(e) if matches!(e.error, Some(ErrorData::VaultSecretAlreadyExists { .. })) => {}
    Err(e) => return Err(e.into()),
}
PlatformHow it's conditional
AWSPutParameter with Overwrite: false. Atomic.
AzureLists the secret's versions, then writes if there are none. Not atomic, so use it only when one writer owns the secret. A soft-deleted secret counts as existing.
KubernetesCreates the Secret, which the API server refuses if it exists. Atomic.
LocalChecks the file, then writes.
GCPNot supported. Fails with OPERATION_NOT_SUPPORTED.

secret_presence

Rust only. Reports whether a secret exists and is usable, from metadata only. The value is never fetched.

use alien_bindings::SecretPresence; // not re-exported from alien-sdk

match credentials.secret_presence("github-token").await? {
    SecretPresence::Present { version } => { /* version changes on every overwrite */ }
    SecretPresence::Missing => { /* never written */ }
    SecretPresence::Invalid { reason } => { /* exists but can't be used as is */ }
}

version is the store's own identifier for the current value: an SSM parameter version, a Secret Manager version name, a Key Vault version ID, a Kubernetes resourceVersion, or a local write counter.

Compare it to decide when to restart a workload to pick up a new value.

Invalid covers cases such as an SSM parameter that isn't a SecureString, a disabled or destroyed latest version on GCP, or a disabled or expired version on Azure.

The binding

A linked Vault injects ALIEN_<NAME>_BINDING, uppercased with hyphens as underscores: credentials becomes ALIEN_CREDENTIALS_BINDING. The SDKs read it for you. It's JSON tagged by service:

servicePlatformFields
parameter-storeAWSvaultPrefix
secret-managerGCPvaultPrefix
key-vaultAzurevaultName
kubernetes-secretKubernetesnamespace, vaultPrefix
local-vaultLocalvaultName, dataDir

The binding holds no secret values and no credentials. The workload's own identity authorizes each call.

Errors

CodeRetryableWhen
VAULT_SECRET_NOT_FOUNDNoget on a secret that doesn't exist.
VAULT_SECRET_ALREADY_EXISTSNocreate_secret on a secret that exists.
OPERATION_NOT_SUPPORTEDNolist on AWS, GCP, or Azure, or create_secret on GCP.
CLOUD_PLATFORM_ERRORYesAny other failure from the secret service, including access denied and throttling. The cause is attached.
BINDING_NOT_CONFIGUREDNoThe workload isn't linked to this resource.

Errors name the secret, never its value.

On this page