The Event Gateway has two APIs: the Configuration API for registering functions and subscriptions, and the runtime Events API for sending events into the Event Gateway. This document contains the API documentation for both Events and Configuration APIs. You can also find links to OpenAPI specs for these APIs.
The Event Gateway exposes an API for emitting events. By default Events API runs on :4000
port.
All data that passes through the Event Gateway is formatted as a CloudEvent, based on CloudEvents v0.1 schema.
Example:
{
"eventType": "myapp.user.created",
"eventID": "66dfc31d-6844-42fd-b1a7-a489a49f65f3",
"cloudEventsVersion": "0.1",
"source": "https://serverless.com/event-gateway/#transformationVersion=0.1",
"eventTime": "1990-12-31T23:59:60Z",
"data": { "foo": "bar" },
"contentType": "application/json"
}
Creating a subscription requires path
(default: /
), method
(default: POST
) and eventType
. path
indicates path under which you can send the event.
Endpoint
POST <Events API URL>/<Subscription Path>
Request
CloudEvents payload
Response
Status code:
202 Accepted
- this status code is returned if there is nosync
subscription defined. Otherwise, status code is controlled by function synchronously subscribed on this endpoint.
Not all data are events that's why Event Gateway has a special, built-in http.request
event type that enables subscribing to
raw HTTP requests. It's especially helpful for building REST APIs or supporting legacy payloads. http.request
event is a
CloudEvent created by Event Gateway where data
field has the following structure:
path
-string
- request pathmethod
-string
- request methodheaders
-object
- request headershost
-string
- request hostquery
-object
- query parametersparams
-object
- matched path parametersbody
- depends onContent-Type
header - request payload
By default cross-origin resource sharing (CORS) is disabled. CORS is configured per-method/path basis using CORS Configuration API.
Event Gateway handles preflight OPTIONS
requests for you. You don't need to setup subscription for OPTIONS
method
because the Event Gateway will respond with all appropriate headers.
Legacy mode is deprecated and will be removed in upcoming releases.
In legacy mode, Event Gateway is able to recognize event type based on Event
header. If the event is not formatted according to CloudEvents specification Event Gateway looks for this header and creates CloudEvent internally. In this case, whole request body is put into data
field.
The MIME type of the data block can be specified using the Content-Type
header (by default it's
application/octet-stream
). This allows the Event Gateway to understand how to deserialize the data block if it needs
to. In case of application/json
type the Event Gateway passes JSON payload to the target functions. In any other case
the data block is base64 encoded.
The Event Gateway exposes a RESTful JSON configuration API. By default Configuration API runs on :4001
port.
Endpoint
POST <Configuration API URL>/v1/spaces/<space>/eventtypes
Request
JSON object:
name
-string
- required, event type nameauthorizerId
-string
- authorizer function IDmetadata
-object
- arbitrary metadata
Response
Status code:
201 Created
on success400 Bad Request
on validation error409 Conflict
if event type already exists
JSON object:
space
-string
- space namename
-string
- event type nameauthorizerId
-string
- authorizer function IDmetadata
-object
- arbitrary metadata
Endpoint
PUT <Configuration API URL>/v1/spaces/<space>/eventtypes/<event type name>
Request
JSON object:
authorizerId
-string
- authorizer function IDmetadata
-object
- arbitrary metadata
Response
Status code:
200 OK
on success400 Bad Request
on validation error or if the authorizer function doesn't exist404 Not Found
if event type doesn't exist
JSON object:
space
-string
- space namename
-string
- event type nameauthorizerId
-string
- authorizer function IDmetadata
-object
- arbitrary metadata
Delete event type. This operation fails if there is at least one subscription using the event type.
Endpoint
DELETE <Configuration API URL>/v1/spaces/<space>/eventtypes/<event type name>
Response
Status code:
204 No Content
on success400 Bad Request
if there are subscriptions using the event type404 Not Found
if event type doesn't exist
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/eventtypes
Query Parameters
Endpoint allows filtering list of returned object with filters passed as query parameters. Currently, filters can only use metadata properties e.g. metadata.service=usersService
.
Response
Status code:
200 OK
on success
JSON object:
eventTypes
-array
ofobject
- event types:space
-string
- space namename
-string
- event type nameauthorizerId
-string
- authorizer function IDmetadata
-object
- arbitrary metadata
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/eventtypes/<event type name>
Response
Status code:
200 OK
on success404 Not Found
if event type doesn't exist
JSON object:
space
-string
- space namename
-string
- event type nameauthorizerId
-string
- authorizer function IDmetadata
-object
- arbitrary metadata
Endpoint
POST <Configuration API URL>/v1/spaces/<space>/functions
Request
JSON object:
functionId
-string
- required, function IDtype
-string
- required, provider type:awslambda
orhttp
provider
-object
- required, provider specific information about a function, depends on type:- for AWS Lambda:
arn
-string
- required, AWS ARN identifierregion
-string
- required, region nameawsAccessKeyId
-string
- optional, AWS API key ID. By default credentials from the environment are used.awsSecretAccessKey
-string
- optional, AWS API access key. By default credentials from the environment are used.awsSessionToken
-string
- optional, AWS session token
- for HTTP function:
url
-string
- required, the URL of an http or https remote endpoint
- for AWS Kinesis connector:
streamName
-string
- required, AWS Kinesis Stream Nameregion
-string
- required, region nameawsAccessKeyId
-string
- optional, AWS API key ID. By default credentials from the environment are used.awsSecretAccessKey
-string
- optional, AWS API access key. By default credentials from the environment are used.awsSessionToken
-string
- optional, AWS session token
- for AWS Firehose connector:
deliveryStreamName
-string
- required, AWS Firehose Delivery Stream Nameregion
-string
- required, region nameawsAccessKeyId
-string
- optional, AWS API key ID. By default credentials from the environment are used.awsSecretAccessKey
-string
- optional, AWS API access key. By default credentials from the environment are used.awsSessionToken
-string
- optional, AWS session token
- for AWS SQS connector:
queueUrl
-string
- required, AWS SQS Queue URLregion
-string
- required, region nameawsAccessKeyId
-string
- optional, AWS API key ID. By default credentials from the environment are used.awsSecretAccessKey
-string
- optional, AWS API access key. By default credentials from the environment are used.awsSessionToken
-string
- optional, AWS session token
- for AWS Lambda:
metadata
-object
- arbitrary metadata
Response
Status code:
201 Created
on success400 Bad Request
on validation error409 Conflict
if function already exists
JSON object:
space
-string
- space namefunctionId
-string
- function IDprovider
-object
- provider specific information about a functionmetadata
-object
- arbitrary metadata
Endpoint
PUT <Configuration API URL>/v1/spaces/<space>/functions/<function ID>
Request
JSON object:
type
-string
- required, provider type:awslambda
orhttp
provider
-object
- required, provider specific information about a function, depends on type:- for AWS Lambda:
arn
-string
- required, AWS ARN identifierregion
-string
- required, region nameawsAccessKeyId
-string
- optional, AWS API key IDawsSecretAccessKey
-string
- optional, AWS API keyawsSessionToken
-string
- optional, AWS session token
- for HTTP function:
url
-string
- required, the URL of an http or https remote endpoint
- for AWS Lambda:
metadata
-object
- arbitrary metadata
Response
Status code:
200 OK
on success400 Bad Request
on validation error404 Not Found
if function doesn't exist
JSON object:
space
-string
- space namefunctionId
-string
- function IDprovider
-object
- provider specific information about a functionmetadata
-object
- arbitrary metadata
Delete all types of functions. This operation fails if the function is currently in-use by a subscription.
Endpoint
DELETE <Configuration API URL>/v1/spaces/<space>/functions/<function ID>
Response
Status code:
204 No Content
on success404 Not Found
if function doesn't exist
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/functions
Query Parameters
Endpoint allows filtering list of returned object with filters passed as query parameters. Currently, filters can only use metadata properties e.g. metadata.service=usersService
.
Response
Status code:
200 OK
on success
JSON object:
functions
-array
ofobject
- functions:space
-string
- space namefunctionId
-string
- function IDprovider
-object
- provider specific information about a functionmetadata
-object
- arbitrary metadata
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/functions/<function ID>
Response
Status code:
200 OK
on success404 Not Found
if function doesn't exist
JSON object:
space
-string
- space namefunctionId
-string
- function IDprovider
-object
- provider specific information about a functionmetadata
-object
- arbitrary metadata
Endpoint
POST <Configuration API URL>/v1/spaces/<space>/subscriptions
Request
type
-string
- subscription type,sync
orasync
eventType
-string
- event typefunctionId
-string
- ID of function to receive eventspath
-string
- optional, URL path under which events (HTTP requests) are accepted, default:/
method
-string
- optional, HTTP method that accepts requests, default:POST
metadata
-object
- arbitrary metadata
Response
Status code:
201 Created
on success400 Bad Request
on validation error409 Conflict
if subscription already exists
JSON object:
space
-string
- space namesubscriptionId
-string
- subscription IDtype
-string
- subscription typeeventType
-string
- event typefunctionId
- function IDmethod
-string
- HTTP method that accepts requestspath
-string
- path that accepts requests, starts with/
metadata
-object
- arbitrary metadata
Endpoint
PUT <Configuration API URL>/v1/spaces/<space>/subscriptions/<subscription ID>
Request
Note that type
, eventType
, functionId
, path
, and method
may not be updated in an UpdateSubscription call.
type
-string
- subscription type,sync
orasync
eventType
-string
- event typefunctionId
-string
- ID of function to receive eventspath
-string
- optional, URL path under which events (HTTP requests) are accepted, default:/
method
-string
- optional, HTTP method that accepts requests, default:POST
metadata
-object
- arbitrary metadata
Response
Status code:
200 Created
on success400 Bad Request
on validation error404 Not Found
if subscription doesn't exist
JSON object:
space
-string
- space namesubscriptionId
-string
- subscription IDtype
-string
- subscription typeeventType
-string
- event typefunctionId
- function IDmethod
-string
- HTTP method that accepts requestspath
-string
- path that accepts requests, starts with/
metadata
-object
- arbitrary metadata
Endpoint
DELETE <Configuration API URL>/v1/spaces/<space>/subscriptions/<subscription ID>
Response
Status code:
204 No Content
on success404 Not Found
if subscription doesn't exist
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/subscriptions
Query Parameters
Endpoint allows filtering list of returned object with filters passed as query parameters. Currently, filters can only use metadata properties e.g. metadata.service=usersService
.
Response
Status code:
200 OK
on success
JSON object:
subscriptions
-array
ofobject
- subscriptionsspace
-string
- space namesubscriptionId
-string
- subscription IDtype
-string
- subscription typeeventType
-string
- event typefunctionId
- function IDmethod
-string
- HTTP method that accepts requestspath
-string
- path that accepts requests, starts with/
metadata
-object
- arbitrary metadata
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/subscriptions/<subscription ID>
Response
Status code:
200 OK
on success404 NotFound
if subscription doesn't exist
JSON object:
space
-string
- space namesubscriptionId
-string
- subscription IDtype
-string
- subscription typeeventType
-string
- event typefunctionId
- function IDmethod
-string
- HTTP method that accepts requestspath
-string
- path that accepts requests, starts with/
metadata
-object
- arbitrary metadata
Endpoint
POST <Configuration API URL>/v1/spaces/<space>/cors
Request
method
-string
- endpoint methodpath
-string
- endpoint pathallowedOrigins
-array
ofstring
- list of allowed origins. An origin may contain a wildcard (*) to replace 0 or more characters (i.e.: http://*.domain.com), default:*
allowedMethods
-array
ofstring
- list of allowed methods, default:HEAD
,GET
,POST
allowedHeaders
-array
ofstring
- list of allowed headers, default:Origin
,Accept
,Content-Type
allowCredentials
-bool
- allow credentials, default: falsemetadata
-object
- arbitrary metadata
Response
Status code:
201 Created
on success400 Bad Request
on validation error409 Conflict
if CORS configuration already exists
JSON object:
space
-string
- space namecorsId
-string
- CORS configuration IDmethod
-string
- endpoint methodpath
-string
- endpoint pathallowedOrigins
-array
ofstring
- list of allowed originsallowedMethods
-array
ofstring
- list of allowed methodsallowedHeaders
-array
ofstring
- list of allowed headersallowCredentials
-boolean
- allow credentialsmetadata
-object
- arbitrary metadata
Endpoint
PUT <Configuration API URL>/v1/spaces/<space>/cors/<CORS ID>
Request
Note that method
, and path
may not be updated in an UpdateCORS call.
method
-string
- endpoint methodpath
-string
- endpoint pathallowedOrigins
-array
ofstring
- list of allowed originsallowedMethods
-array
ofstring
- list of allowed methodsallowedHeaders
-array
ofstring
- list of allowed headersallowCredentials
-boolean
- allow credentialsmetadata
-object
- arbitrary metadata
Response
Status code:
200 Created
on success400 Bad Request
on validation error404 Not Found
if CORS configuration doesn't exist
JSON object:
space
-string
- space namecorsId
-string
- CORS configuration IDmethod
-string
- endpoint methodpath
-string
- endpoint pathallowedOrigins
-array
ofstring
- allowed originsallowedMethods
-array
ofstring
- allowed methodsallowedHeaders
-array
ofstring
- allowed headersallowCredentials
-boolean
- allow credentialsmetadata
-object
- arbitrary metadata
Endpoint
DELETE <Configuration API URL>/v1/spaces/<space>/cors/<CORS ID>
Response
Status code:
204 No Content
on success404 Not Found
if CORS configuration doesn't exist
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/cors
Query Parameters
Endpoint allows filtering list of returned object with filters passed as query parameters. Currently, filters can only use metadata properties e.g. metadata.service=usersService
.
Response
Status code:
200 OK
on success
JSON object:
cors
-array
ofobject
- CORS configurationsspace
-string
- space namecorsId
-string
- CORS configuration IDmethod
-string
- endpoint methodpath
-string
- endpoint pathallowedOrigins
-array
ofstring
- allowed originsallowedMethods
-array
ofstring
- allowed methodsallowedHeaders
-array
ofstring
- allowed headersallowCredentials
-boolean
- allow credentialsmetadata
-object
- arbitrary metadata
Endpoint
GET <Configuration API URL>/v1/spaces/<space>/cors/<CORS ID>
Response
Status code:
200 OK
on success404 NotFound
if CORS configuration doesn't exist
JSON object:
space
-string
- space namecorsId
-string
- CORS configuration IDmethod
-string
- endpoint methodpath
-string
- endpoint pathallowedOrigins
-array
ofstring
- allowed originsallowedMethods
-array
ofstring
- allowed methodsallowedHeaders
-array
ofstring
- allowed headersallowCredentials
-boolean
- allow credentialsmetadata
-object
- arbitrary metadata
Endpoint exposing Prometheus metrics.
Endpoint
GET <Configuration API URL>/metrics
Dummy endpoint (always returning 200 OK
status code) for checking if the event gateway instance is running.
Endpoint
GET <Configuration API URL>/v1/status