Functions Classic
Version Note: This page covers the Functions Classic product; for the current generation of Functions please visit the latest version of the Functions documentation.
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.
How can Functions be used?
- automatically process EDI files received via SFTP by sending them to the EDI Translate API.
- send translated payloads to external API endpoints.
- call the EDI Translate API to translate EDI to JSON, and then transform the output using the Mappings API.
- or do something completely unrelated to your other Stedi workflows!
Features
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.
A real-world example
Using Stedi Functions, you can convert the EDI file to JSON. Next, you can transform the JSON into the desired JSON schema and convert 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.
Supported languages
- JavaScript (or any other language that compiles to JavaScript, like TypeScript).
Choosing a module system
Version Note: You can only choose a module system for the functions labeledNew (v2)
in the Functions UI.
Functions support both CommonJS (CJS) and ECMAScript (ESM) modules. Stedi infers the module system from the file extension: .js for CJS and .mjs for ESM.
You cannot change the module system if your function package contains multiple files (usually the case if it's been bundled). Changing a function module system impacts how the function behaves, so ensure the function's code is compatible with the selected module system before updating it.
Limitations
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 execution time of a function is 15 minutes. Your function is deployed with a 3-second timeout by default, which you can increase using the API.
- 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.25 MB, and zip files can only be uploaded via API. Our web UI only supports self-contained code consisting of a single source code file.
- When a function has not run for a while, or when a large burst of requests arrives, the initial invocation(s) of a function may take a few seconds longer than normal. After such a "cold start" the function will be "warm" and its latency will settle down to just the execution time of your own code.
API documentation
Feedback
Have an idea for something we could improve? Page not clear? We love feedback - send us a message.