---
source_url: https://www.pubnub.com/docs/serverless-sdk/request-response-objects
title: Request and response objects
updated_at: 2026-09-30T07:20:08.000Z
---

# Request and response objects

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

This page lists every field and method on the `request`, `response`, and `event` objects a PubNub [Function](https://www.pubnub.com/docs/message-processing/serverless/development.md) handler receives, by trigger type. For handler structure, Promises, and chaining, see [Functions development](https://www.pubnub.com/docs/message-processing/serverless/development.md). For what each trigger does, see [Function types](https://www.pubnub.com/docs/serverless-sdk/function-types.md).

## Standard request object

PubNub passes this object to the handler for every trigger type except On Request, On Interval, and Subscribe on Interval.

### Methods

| Method | Arguments | Description |
| --- | --- | --- |
| `ok(message?)` | `message: String` (optional) | Resolves the execution and returns a Promise that resolves to the value of the request object. The event continues normally. |
| `abort(message?)` | `message: String` (optional) | Resolves the execution and returns a Promise that resolves to the value of the request object, with an error code added. On synchronous triggers, PubNub does not deliver the message. |

```javascript
export default (request) => {
    if (!request.message.valid) {
        return request.abort('invalid payload');
    }
    return request.ok();
};
```

### Attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `message` | Object | The message payload. |
| `channels` | Array<String> | Channels the message was published to. |
| `verb` | String | Publish method the client used. |
| `pubkey` | String | Publish key used to send the message. |
| `subkey` | String | Subscribe key for the channel. |
| `meta.clientip` | String | IP address of the publishing client. |
| `meta.origin` | String | Origin configured on the publishing client. |
| `meta.useragent` | String | User agent string of the publishing client. |
| `params` | Object | URL parameters on the request. |
| `uri` | String | Request URI. |
| `version` | String | API version. |

## On Request: request and response

### request attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `method` | String | HTTP method: GET, PUT, POST, DELETE. |
| `body` | Object | Request body. |
| `headers` | Object | Request headers. |
| `params` | Object | URL query parameters. |
| `path` | String | Path configured for the Function, minus the PubNub hostname and key information. |
| `uri` | String | Full request URI. |
| `verb` | String | Always `rest`. |
| `pubkey` | String | Publish key. |
| `subkey` | String | Subscribe key. |
| `meta.clientip` | String | IP address of the caller. |
| `meta.origin` | String | Origin of the caller. |
| `meta.useragent` | String | User agent of the caller. |
| `version` | String | API version. |

### response methods

| Method | Arguments | Description |
| --- | --- | --- |
| `send(body?)` | `body: String` (optional) | Sends the response, ends the Function execution, and returns a Promise that resolves to the value of the response object. |

### response attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `status` | Number | HTTP status code returned to the caller. Set before calling `send()`. |
| `body` | Object | Response body returned to the caller. |
| `headers` | Object | Response headers returned to the caller. |

On Request Functions receive HTTP requests. The `request` object represents the incoming HTTP request.

## On Interval: event object

PubNub passes this object to the handler for the On Interval trigger.

### Methods

| Method | Arguments | Description |
| --- | --- | --- |
| `ok()` | None | Resolves the execution and returns a Promise that resolves to the value of the event object. |

### Attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `execInterval` | Number | Configured interval, in milliseconds. |
| `lastTimestamp` | Number | Timestamp of the previous execution. |
| `timestamp` | Number | Timestamp of the current execution. |
| `verb` | String | Always `interval`. |
| `pubkey` | String | Publish key. |
| `subkey` | String | Subscribe key. |

## Subscribe on Interval: event object

Subscribe on Interval uses the same [event object as On Interval](#on-interval-event-object) (above).

## Related reference

* [Functions development](https://www.pubnub.com/docs/message-processing/serverless/development.md). Handler structure, Promises, and chaining and forking.
* [Function types](https://www.pubnub.com/docs/serverless-sdk/function-types.md). What each trigger type does and when to use it.
* [Modules and libraries](https://www.pubnub.com/docs/serverless-sdk/modules-and-libraries/overview.md). Built-in module APIs, including the `pubnub` module.

Last updated at: 2026-09-30T07:20:08.000Z
