Edge Functions

Edge functions enables you to write event enrichment and transformation logic in Javascript outside your client codebase and deployed to applications over-the-air dynamically.

Availability

Edge Functions are in Private Alpha testing and available to select customers. To opt in, contact your Customer Success Manager and ensure that you have one of Segment's new Mobile SDKs (Swift or Kotlin) configured.

Migrate from the Config API

Config API Public API
name Use the Source id (See note on names vs IDs in the migration guide)

To migrate, replace any use of the Config API endpoints with the Segment Public API counterparts, using the field mappings in the table above.

Create Edge Functions

Create EdgeFunctions for your Source given a valid upload URL for an Edge Functions bundle.

• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.

• In order to successfully call this endpoint, the specified Workspace needs to have the Edge Functions feature enabled. Please reach out to your customer success manager for more information.

Securitytoken
Request
path Parameters
sourceId
required
string [ 1 .. 255 ]
Example: qQEHquLrjRDN9j1ByrChyn
Request Body schema: application/vnd.segment.v1alpha+json
required
uploadURL
required
string (uploadURL)

The id of the Source associated with this Edge Function.

Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

post/sources/{sourceId}/edge-functions
Request samples
application/vnd.segment.v1alpha+json
{
  • "uploadURL": "<upload_url>"
}
Response samples
application/vnd.segment.v1alpha+json
{}

Disable Edge Functions

Disable Edge Functions for your Source.

• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.

• In order to successfully call this endpoint, the specified Workspace needs to have the Edge Functions feature enabled. Please reach out to your customer success manager for more information.

Securitytoken
Request
path Parameters
sourceId
required
string [ 1 .. 255 ]
Example: qQEHquLrjRDN9j1ByrChyn
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

patch/sources/{sourceId}/edge-functions/disable
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.edgeFunctions.disableEdgeFunctions('qQEHquLrjRDN9j1ByrChyn'))
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Generate Upload URL for Edge Functions

Generate a temporary upload URL that can be used to upload an Edge Functions bundle.

• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.

• In order to successfully call this endpoint, the specified Workspace needs to have the Edge Functions feature enabled. Please reach out to your customer success manager for more information.

Securitytoken
Request
path Parameters
sourceId
required
string [ 1 .. 255 ]
Example: qQEHquLrjRDN9j1ByrChyn
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

post/sources/{sourceId}/edge-functions/upload-url
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.edgeFunctions.generateUploadURLForEdgeFunctions('qQEHquLrjRDN9j1ByrChyn'))
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{
  • "data": {
    }
}

Get Latest from Edge Functions

Get the latest Edge Functions for your Source.

• This endpoint is in Alpha testing. Please submit any feedback by sending an email to friends@segment.com.

• In order to successfully call this endpoint, the specified Workspace needs to have the Edge Functions feature enabled. Please reach out to your customer success manager for more information.

Securitytoken
Request
path Parameters
sourceId
required
string [ 1 .. 255 ]
Example: qQEHquLrjRDN9j1ByrChyn
Responses
200

OK

404

Resource not found

422

Validation failure

429

Too many requests

get/sources/{sourceId}/edge-functions/latest
Request samples
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript'

const api = configureApis('/* Insert your Public API token here */')

try {
  const result = await unwrap(api.edgeFunctions.getLatestFromEdgeFunctions('qQEHquLrjRDN9j1ByrChyn'))
  console.log(JSON.stringify(result))
} catch (e) {
  console.log('ERROR:', e)
}
Response samples
application/vnd.segment.v1alpha+json
{}