---
source_url: https://www.pubnub.com/docs/sdks/lua/api-reference/configuration
title: Configuration API for Lua SDK
updated_at: 2026-06-26T11:06:03.795Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Configuration API for Lua SDK

Complete Lua API reference for building real-time applications on PubNub, including basic usage and sample code.

## Initialization

### Including the code

```lua
require "pubnub"
```

### Description

This function is used for initializing the PubNub Client API context. This function must be called before attempting to utilize any API functionality in order to establish account level credentials such as `publish_key` and `subscribe_key`.

### Method(s)

To `Initialize` PubNub you can use the following method(s) in the Lua SDK:

```lua
pubnub_obj = pubnub.new(configuration)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| configuration | table | Yes |  | Table of initialization parameters (a kind of prototype to construct the PubNub object from). See [Configuration Parameters](#configuration-parameters) for more details. |

#### Configuration parameters

| Parameter | Description |
| --- | --- |
| `publish_key`Type: stringDefault: `none` | The PubNub publish key. |
| `subscribe_key` *Type: stringDefault: `none` | The PubNub subscribe key. |
| `secret_key`Type: stringDefault: `none` | The secret key. |
| `auth_key`Type: stringDefault: `none` | The auth key to access channels. |
| `ssl`Type: booleanDefault: `false` | Whether to use SSL to connect to PubNub. |
| `origin`Type: stringDefault: `ps.pndsn.com` | The domain name to use to connect to PubNub. To request a custom domain, contact support and follow the [request process](https://www.pubnub.com/docs/general/setup/data-security#request-process). |
| `uuid` *Type: stringDefault: n/a | `UUID` to use. You should set a unique `UUID` to identify the user or the device that connects to PubNub. It's a UTF-8 encoded string of up to 92 alphanumeric characters. If you don't set the `UUID`, you won't be able to connect to PubNub. |

### Sample code

#### Initialize the PubNub client API

:::note Required UUID
Always set the `UUID` to uniquely identify the user or device that connects to PubNub. This `UUID` should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the `UUID`, you won't be able to connect to PubNub.
:::

```lua
require "pubnub"

local pubnub_obj = pubnub.new({
    publish_key = "demo",
    subscribe_key = "demo",
    secret_key = "demo",
    ssl = false,
    origin = "ps.pndsn.com"
})
```

### Returns

It returns the PubNub instance for invoking PubNub APIs like `publish()`, `subscribe()`, `history()`, `here_now()`, etc.