Workload Secrets Vault SDKs
This feature is currently available only to customers participating in a Private Preview. If you'd like to participate and be among the first to try this feature, ask our support or account team for details.
SDKs for .NET, Go, Java, and Python wrap the Workload Secrets Vault REST API so that applications can read secrets and call every other operation without building HTTP requests themselves. The SDKs are in preview, with version numbers such as 0.1.0-preview.2. Each SDK has its own version number, and Python preview versions take the form 0.1.0b1. During the preview, they aren't published to public package registries. Ask your Delinea account team for access.
| SDK | Package | Requires | GetSecret helper |
|---|---|---|---|
| .NET | NuGet package Delinea.WorkloadSecrets.Public.Api.Client |
.NET 10 | Yes, GetSecretAsync, from 0.1.0-preview.3 |
| Go | Go module, package workloadsecrets. The module path is provided with the preview and will change before general availability. |
Go 1.26.11 | Yes, from v0.1.0-preview.2 |
| Java | Maven artifact com.delinea.secrets:workload-secrets-sdk |
Java 11 | Yes |
| Python | Python package delinea-workload-secrets, imported as delinea_workload_secrets |
Python 3.11 | Yes, get_secret |
To mint credentials from dynamic secrets, use at least these versions: Go v0.1.0-preview.3, .NET 0.1.0-preview.3, Java 0.1.0-preview.2, and Python 0.1.0b1. Earlier versions can't mint.
What the SDKs Handle
-
Every API operation. Each SDK includes a typed client for all Workload Secrets Vault operations, with request and response models and the Problem Details error format.
-
Sign-in. With a client ID and client secret, the SDK gets an access token with the client credentials grant, caches it until it expires, and gets a new one when the service rejects an expired token.
-
Workload identity. Instead of a client ID and client secret, you can give the SDK a token source: your own code that returns an access token. This is how workload identity works. The application signs in with a token from your own identity provider, such as Microsoft Entra, Kubernetes, or GitHub, so it doesn't need a stored secret. The token's issuer must be one that your Delinea Platform tenant trusts. The SDK asks the token source for a token on every request, so cache the token in your source and refresh it before it expires. For an example, see the Bring your own token section of each SDK's README on GitHub: .NET, Go, Java, and Python.
-
Safe retries. The SDK makes up to four attempts, with exponential backoff and jitter, and follows
Retry-Afterfor waits of up to 30 seconds. If the service asks for a longer wait, the SDK returns the response instead of waiting. Operations that the API marks as safe to repeat, such as reads, are retried after connection errors and408,429,502,503, and504responses. Other operations, such as writes and mints, are retried only when the request provably wasn't processed. See Retrying Requests. -
Timeouts. By default, each attempt times out after 15 seconds and the whole call after 60 seconds. Both values can be configured.
-
Redirects. The SDK follows
307and308redirects only to the same host, so your token is never sent to another host. -
HTTPS only. All four SDKs refuse a base URL or token endpoint that uses plain
http://, so credentials and secrets are never sent in clear text. The only exception is for local testing: plainhttp://is allowed to the same computer, atlocalhost,127.0.0.1, or::1. -
A simple read. Each SDK has a helper that returns a secret's data and version:
GetSecretin Go,GetSecretAsyncin .NET,getSecretin Java, andget_secretin Python. A dynamic secret has no stored values, so reading one fails with a conflict error (409). The string form of the returned secret shows key names but never values, so a secret logged by mistake doesn't leak. -
Minting. To get a credential from a dynamic secret, call
MintSecretin Go,mintSecretin Java, ormint_secretin Python. It returns the credential with its lease ID and expiry time. Each call creates a new credential, so the SDK never resends a mint that might have reached the service. The .NET SDK has no one-call mint yet: callapi.Api.V1.Secrets.Mint[path].PostAsync()on the generated client, as shown in Example: Configuring the .NET SDK. See also Minting a Credential.
Configuration
| Setting | Value |
|---|---|
| Base URL | https://<your-tenant>.delinea.app/workload-secrets. The SDK adds /api/v1. |
| Tenant ID | Your tenant's ID. It's the value after drn:dws: in the subjects and targets that policy get returns. It's optional in the Go, Java, and Python SDKs, because the API finds your tenant from the base URL. The .NET SDK still lists TenantId as a required setting, so set it there. |
| Client ID and client secret | The service user's username and password. Read them from the environment or a secret store, not from source code. Not needed if you supply your own token source. See What the SDKs Handle. |
| Token endpoint | https://<your-tenant>.delinea.app/identity/api/oauth2/token/xpmplatform
|
| Timeouts | Optional. The per-attempt and total timeouts. |
Example: Reading a Secret in Go
import (
"context"
"errors"
"log"
"os"
workloadsecrets "github.com/DelineaXPM/workload-secrets-sdk-go"
)
func main() {
client, err := workloadsecrets.New(workloadsecrets.ClientOptions{
BaseURL: "https://example.delinea.app/workload-secrets",
ClientID: os.Getenv("WS_CLIENT_ID"),
ClientSecret: os.Getenv("WS_CLIENT_SECRET"),
TokenEndpoint: "https://example.delinea.app/identity/api/oauth2/token/xpmplatform",
})
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// A static secret: read its stored values.
secret, err := client.GetSecret(ctx, "payments/prod/orders-db")
if errors.Is(err, workloadsecrets.ErrNotFound) {
log.Fatal("no secret at that path")
} else if err != nil {
log.Fatal(err)
}
password, _ := secret.Data["password"].(string)
// A dynamic secret: mint a new credential. Each call creates another one.
credential, err := client.MintSecret(ctx, "payments/prod/orders-db-read")
if err != nil {
log.Fatal(err)
}
username, _ := credential.Data["username"].(string)
dbPassword, _ := credential.Data["password"].(string)
if credential.Lease != nil {
log.Printf("lease %s expires at %s", credential.Lease.ID, credential.Lease.ExpiresAt)
}
_, _, _ = password, username, dbPassword
}
Errors from the API can be matched with errors.Is against ErrUnauthorized, ErrForbidden, ErrNotFound, and ErrConflict. GetSecret fails with ErrConflict for a dynamic secret, and MintSecret fails with it for a secret that isn't dynamic. Error messages include the status, error code, and title, but never response bodies or secret values.
Example: Configuring the .NET SDK
Register the client with dependency injection and bind its settings from configuration:
{
"WorkloadSecretsApiClient": {
"BaseUrl": "https://example.delinea.app/workload-secrets",
"TenantId": "<tenant-id>",
"TokenEndpoint": "https://example.delinea.app/identity/api/oauth2/token/xpmplatform"
}
}
using Delinea.WorkloadSecrets.Public.Api.Client;
// ClientId and ClientSecret come from configuration too, for example
// environment variables WorkloadSecretsApiClient__ClientId and WorkloadSecretsApiClient__ClientSecret.
services.AddWorkloadSecretsApiClient(configuration);
// Later, from the service provider:
var client = provider.GetRequiredService<WorkloadSecretsApiClient>();
var read = await client.Api.V1.Secrets.Data["payments/prod/orders-db"].GetAsync();
var version = read?.Data?.Metadata?.Version;
var keys = read?.Data?.Data?.AdditionalData.Keys;
The secret's keys and values are in read.Data.Data.AdditionalData. API errors are raised as ApiProblemDetails when the response has a body, with the error code in ErrorCode, and as ApiException otherwise.
The SDK also registers IWorkloadSecretsClient. Its GetSecretAsync reads a secret in one call and returns the secret's values in Data, as JsonElements. It throws SecretNotFoundException when there's no secret at the path, and WorkloadSecretsApiException for other errors, with the status in StatusCode and the error code in ErrorCode. For a dynamic secret, it throws WorkloadSecretsApiException with status 409.
The .NET SDK has no one-call mint yet, so mint a credential from a dynamic secret with the generated client. The credential is a DatabaseCredential or an AzureCredential, both in the Delinea.WorkloadSecrets.Public.Api.Client.Models namespace:
var secrets = provider.GetRequiredService<IWorkloadSecretsClient>();
var secret = await secrets.GetSecretAsync("payments/prod/orders-db");
var password = secret.Data["password"].GetString();
// Each call creates a new credential.
var minted = await client.Api.V1.Secrets.Mint["payments/prod/orders-db-read"].PostAsync();
if (minted?.Data?.Credential is DatabaseCredential database)
{
var username = database.Username;
var dbPassword = database.Password;
}
var leaseId = minted?.Data?.LeaseId;
var expiresAt = minted?.Data?.ExpiresAt;
Example: Reading a Secret in Python
Install an exact version of the package, for example delinea-workload-secrets==0.1.0b1. The SDK's dependencies come from PyPI, and the package name isn't registered on PyPI yet. If you don't give an exact version, pip takes the highest version it finds on any index, which could be a package of the same name that someone else uploaded to PyPI.
import os
from delinea_workload_secrets import ClientOptions, NotFoundError, WorkloadSecretsClient
options = ClientOptions(
base_url="https://example.delinea.app/workload-secrets",
token_endpoint="https://example.delinea.app/identity/api/oauth2/token/xpmplatform",
client_id=os.environ["WS_CLIENT_ID"],
client_secret=os.environ["WS_CLIENT_SECRET"],
)
with WorkloadSecretsClient(options) as client:
# A static secret: read its stored values.
try:
secret = client.get_secret("payments/prod/orders-db")
except NotFoundError:
raise SystemExit("no secret at that path")
password = secret.data["password"]
# A dynamic secret: mint a new credential. Each call creates another one.
credential = client.mint_secret("payments/prod/orders-db-read")
username = credential.data["username"]
db_password = credential.data["password"]
expires_at = credential.lease.expires_at # a timezone-aware datetime
secret.data holds the values as plain Python types and can't be changed. Errors from the API are raised as NotFoundError, ForbiddenError, UnauthorizedError, or ConflictError, or otherwise as WorkloadSecretsApiError, with the status in status_code and the error code in error_code. get_secret raises ConflictError for a dynamic secret, and mint_secret raises it for a secret that isn't dynamic. A call that can't complete raises WorkloadSecretsError. Error messages never include response bodies or secret values. For asyncio code, AsyncWorkloadSecretsClient offers the same calls as coroutines.
Example Applications
The SDK preview comes with example command-line applications for .NET, Go, Java and Python. Each has a tour that runs a realistic sequence of calls and cleans up after itself: it creates, reads, versions, rolls back, deletes, restores, and destroys a secret; creates a key and encrypts, decrypts, rotates, and rewraps with it; and creates, checks, and redeems a secret share. Run the tour first to check your configuration, permissions, and policies.
The preview also comes with a quick start for each of the four SDKs: one short program that creates a client, reads one secret, and uses its values.