---
source_url: https://www.pubnub.com/docs/sdks/arduino/api-reference/configuration
title: Configuration API for Arduino SDK
updated_at: 2026-06-19T11:36:38.374Z
---

> 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 Arduino SDK

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 | Default | Description |
| --- | --- | --- | --- | --- |
| publish_key | const | Yes |  | The string of the `publish key` to use. |
| subscribe_key | const | Yes |  | The string of the `subscribe key` to use. |
| origin | const | 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/general/setup/data-security#request-process). |

### 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 | Description |
| --- | --- |
| `uuid` *Type: const char* | 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 | Description |
| --- | --- |
| `auth` *Type: const char* | 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.` |

## Terms in this document

* **PubNub** - PubNub is a real-time messaging platform that provides APIs and SDKs for building scalable applications. It handles the complex infrastructure of real-time communication, including: Message delivery and persistence, Presence detection, Access control, Push notifications, File sharing, Serverless processing with Functions and Events & Actions, Analytics and monitoring with BizOps Workspace, AI-powered insights with Illuminate.
