Jump to Content

New API Documentation - Developer Preview Available

We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.

Class InvokeCommandProtected

Invokes a Lambda function. You can invoke a function synchronously (and wait for the response), or asynchronously. To invoke a function asynchronously, set InvocationType to Event.

For synchronous invocation, details about the function response, including errors, are included in the response body and headers. For either invocation type, you can find more information in the execution log and trace.

When an error occurs, your function may be invoked multiple times. Retry behavior varies by error type, client, event source, and invocation type. For example, if you invoke a function asynchronously and it returns an error, Lambda executes the function up to two more times. For more information, see Error handling and automatic retries in Lambda.

For asynchronous invocation, Lambda adds events to a queue before sending them to your function. If your function does not have enough capacity to keep up with the queue, events may be lost. Occasionally, your function may receive the same event multiple times, even if no error occurs. To retain events that were not processed, configure your function with a dead-letter queue.

The status code in the API response doesn't reflect function errors. Error codes are reserved for errors that prevent your function from executing, such as permissions errors, quota errors, or issues with your function's code and configuration. For example, Lambda returns TooManyRequestsException if running the function would cause you to exceed a concurrency limit at either the account level (ConcurrentInvocationLimitExceeded) or function level (ReservedFunctionConcurrentInvocationLimitExceeded).

For functions with a long timeout, your client might disconnect during synchronous invocation while it waits for a response. Configure your HTTP client, SDK, firewall, proxy, or operating system to allow for long connections with timeout or keep-alive settings.

This operation requires permission for the lambda:InvokeFunction action. For details on how to set up permissions for cross-account invocations, see Granting function access to other accounts.


Use a bare-bones client and the command you need to make an API call.

import { LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda"; // ES Modules import
// const { LambdaClient, InvokeCommand } = require("@aws-sdk/client-lambda"); // CommonJS import
const client = new LambdaClient(config);
const input = { // InvocationRequest
FunctionName: "STRING_VALUE", // required
InvocationType: "Event" || "RequestResponse" || "DryRun",
LogType: "None" || "Tail",
ClientContext: "STRING_VALUE",
Payload: "BLOB_VALUE",
Qualifier: "STRING_VALUE",
const command = new InvokeCommand(input);
const response = await client.send(command);
// { // InvocationResponse
// StatusCode: Number("int"),
// FunctionError: "STRING_VALUE",
// LogResult: "STRING_VALUE",
// Payload: "BLOB_VALUE",
// ExecutedVersion: "STRING_VALUE",
// };







EC2AccessDeniedException (server fault)

Need additional permissions to configure VPC settings.


EC2ThrottledException (server fault)

Amazon EC2 throttled Lambda during Lambda function initialization using the execution role provided for the function.


EC2UnexpectedException (server fault)

Lambda received an unexpected Amazon EC2 client exception while setting up for the Lambda function.


EFSIOException (client fault)

An error occurred when reading from or writing to a connected file system.


EFSMountConnectivityException (client fault)

The Lambda function couldn't make a network connection to the configured file system.


EFSMountFailureException (client fault)

The Lambda function couldn't mount the configured file system due to a permission or configuration issue.


EFSMountTimeoutException (client fault)

The Lambda function made a network connection to the configured file system, but the mount operation timed out.


ENILimitReachedException (server fault)

Lambda couldn't create an elastic network interface in the VPC, specified as part of Lambda function configuration, because the limit for network interfaces has been reached. For more information, see Lambda quotas.


InvalidParameterValueException (client fault)

One of the parameters in the request is not valid.


InvalidRequestContentException (client fault)

The request body could not be parsed as JSON.


InvalidRuntimeException (server fault)

The runtime or runtime version specified is not supported.


InvalidSecurityGroupIDException (server fault)

The security group ID provided in the Lambda function VPC configuration is not valid.


InvalidSubnetIDException (server fault)

The subnet ID provided in the Lambda function VPC configuration is not valid.


InvalidZipFileException (server fault)

Lambda could not unzip the deployment package.


KMSAccessDeniedException (server fault)

Lambda couldn't decrypt the environment variables because KMS access was denied. Check the Lambda function's KMS permissions.


KMSDisabledException (server fault)

Lambda couldn't decrypt the environment variables because the KMS key used is disabled. Check the Lambda function's KMS key settings.


KMSInvalidStateException (server fault)

Lambda couldn't decrypt the environment variables because the state of the KMS key used is not valid for Decrypt. Check the function's KMS key settings.


KMSNotFoundException (server fault)

Lambda couldn't decrypt the environment variables because the KMS key was not found. Check the function's KMS key settings.


RequestTooLargeException (client fault)

The request payload exceeded the Invoke request body JSON input quota. For more information, see Lambda quotas.


ResourceConflictException (client fault)

The resource already exists, or another operation is in progress.


ResourceNotFoundException (client fault)

The resource specified in the request does not exist.


ResourceNotReadyException (server fault)

The function is inactive and its VPC connection is no longer available. Wait for the VPC connection to reestablish and try again.


ServiceException (server fault)

The Lambda service encountered an internal error.


SnapStartException (client fault)

The afterRestore() runtime hook encountered an error. For more information, check the Amazon CloudWatch logs.


SnapStartNotReadyException (client fault)

Lambda is initializing your function. You can invoke the function when the function state becomes Active.


SnapStartTimeoutException (client fault)

Lambda couldn't restore the snapshot within the timeout limit.


SubnetIPAddressLimitReachedException (server fault)

Lambda couldn't set up VPC access for the Lambda function because one or more configured subnets has no available IP addresses.


TooManyRequestsException (client fault)

The request throughput limit was exceeded. For more information, see Lambda quotas.


UnsupportedMediaTypeException (client fault)

The content type of the Invoke request body is not JSON.



Base exception class for all service exceptions from Lambda service.




middlewareStack: MiddlewareStack<InvokeCommandInput, InvokeCommandOutput>