Installation
Getting Started
The easiest way to get started is to use the builder pattern for both the client and your requests.Client Configuration
TheClient::builder()
provides several configuration options:
.base_url(url)
: Optional method to set the Infisical instance URL. Defaults tohttps://app.infisical.com
for Infisical Cloud. Usehttps://eu.infisical.com
for EU andhttp://localhost:8080
for local development.
Core Methods
The SDK methods are organized into the following high-level categories:Client::builder()
: The main entry point for creating a client.client.login()
: Allows client to make authenticated requests to the API.client.secrets()
: Provides access to all CRUD operations for secrets.client.kms()
: Provides access to all KMS (Key Management Service) operations.
Helper Functions
The SDK provides utility functions for common operations:encode_base64(data: &str) -> String
: Encodes a string as base64decode_base64(data: &str) -> Result<String, InfisicalError>
: Decodes a base64 string
secrets
All secret operations are accessed via client.secrets()
. Each operation has a dedicated request builder.
Create Secret
Create a new secret in your project. Examplesecret_name
,secret_value
,project_id
,environment
: Required parameters passed to thebuilder()
function..path(path)
: Optional method to set the secret’s path (defaults to/
)..secret_comment(comment)
: Optional method to add a comment..skip_multiline_encoding(bool)
: Optional method to control multiline encoding (defaults tofalse
)..r#type(type)
: Optional method to set the secret type (shared
orpersonal
), defaults toshared
.
Get Secret
Retrieve a specific secret by name. Examplesecret_name
,project_id
,environment
: Required parameters passed to thebuilder()
function..path(path)
: Optional method to set the secret’s path (defaults to/
)..expand_secret_references(bool)
: Optional method to control secret reference expansion (defaults totrue
)..r#type(type)
: Optional method to set the secret type (shared
orpersonal
), defaults toshared
.
List Secrets
List all secrets in a project and environment. Exampleproject_id
,environment
: Required parameters passed to thebuilder()
function..path(path)
: Optional method to set the path from which to list secrets (defaults to/
)..expand_secret_references(bool)
: Optional method to control secret reference expansion (defaults totrue
)..recursive(bool)
: Optional method to recursively list secrets from sub-folders (defaults tofalse
)..attach_to_process_env(bool)
: Optional method to attach fetched secrets to the current process’s environment variables (defaults tofalse
).
Update Secret
Update an existing secret. Examplesecret_name
,project_id
,environment
: Required parameters passed to thebuilder()
function..new_secret_name(name)
: Optional method to rename the secret..secret_value(value)
: Optional method to set a new value for the secret..path(path)
: Optional method to set the secret’s path..secret_comment(comment)
: Optional method to add or change the comment..skip_multiline_encoding(bool)
: Optional method to control multiline encoding..r#type(type)
: Optional method to set the secret type (shared
orpersonal
).
Delete Secret
Delete a secret from your project. Examplesecret_name
,project_id
,environment
: Required parameters passed to thebuilder()
function..path(path)
: Optional method to set the secret’s path (defaults to/
)..r#type(type)
: Optional method to set the secret type (shared
orpersonal
), defaults toshared
.
kms
All KMS (Key Management Service) operations are accessed via client.kms()
. Each operation has a dedicated request builder.
List KMS Keys
List all KMS keys in a project. Exampleproject_id
: Required parameter passed to thebuilder()
function.
Get KMS Key
Retrieve a specific KMS key by ID. Examplekey_id
: Required parameter passed to thebuilder()
function.
Get KMS Key by Name
Retrieve a specific KMS key by name. Examplekey_name
: Required parameter passed to thebuilder()
function.
Create KMS Key
Create a new KMS key in your project. Exampleproject_id
,name
: Required parameters passed to thebuilder()
function..description(description)
: Optional method to set the key description..key_usage(usage)
: Optional method to set the key usage using theKeyUsage
enum (defaults toKeyUsage::EncryptDecrypt
)..encryption_algorithm(algorithm)
: Optional method to set the encryption algorithm using theEncryptionAlgorithm
enum (defaults toEncryptionAlgorithm::Aes256Gcm
).
Update KMS Key
Update an existing KMS key. Examplekey_id
: Required parameter passed to thebuilder()
function..name(name)
: Optional method to rename the key..description(description)
: Optional method to update the key description..is_disabled(disabled)
: Optional method to enable or disable the key.
Delete KMS Key
Delete a KMS key from your project. Examplekey_id
: Required parameter passed to thebuilder()
function.
Encrypt Data
Encrypt data using a KMS key. Examplekey_id
,plaintext
: Required parameters passed to thebuilder()
function.
Decrypt Data
Decrypt data using a KMS key. Examplekey_id
,ciphertext
: Required parameters passed to thebuilder()
function.
Sign Data
Sign data using a KMS key. Examplekey_id
,data
: Required parameters passed to thebuilder()
function..signing_algorithm(algorithm)
: Optional method to set the signing algorithm using theSigningAlgorithm
enum (defaults toSigningAlgorithm::RsassaPkcs1V15Sha256
)..is_digest(is_digest)
: Optional method to indicate if the data is a digest (defaults tofalse
).
Verify Signature
Verify a signature using a KMS key. Examplekey_id
,data
,signature
: Required parameters passed to thebuilder()
function..signing_algorithm(algorithm)
: Optional method to set the signing algorithm using theSigningAlgorithm
enum (defaults toSigningAlgorithm::RsassaPkcs1V15Sha256
)..is_digest(is_digest)
: Optional method to indicate if the data is a digest (defaults tofalse
).
Get Public Key
Get the public key for a KMS key. Examplekey_id
: The ID of the key to get the public key for.
Get Signing Algorithms
Get the available signing algorithms for a KMS key. Examplekey_id
: The ID of the key to get signing algorithms for.
Development and Testing
Environment Setup
For development and testing, you’ll need to set up environment variables. Create a.env
file in your project root:
Getting Credentials
To obtain the required credentials:- Client ID and Secret: Create a Universal Auth machine identity in your Infisical project settings
- Project ID: Found in your project settings or URL when viewing a project in the Infisical dashboard
Running Tests
Tests that require authentication are marked with#[ignore]
and need valid credentials: