Updated July 5, 2022
Functions is a compute service that lets you run code without provisioning or managing servers. With Functions, Stedi runs your code on high-availability compute infrastructure that automatically scales up and down according to your usage. You can run code for virtually any type of integration or other standalone backend service – all you need to do is supply your code in one of the languages that Functions supports.
Stedi runs your function only when needed and scales automatically, from a few requests per day to up to 50 concurrently by default. You pay only for the compute time that you consume — there is no charge to create functions, and there is no charge when your code isn't running.
You can invoke your functions using the Functions API, or run a function in response to events from other Stedi products. For example, you can use Functions to:
- automatically process EDI files received via SFTP by sending them to the EDI Core API.
- send translated payloads to external API endpoints.
- call the Converter API to convert XML to JSON, and then transform the output using the Mappings API.
- or do something completely unrelated to your other Stedi workflows!
Here’s what you can do with Functions.
- Execute code in a hosted environment.
- Run code in response to supported events from other Stedi products.
- Use third-party libraries.
- Call out to any external web API.
You can create, update, and invoke functions with the Functions API or the web UI. The API is more flexible and gives you access to every feature, but you need to set up deployment for your functions. The web UI gets you up and running quickly, but it doesn’t support third-party libraries and it makes it hard to put your code under version control. We recommend you use the web UI to experiment with Functions and the API for production-level usage.
Let's say that you receive EDI 850 purchase orders from your trading partner. The trading partner delivers these files to you via Stedi SFTP and you need to transform it somehow into an XML document for your ERP.
Using Stedi Functions, you can convert the EDI file to JEDI (JSON EDI). Next, you can transform the JEDI into a desired JSON format an conver the document to XML. Finally, the XML document is posted to an external webhook of the ERP.
You could use variations of this pattern to convert documents between other file formats and extend the function further with additional features.
You can find instructions how to deploy your first Stedi Function in this tutorial. We also encourage to take a look at the other Stedi tutorials.
There are some restrictions you should keep in mind.
- The name of a function can be up to 64 characters long and can only contain characters that are valid in a URL.
- The maximum invocation time of a function is 29 seconds.
- When a function makes requests to a web API, or calls other functions, all those requests and calls combined must finish within 29 seconds.
- Functions that require packages and other assets can only be deployed as a single zip archive. The overall size of the zip file is limited to 3 MB, and zip files can only be uploaded via API (the web UI only supports self-contained code).
- The response time of a function can vary from about 10 ms to more than a second, due to cold starts.
You can find the API specifications here.
There are charges for invoking a function and for the amount of time that the function runs. There is no additional charge for creating functions. For more information, see the pricing page.