Invokes a deployed Function. It allows you to send event data to the Function and returns the response.
serverless invoke --function functionName
--function
or-f
The name of the function in your service that you want to invoke. Required.--stage
or-s
The stage in your service that you want to deploy to. The default stage is 'dev'.--profile
or-p
The Auth0 Webtasks profile to use when deploying your service. The 'serverless' profile is used by default.--data
or-d
String data to be passed as an event to your function. By default data is read from standard input.--path
or-p
The path to a JSON file with input data to be passed to the invoked function. This path is relative to the root directory of the service.
invoke:invoke
serverless invoke --function main
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP POST request by default. The command will return the HTTP status code and body of the response.
serverless invoke --function main --data '{"message":"Serverless + Webtasks!"}'
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP POST and a request body that includes the JSON payload: {"message":"Serverless + Webtasks!"}
.
serverless invoke --function main --data '{"method":"GET", "body":{"message":"Serverless + Webtasks!"}}'
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP GET request and a request body that includes the JSON payload: {"message":"Serverless + Webtasks!"}
.
serverless invoke --function main --data '{"query":{"message":"Serverless + Webtasks!"}}'
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP POST request and a request query string: ?message=Serverless%20%2B%20Webtasks!
.