Skip to main content
Every call to Infisical goes through an InfisicalSDK client. You create the client once, log it in as a machine identity, and then use it for every request.

Create a client

Create the client with the URL of your Infisical instance in siteUrl. If you use the US region of Infisical Cloud, you can leave siteUrl out.
Parameters:
object

Log in

The client logs in with one of the machine identity’s authentication methods. After the client logs in, it sends the access token it got with every request.

Universal Auth

Parameters:
UniversalAuthLoginRequest
required

AWS auth

If your application runs on AWS, it can log in through AWS Auth with the AWS credentials it already has:
The SDK gets the details it needs from the AWS environment:
  • AWS credentials: the same way the AWS SDK for JavaScript does, such as from environment variables or the IAM role of an EC2 instance or Lambda function
  • AWS region: from the AWS_REGION environment variable, or from the EC2 instance metadata if AWS_REGION isn’t set
Parameters:
object

Access token

If your application gets an access token some other way, such as from the Infisical Agent, give the token to the client:
Parameters:
string
required
The access token, without the Bearer prefix.
To read the token that the client uses, call client.auth().getAccessToken(). It returns null if the client hasn’t logged in.

Renew the access token

The SDK doesn’t renew the access token on its own. The token expires after the Access Token TTL set in the machine identity’s auth method. Each renewal extends the token by its TTL, up to the Access Token Max TTL. After the max TTL, log in again. If your application runs longer than the TTL, renew the token before it expires: