Event Payloads

Here are examples of event payloads for some typical controller requests. They help to figure out what are the minimum required keys.

home

{
  "version": "2.0",
  "rawPath": "/",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  }
}

Note: For Rails, you’ll need the x-forwarded-proto and x-forwarded-port headers because most Rails has a middleware that checks for https on by default.

posts#index

{
  "version": "2.0",
  "rawPath": "/posts",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  }
}

posts#show

{
  "version": "2.0",
  "rawPath": "/posts/1",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  }
}

posts#new

{
  "version": "2.0",
  "rawPath": "/posts/new",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  }
}

posts#edit

{
  "version": "2.0",
  "rawPath": "/posts/edit/1",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  }
}

posts#create

{
  "version": "2.0",
  "rawPath": "/posts",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "content-type": "application/x-www-form-urlencoded",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  },
  "requestContext": {
    "http": {
      "method": "POST"
    }
  },
  "body": "{\"post\":{\"title\":\"Post 1\",\"body\":\"Body 1\",\"published\":true}}"
}

posts#update

{
  "version": "2.0",
  "rawPath": "/posts/1",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "content-type": "application/x-www-form-urlencoded",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  },
  "requestContext": {
    "http": {
      "method": "PUT"
    }
  },
  "body": "{\"post\":{\"title\":\"Post 1 Edit 1\",\"body\":\"Body 1\",\"published\":true}}"
}

posts#destroy

{
  "version": "2.0",
  "rawPath": "/posts/1",
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  },
  "requestContext": {
    "http": {
      "method": "DELETE"
    }
  }
}

Cookies Example

Here’s an example payload that will set cookies.

{
  "version": "2.0",
  "routeKey": "$default",
  "rawPath": "/posts",
  "rawQueryString": "foo=bar",
  "cookies": [
    "yummy1=value1",
    "yummy2=value2"
  ],
  "headers": {
    "host": "dummy.lambda-url.us-west-2.on.aws",
    "x-forwarded-proto": "https",
    "x-forwarded-port": "443"
  }
}

AWS Docs

For the example event format structure, check out the AWS docs: Payload format version