---
source_url: https://www.pubnub.com/docs/sdks/arduino/api-reference/configuration
title: Configuration API for Arduino SDK
description: Learn how to initialize and configure the PubNub Arduino SDK with account-level credentials.
updated_at: 2026-11-09T13:29:01.000Z
---

# Configuration API for Arduino SDK

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

Arduino complete Application Programming Interface (API) reference for building real-time applications on PubNub, including basic usage and sample code. This guide explains how to configure and use the Arduino Software Development Kit (SDK).

## Initialization

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`.

:::note
To initialize the PubNub library, use the `begin()` method in your `setup()` function in your sketch.
:::

### Method(s)

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

```c
bool begin(const char *publish_key, const char *subscribe_key, const char *origin = "ps.pndsn.com");
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| publish_key | const char* | Yes | The string of the `publish key` to use. |
| subscribe_key | const char* | Yes | The string of the `subscribe key` to use. |
| origin | const char* | Optional | The host name of the PubNub `origin` to use. Defaults to `ps.pndsn.com`. To request a custom domain, contact support and follow the [request process](https://www.pubnub.com/docs/security/encryption/overview.md). |

### Sample code

:::note
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.
:::

```c
Pubnub.begin("demo", "demo");
```

### Returns

| Type | Description |
| --- | --- |
| `bool` | `true` if initialization succeeded, `false` otherwise. |

## UUID

This function is used to set a user ID on the fly.

### Method(s)

To set `UUID` you can use the following method(s) in Arduino SDK

:::note Add Publisher UUID to Message Add Publisher UUID to Message
Note that this function only allows you to set the UUID. Arduino is a subscribe API v1 client and these clients don't implicitly send either the publisher's UUID or the publish timetoken.
If you want to include the publisher information in your message payload, you need to set the client UUID manually, and explicitly include it in your message payload. Refer to [Sending publisher UUID](#sending-publisher-uuid) for more information.
:::

```c
void set_uuid(const char *uuid);
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| uuid | const char* | Yes | The `UUID` to use. Set `0` to not use `UUID`. |

### Sample code

:::note
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.
:::

```c
Pubnub.set_uuid("myUniqueUUID");
```

### Returns

| Type | Description |
| --- | --- |
| `void` | `Nothing.` |

### Sending publisher UUID

To attach the publisher's UUID to the message, you need to store the UUID in a regular variable and then pass it inside the message payload.

```c
char client_uuid[] = "myUniqueUUID";

PubNub_BASE_CLIENT *client = PubNub.publish("my_channel", "{\"msg\": \"hello\", \"publisher\": \"" + client_uuid + "\"}");
if (!client) {
    client->stop();
}
```

## Authentication key

To set the auth key, use the `set_auth()` method in either your `setup()` or your `loop()` function in your sketch.

### Property

To `Set Authentication Key` you can use the following method(s) in the Arduino SDK:

```c
void set_auth(const char *auth);
```

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| auth | const char* | Yes | The `auth` key to use. Set `0` to not use the `auth` key. |

### Sample code

```c
Pubnub.set_auth("my_auth_key");
```

### Returns

| Type | Description |
| --- | --- |
| `void` | `Nothing.` |

Last updated at: 2026-11-09T13:29:01.000Z
