Documentation Index
Fetch the complete documentation index at: https://docs.gateways.app/llms.txt
Use this file to discover all available pages before exploring further.
Serverless Functions API
Serverless functions are AWS Lambda functions that allow users to run code without managing servers. Users can specify the runtime, architecture, and code, and the function will be deployed to AWS Lambda with an invocation endpoint.Base URL
All endpoints are prefixed with/api/:projectSlug/:environmentSlug/functions
Important Notes
-
Lambda Execution Role: A Lambda execution role must exist in the customer’s AWS account (not in the SaaS provider’s account). This role grants the Lambda function permissions to access other AWS services (e.g., CloudWatch Logs).
- Automatic Creation: The latest version of the CloudFormation template (
infrastructure/customer-connector.yaml) automatically creates theGatewaysAppLambdaExecutionRolewith the correct trust policy andAWSLambdaBasicExecutionRolemanaged policy. Simply update your CloudFormation stack to get this role created. - Trust Policy: The role’s trust policy must allow
lambda.amazonaws.comto assume the role. This is automatically configured when using the CloudFormation template. - Permissions: The role is created with
AWSLambdaBasicExecutionRolefor logging. Additional permissions can be added if your Lambda functions need access to other AWS services (e.g., S3, DynamoDB). - Default Role: If
LAMBDA_EXECUTION_ROLE_ARNis not set in your environment variables, the system will automatically usearn:aws:iam::{customerAccountId}:role/GatewaysAppLambdaExecutionRolein the customer’s account. - Account Verification: The system automatically extracts the customer’s account ID from their GatewaysAppDeployRole ARN to ensure the Lambda function is created in the correct account.
- IAM PassRole Permission: The
GatewaysAppDeployRolein the customer’s account must haveiam:PassRolepermission for the Lambda execution role. This is already included in the CloudFormation template. If you’re using a custom role ARN, ensureiam:PassRoleis granted for that role. See (../../LAMBDA-PERMISSIONS-UPDATE.md— see repository) for troubleshooting.
- Automatic Creation: The latest version of the CloudFormation template (
-
Code Packaging: The function code is packaged into a ZIP file before deployment. The file structure depends on the runtime:
- Node.js:
index.js - Python:
lambda_function.py - Java:
Handler.java - .NET:
Function.cs - Go:
main.go - Ruby:
lambda_function.rb - Custom/Unknown:
index.js
- Node.js:
-
Runtime and Architecture:
- Supported Runtimes: See Get Lambda Runtimes in the Cloud Infrastructure API for a list of available runtimes.
- Supported Architectures:
x86_64(default) andarm64.
-
Function Endpoint: After creation, Lambda functions do not automatically have a public HTTP endpoint. You would typically integrate them with AWS API Gateway for HTTP access. This API currently only supports direct invocation via the
/invokeendpoint.
Endpoints
Create Function
Create a new serverless function (AWS Lambda). Code is not required in the request: a dummy/starter file is created automatically based on the handler (multi-file structure). Add or edit files after creation via the function files API. Endpoint:POST /api/:projectSlug/:environmentSlug/functions
Authentication: Required
Request Body:
name(required): Function name. Must be a non-empty string. This name will be used directly as the AWS Lambda function name (after sanitization to meet AWS requirements: 1-64 characters, alphanumeric, hyphens, underscores). Important: Function names must be unique within your AWS account and region. If a function with the same name already exists, creation will fail.runtime(required): Lambda runtime identifier. Use the Get Lambda Runtimes endpoint to retrieve the full list of available runtimes. Common examples:- Node.js:
nodejs20.x,nodejs18.x,nodejs16.x - Python:
python3.12,python3.11,python3.9 - Java:
java21,java17,java11,java8.al2 - .NET:
dotnet8,dotnet6 - Go:
go1.x - Ruby:
ruby3.2,ruby2.7 - Custom:
provided.al2023,provided.al2Note: Only active runtimes should be used. Deprecated runtimes (marked as inactive) are not recommended for new functions.
- Node.js:
architecture(required): CPU architecture. Must be eitherx86_64orarm64. Default:x86_64handler(required): Function handler. A dummy file is created based on this (e.g.index.handler→index.jswith a stub handler). Format depends on runtime:- Node.js:
index.handler(file.exportedFunction) - Python:
lambda_function.lambda_handler(file.function) - Java:
com.example.Handler::handleRequest(package.class::method) - .NET:
MyFunction::MyFunction.Function::FunctionHandler(assembly::namespace.class::method) - Go:
main(package)
- Node.js:
region(required): AWS region where the function will be deployed (e.g.,us-east-1,eu-west-1)description(optional): Function descriptionenvironmentVariables(optional): JSON object of key-value environment variables (e.g.,{"NODE_ENV":"production","API_URL":"https://api.example.com"}). Stored in metadata and injected into the Lambda function at runtime.environmentVariablesLocked(optional): Array of keys for which values should be masked when fetching (e.g.,["API_KEY"]). Locked keys keep their values but are not returned in API responses.positionX(optional): Canvas X coordinate for draggable cardspositionY(optional): Canvas Y coordinate for draggable cards
201 Created
- No code in request: Create does not accept
codein the body. A dummy/starter file is created automatically from the handler (e.g.index.handler→index.jswith a stub). Use the function files API to add or edit files after creation. - A Function URL is automatically created when the function is created
- The Function URL provides a dedicated HTTPS endpoint for your Lambda function
- The endpoint is publicly accessible (AuthType: NONE) by default
- CORS is configured to allow all origins, methods, and headers
- The endpoint will be available in the
endpointfield once the function is created - If Function URL creation fails, the function will still be created (endpoint will be
null)
- Is publicly accessible by default (no authentication required)
- Supports CORS (configured to allow all origins)
- Provides a stable HTTPS endpoint for your function
- Can be used for webhooks, APIs, or direct HTTP invocations
400 Bad Request: Invalid request body or missing required fields401 Unauthorized: Missing or invalid authentication token403 Forbidden: Access denied404 Not Found: Project or environment not found500 Internal Server Error: Failed to create function in AWS
endpoint field will be null. You can manually create a Function URL later via the AWS Console.
List Functions
List all functions in a project environment. Endpoint:GET /api/:projectSlug/:environmentSlug/functions
Authentication: Required
Response: 200 OK
401 Unauthorized: Missing or invalid authentication token404 Not Found: Project or environment not found
Get Function
Get details of a specific function. Endpoint:GET /api/:projectSlug/:environmentSlug/functions/:id
Authentication: Required
Response: 200 OK
400 Bad Request: Invalid function ID401 Unauthorized: Missing or invalid authentication token404 Not Found: Function not found
Update Function
Update a function’s handler, architecture, position, memory, timeout, or ephemeral storage. Code is updated via the function files API, not this endpoint. Endpoint:PUT /api/:projectSlug/:environmentSlug/functions/:id
Authentication: Required
Request Body:
handler(optional): Updated function handlerarchitecture(optional): CPU architecture. AWS Lambda / GCP / Azure:x86_64orarm64memorySize(optional): Memory allocation in MB. AWS Lambda: 128–10240. GCP Cloud Functions: up to 8192 (1st gen) or 32768 (2nd gen). Azure Functions: depends on plan (e.g. Consumption 1.5 GB default).timeout(optional): Max execution time in seconds. AWS Lambda: 1–900 (15 min). GCP Cloud Functions: 1–540 (9 min, 1st gen). Azure Functions: up to 600 (10 min) on Consumption; higher on Premium/Dedicated.ephemeralStorage(optional): Ephemeral storage (/tmp) size in MB. AWS Lambda only: 512–10240; ignored for GCP and Azure.positionX(optional): Updated X coordinatepositionY(optional): Updated Y coordinate
200 OK
400 Bad Request: Invalid request body401 Unauthorized: Missing or invalid authentication token404 Not Found: Function not found500 Internal Server Error: Failed to update function in AWS
Sync Function Status from Cloud Provider
Note: Function sync is now performed through the unified resources API. Use the unified sync endpoint instead of the type-specific endpoint. Unified Sync Endpoint:PUT /api/:projectSlug/:environmentSlug/resources/:resourceId/sync
See Resources API — Sync Resource from Cloud Provider for details.
Sync/refresh function data from the cloud provider (AWS Lambda, GCP Cloud Functions, or Azure Functions) and update the function record.
Description:
- Fetches the latest function details from the cloud provider
- Updates the function record with current status, runtime, architecture, handler, memory, timeout, and configuration
- Handles deleted functions (updates status to ‘Failed’ if not found in the cloud provider)
- Fetches the latest function details from the cloud provider
- Updates the function record with current status, runtime, architecture, handler, memory, and timeout
- Updates environment variables and tags if they have changed
- Handles deleted functions (updates status to ‘Failed’ if not found in the cloud provider)
Delete Function
Function (resource) deletion is performed only via the unified resources API:DELETE /api/:projectSlug/:environmentSlug/resources/:resourceId
Upload Function ZIP
Upload a ZIP file containing function code. The ZIP replaces all existing files in the function. Supports multiple files (e.g.,index.js, utils/helper.js).
Endpoint: POST /api/:projectSlug/:environmentSlug/functions/:id/upload
Authentication: Required
Request: multipart/form-data with field file (ZIP file)
Example Request:
- The ZIP replaces all existing files in the function
- Supported for AWS Lambda, GCP Cloud Functions, and Azure Functions
- Only text/code files (e.g., .js, .py, .ts) are included; binary files (images, fonts) are skipped
- File paths must not contain
.., absolute paths, or Windows-style paths - The function is automatically redeployed to the cloud provider after upload
400 Bad Request: No file provided, invalid ZIP, or no text/code files found401 Unauthorized: Missing or invalid authentication token404 Not Found: Function not found500 Internal Server Error: Failed to upload or redeploy
Function Code Examples
Node.js Example
Handler:index.handler
Code:
Python Example
Handler:lambda_function.lambda_handler
Code:
Java Example
Handler:com.example.Handler::handleRequest
Code:
Function Status
Functions can have the following statuses:creating: Function is being created in AWSactive: Function is active and ready to invokeinactive: Function is inactiveupdating: Function code or configuration is being updatedfailed: Function creation or update failed
Architecture Options
- x86_64: Intel/AMD 64-bit architecture (default, wider compatibility)
- arm64: ARM 64-bit architecture (better price/performance, lower cost)
Runtime Compatibility
For the most up-to-date list of available runtimes, use the Get Lambda Runtimes endpoint. This returns all supported runtimes from the metadata table, including their status (active/inactive) and configuration details. Common Supported Runtimes:| Runtime | x86_64 | arm64 | Status | Notes |
|---|---|---|---|---|
| nodejs20.x | ✅ | ✅ | Active | Latest Node.js |
| nodejs18.x | ✅ | ✅ | Active | LTS |
| python3.12 | ✅ | ✅ | Active | Latest Python |
| python3.11 | ✅ | ✅ | Active | |
| java21 | ✅ | ✅ | Active | Latest Java |
| java17 | ✅ | ✅ | Active | LTS |
| java11 | ✅ | ✅ | Active | |
| dotnet8 | ✅ | ✅ | Active | Latest .NET |
| dotnet6 | ✅ | ✅ | Active | |
| go1.x | ✅ | ✅ | Active | Go 1.x |
| ruby3.2 | ✅ | ✅ | Active | Ruby 3.2 |
| ruby2.7 | ✅ | ✅ | Active | |
| provided.al2023 | ✅ | ✅ | Active | Custom runtime (AL2023) |
| provided.al2 | ✅ | ✅ | Active | Custom runtime (AL2) |
| nodejs16.x | ✅ | ✅ | Inactive | Deprecated |
| python3.9 | ✅ | ✅ | Inactive | Deprecated |
| java8.al2 | ✅ | ✅ | Inactive | Deprecated |
Integration with Resources API
Functions are included in the unified resources API:- List all resources:
GET /api/:projectSlug/:environmentSlug/resources?type=all - List functions only:
GET /api/:projectSlug/:environmentSlug/resources?type=function - Get function details:
GET /api/:projectSlug/:environmentSlug/resources/function/:functionId
Resource Connections
Functions can be connected to other resources using the resource connections API. See the Resource Connections API documentation for details.AWS Lambda Configuration
When a function is created, the following AWS Lambda configurations are applied:- Runtime: User-specified runtime (e.g., nodejs20.x, python3.12)
- Architecture: User-specified architecture (x86_64 or arm64)
- Handler: User-specified handler (e.g., index.handler)
- Timeout: 30 seconds (default, can be updated via the API)
- Memory: 128 MB (default, can be updated via the API)
- Execution Role: The Lambda execution role must exist in the customer’s AWS account. The system uses:
- The role specified in
LAMBDA_EXECUTION_ROLE_ARNenvironment variable (if set), or - The default role
arn:aws:iam::{customerAccountId}:role/GatewaysAppLambdaExecutionRolein the customer’s account - The customer’s account ID is automatically extracted from their GatewaysAppDeployRole ARN
- The role specified in
- Timeout and memory can be updated via the API’s update endpoint or AWS Console/CLI.
- The execution role must be created in the customer’s AWS account before creating Lambda functions.
- The role must have a trust policy allowing
lambda.amazonaws.comto assume it. - The
GatewaysAppDeployRolemust haveiam:PassRolepermission for the Lambda execution role (already included in the CloudFormation template). See (../../LAMBDA-PERMISSIONS-UPDATE.md— see repository) for details.
Best Practices
-
Handler Naming:
- Use descriptive handler names that match your code structure
- Follow runtime-specific conventions (e.g.,
file.exportedFunctionfor Node.js)
-
Code Structure:
- Keep functions focused on a single task
- Handle errors appropriately
- Return consistent response formats
-
Performance:
- Use ARM64 architecture for better price-performance
- Optimize code for cold starts
- Consider using Lambda layers for shared code
-
Security:
- Never commit sensitive data in function code
- Use environment variables or AWS Secrets Manager for credentials
- Follow the principle of least privilege for execution roles
-
Monitoring:
- Monitor function invocations via AWS CloudWatch
- Set up alarms for errors and latency
- Review function logs regularly
Limitations
- Maximum function code size: 50 MB (zipped)
- Maximum deployment package size: 250 MB (unzipped)
- Maximum function timeout: 900 seconds (15 minutes)
- Maximum memory: 10,240 MB
- Maximum ephemeral storage: 10,240 MB
- Lambda layers for shared code
- Container images for very large dependencies
- S3 for code storage (not currently supported via API)
Error Handling
Functions should return appropriate status codes and error messages. Example error response:Troubleshooting
Function not invoking:- Check that the function status is
active - Verify the handler name matches your code structure
- Check AWS CloudWatch Logs for error messages
- Increase timeout via AWS Console (max 15 minutes)
- Optimize code performance
- Check for external dependencies causing delays
- Wait a few moments for deployment to complete
- Check function status - it should show
activeafter update - Verify the code was updated in the database
- Check function logs in AWS CloudWatch
- Verify the payload format matches what your function expects
- Ensure the function has proper error handling
- The Lambda execution role does not exist: Create the
GatewaysAppLambdaExecutionRolein the customer’s AWS account. See (../../LAMBDA-PERMISSIONS-UPDATE.md#creating-the-lambda-execution-role— see repository) for detailed instructions. - The role exists but has incorrect trust policy: Ensure the role’s trust policy allows
lambda.amazonaws.comto assume it: - Wrong role name: If you’re using a custom role ARN via
LAMBDA_EXECUTION_ROLE_ARNenvironment variable, verify the role exists and has the correct trust policy.
- The
GatewaysAppDeployRoleis missingiam:PassRolepermission for the Lambda execution role. Update the CloudFormation stack or manually add the permission. See (../../LAMBDA-PERMISSIONS-UPDATE.md— see repository) for details.