# Can I programmatically call serverless?

**URL:** <https://forum.serverless.com/t/can-i-programmatically-call-serverless/475>\
**Category:** Serverless Framework\
**Created:** [October 7, 2016, 11:06am UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475 "2016-10-07T11:06:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bencooling](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@bencooling](https://forum.serverless.com/u/bencooling)\
**Post date:** [October 7, 2016, 11:06am UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/1 "2016-10-07T11:06:18Z")

</div>

Instead of using the cli with say `serverless invoke` can I `require('serverless').invoke`?

---

<div class="post-metadata">

**Author:** ![rowanu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rowanu/32/75_2.png) [@rowanu](https://forum.serverless.com/u/rowanu)\
**Post date:** [October 8, 2016, 12:35am UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/2 "2016-10-08T00:35:10Z")

</div>

No, not at the moment. There have been other people discussing this, but it just doesn’t make sense for the project to address this use case at this point in time (while work is still in progress to v1.0).

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [October 12, 2016, 3:00pm UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/3 "2016-10-12T15:00:42Z")

</div>

As @rowanu mentioned this is currently not possible, but what would be your use case?

---

<div class="post-metadata">

**Author:** ![bencooling](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@bencooling](https://forum.serverless.com/u/bencooling)\
**Post date:** [October 12, 2016, 9:46pm UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/4 "2016-10-12T21:46:48Z")

</div>

@flomotlik For performing integration tests in CI. Currently I do:

```javascript
const { test } = require('tap');
const exec = require('child_process').exec;
... 
test('accepts request path variables', t =>
  exec('serverless invoke -f path -p events/path2.json', (e, data) => {
...

```

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [October 12, 2016, 10:27pm UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/5 "2016-10-12T22:27:53Z")

</div>

@bencooling Could you use [invoke](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property) from the AWS Javascript SDK?

---

<div class="post-metadata">

**Author:** ![bencooling](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@bencooling](https://forum.serverless.com/u/bencooling)\
**Post date:** [October 13, 2016, 2:14am UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/6 "2016-10-13T02:14:23Z")

</div>

Thanks @buggy I haven’t touched [AWS.Lambda](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html) yet, thanks for bringing the [invoke](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property) method to my attention.

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [October 13, 2016, 3:04pm UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/7 "2016-10-13T15:04:51Z")

</div>

In the future we want to provide testing libraries as well that make these things easier. Testing is a VERY important topic for us going forward. We’ve started by implementing this small mock library: [https://github.com/serverless/aws-event-mocks](https://github.com/serverless/aws-event-mocks) but there will be more

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [October 13, 2016, 3:05pm UTC](https://forum.serverless.com/t/can-i-programmatically-call-serverless/475/8 "2016-10-13T15:05:25Z")

</div>

And also we’re going to start opening issues and starting the discussion there, so checking out the issues and milestone goals we share could give you a chance to chime in there.
