Overview

Serverless functions provide a powerful way to process sync data in real-time without managing infrastructure. Instead of sending sync records to an HTTP endpoint, you can deploy serverless functions that automatically scale to handle your data processing needs.
Serverless functions sync destinations are currently in beta. Features and interfaces may be subject to change.

How It Works

When you configure a serverless function as your sync destination, Strata automatically:
  1. Deploys your function - We handle the deployment and scaling of your serverless function
  2. Routes sync records - Each sync record is automatically sent to your function for processing
  3. Manages retries - Failed function executions are automatically retried with exponential backoff
  4. Provides monitoring - Built-in observability for function performance and error tracking

Supported Runtimes

We currently support Node.js v22.x

Getting started

  1. If you haven’t already, install the Strata GitHub App in your GitHub repository.
  2. Write your serverless function using the following function signature. The function should be named handler. It should accept a single event parameter and return a response with a statusCode and a message. You do not need to provide a specific name for the file or locate it in a specific directory.
export async function handler(event) {
  // process the event
  return { statusCode: 200, message: 'Success' };
}
  1. Commit and push your function to your GitHub repository.
  2. Go into the Strata dashboard and select the file as the destination for your Sync.
  3. A build will be triggered automatically and your function will be deployed to Strata’s serverless platform.
Keep your functions lightweight and focused on a single responsibility for better performance and debugging.

TypeScript support

We recommend using TypeScript for your serverless functions. You can use the following type definitions in your function:
interface Response {
  statusCode: number;
  message: string;
}

interface Event {
  data: Record<string, any>;
  context: SyncContext;
}

interface SyncContext {
  connection: Connection;
  integrationUser: IntegrationUser;
  integration: Integration;
}

interface Connection {
  id: string;
  authType: AuthType;
  metadata: Record<string, any>;
  secrets: Record<string, any>;
  createdAt: string;
  projectId: string;
  updatedAt: string;
  integrationId: string;
  integrationUserId: string;
}

type AuthType = "OAuth2" | "ApiKey";

interface IntegrationUser {
  id: string;
  createdAt: string;
  projectId: string;
  updatedAt: string;
  externalId: string;
}

interface Integration {
  id: string;
  projectId: string;
  createdAt: string;
  updatedAt: string;
  serviceProviderId: string;
}

Error Handling

We recommend returning descriptive error messages and HTTP status codes to help with debugging. You can view execution response logs in the Strata dashboard.
export async function handler(event: Event): Promise<Response> {
  try {
    const { data, context } = event;

    if (!data.email) {
      return { statusCode: 400, message: 'Missing required field: email' };
    }

    await processData(data);
    return { statusCode: 200, message: 'Success' };

  } catch (error) {
    return { statusCode: 500, message: 'Error processing data: ' + error.toString() };
  }
}

Retry Behavior

The following results in a retry:
  • Returning a 429 or 5xx status code
  • Throwing an error
4xx errors other than 429 do not result in a retry.
Ideally, your functions should be idempotent. Records may be processed multiple times due to retries and “at least once” event delivery.