# Commissioner

# Commissioner

This module includes functions for the Thread Commissioner role.

## Summary

| ### Enumerations ||
|---|---|
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gaf537456875dae00e847122bfbb075459` | enumDefines a Joiner Event on the Commissioner. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga66faa041c266867350162885db687ec3{ https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gga66faa041c266867350162885db687ec3a309d2216ed90422d6904b81e15b6516e = 0, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gga66faa041c266867350162885db687ec3a9d07122f8a2acf478753a11e503b34d1 = 1, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gga66faa041c266867350162885db687ec3aea660a3596216bc1e60057835a24938a = 2 }` | enumDefines the Commissioner State. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gab1880d4811aff87d7f8ba7cdf929aafe{ https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ggab1880d4811aff87d7f8ba7cdf929aafea032851fc704e28d8efd52944cdc34aa1 = 0, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ggab1880d4811aff87d7f8ba7cdf929aafea38bfd5a1165aa8bd6cbaca85fe540958 = 1, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ggab1880d4811aff87d7f8ba7cdf929aafea2d5f8a39193ff6445d0663b564334157 = 2 }` | enumDefines a Joiner Info Type. |

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga65f2838860e10335b5b3e6157776283b)(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength, void *aContext)` | typedef `void(*` Pointer is called when the Commissioner receives an Energy Report. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga98e67d37daf7997b07009a5eac485889)(otCommissionerJoinerEvent aEvent, const otJoinerInfo *aJoinerInfo, const otExtAddress *aJoinerId, void *aContext)` | typedef `void(*` Pointer is called whenever the joiner state changes. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gab9b4d32893b6dd859b9bf40f8921819e` | typedef `enum https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gaf537456875dae00e847122bfbb075459` Defines a Joiner Event on the Commissioner. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga6c1c0e496bdda6628f06fa70975db318)(uint16_t aPanId, uint32_t aChannelMask, void *aContext)` | typedef `void(*` Pointer is called when the Commissioner receives a PAN ID Conflict message. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga4604ba53f4819c570294e3d5a9267b6f` | typedef `enum https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga66faa041c266867350162885db687ec3` Defines the Commissioner State. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga9c419fd574096f6ebd12185d87a58c24)(otCommissionerState aState, void *aContext)` | typedef `void(*` Pointer is called whenever the commissioner state changes. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gab492a66b08598e4ee28d72b8851e3a5b` | typedef `struct https://openthread.io/reference/struct/ot-commissioning-dataset` Represents a Commissioning Dataset. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga8b47c7edfba5a687727d6281f6c792b6` | typedef `struct https://openthread.io/reference/struct/ot-joiner-info` Represents a Joiner Info. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gad267c66b83a96c71581578f561449fa5` | typedef `enum https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gab1880d4811aff87d7f8ba7cdf929aafe` Defines a Joiner Info Type. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga563769a3f28e7dfe198344a6372fb83b` | typedef `struct https://openthread.io/reference/struct/ot-joiner-pskd` Represents a Joiner PSKd. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga3c5bf9814289ed2c40cc6a8d1327f9c4(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-ext-address *aEui64, const char *aPskd, uint32_t aTimeout)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Adds a Joiner entry. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gad4c35a7380842d0431e816fee9815bd4(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-joiner-discerner *aDiscerner, const char *aPskd, uint32_t aTimeout)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Adds a Joiner entry with a given Joiner Discerner value. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gaa7a1c858a587e62f50404a07a70e048e(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod, const https://openthread.io/reference/struct/ot-ip6-address *aAddress)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sends an Announce Begin message. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga33ff11d401e46723b55c07327c23f275(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod, uint16_t aScanDuration, const https://openthread.io/reference/struct/ot-ip6-address *aAddress, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga65f2838860e10335b5b3e6157776283b aCallback, void *aContext)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sends an Energy Scan Query message. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga542d38c68929d4efb5b12943001ba798(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `const char *` Returns the Commissioner Id. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga6fdeecca44a5786a5bd53bf53b3dc004(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint16_t *aIterator, https://openthread.io/reference/struct/ot-joiner-info *aJoiner)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Get joiner info at aIterator position. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gac548310015bc1f540ce55dc93bf49ec1(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `const char *` Gets the Provisioning URL. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga30fb4478fc93ecf9254490d879118579(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `uint16_t` Returns the Commissioner Session ID. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga47a8c7e5174205accab11bf8558cbe79(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga66faa041c266867350162885db687ec3` Returns the Commissioner State. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga37e4c517ae343cbbe23422c3031062d3(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint16_t aPanId, uint32_t aChannelMask, const https://openthread.io/reference/struct/ot-ip6-address *aAddress, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga6c1c0e496bdda6628f06fa70975db318 aCallback, void *aContext)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sends a PAN ID Query message. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga0683357c7078c0ecf1a462c8a4ab9092(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-ext-address *aEui64)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Removes a Joiner entry. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga6527980f9c4f53ccc762b344231911e3(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-joiner-discerner *aDiscerner)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Removes a Joiner entry. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gaa91e4598e78be7391ab180a15e239553(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const uint8_t *aTlvs, uint8_t aLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sends MGMT_COMMISSIONER_GET. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga64323e25aef5baedad2550fb9907d9a6(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-commissioning-dataset *aDataset, const uint8_t *aTlvs, uint8_t aLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sends MGMT_COMMISSIONER_SET. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga86843c59aeddad57c0f7c7c96b1a5c4f(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const char *aId)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sets the Commissioner Id. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga4a8e7a0413d4b206a49014b2dd2124ba(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const char *aProvisioningUrl)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sets the Provisioning URL. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga9c419fd574096f6ebd12185d87a58c24 aStateCallback, https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga98e67d37daf7997b07009a5eac485889 aJoinerCallback, void *aCallbackContext)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Enables the Thread Commissioner role. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga60fe57713b31ee007c6351b0e7d533f5(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Disables the Thread Commissioner role. |

| ### Macros ||
|---|---|
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gadc00841d793e3996e778abc822cb5cd2 255` | Maximum size of the Commissioning Passphrase. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1ga4ac42578f545c4026816927109a832a4 6` | Minimum size of the Commissioning Passphrase. |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gac065cd3782101a9d9ef9f8e059edb531 32` | Maximum string length of a Joiner PSKd (does not include null char). |
| `https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gacd80943af476d30c6847657687b4b035 64` | Max size (number of chars) in Provisioning URL string (excludes null char). |

| ### Structs ||
|---|---|
| [otCommissioningDataset](https://openthread.io/reference/struct/ot-commissioning-dataset) | Represents a Commissioning Dataset. |
| [otJoinerInfo](https://openthread.io/reference/struct/ot-joiner-info) | Represents a Joiner Info. |
| [otJoinerPskd](https://openthread.io/reference/struct/ot-joiner-pskd) | Represents a Joiner PSKd. |

## Enumerations

### otCommissionerJoinerEvent

```
 otCommissionerJoinerEvent
```
Defines a Joiner Event on the Commissioner.

### otCommissionerState

```
 otCommissionerState
```
Defines the Commissioner State.

| Properties ||
|---|---|
| `OT_COMMISSIONER_STATE_ACTIVE` | Commissioner role is active. |
| `OT_COMMISSIONER_STATE_DISABLED` | Commissioner role is disabled. |
| `OT_COMMISSIONER_STATE_PETITION` | Currently petitioning to become a Commissioner. |

### otJoinerInfoType

```
 otJoinerInfoType
```
Defines a Joiner Info Type.

| Properties ||
|---|---|
| `OT_JOINER_INFO_TYPE_ANY` | Accept any Joiner (no EUI64 or Discerner is specified). |
| `OT_JOINER_INFO_TYPE_DISCERNER` | Joiner Discerner is specified (`mSharedId.mDiscerner` in `https://openthread.io/reference/struct/ot-joiner-info`). |
| `OT_JOINER_INFO_TYPE_EUI64` | Joiner EUI-64 is specified (`mSharedId.mEui64` in `https://openthread.io/reference/struct/ot-joiner-info`). |

## Typedefs

### otCommissionerEnergyReportCallback

```
void(* otCommissionerEnergyReportCallback)(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength, void *aContext)
```
Pointer is called when the Commissioner receives an Energy Report.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aChannelMask` | The channel mask value. | | `[in] aEnergyList` | A pointer to the energy measurement list. | | `[in] aEnergyListLength` | Number of entries in `aEnergyListLength`. | | `[in] aContext` | A pointer to application-specific context. | |

### otCommissionerJoinerCallback

```
void(* otCommissionerJoinerCallback)(otCommissionerJoinerEvent aEvent, const otJoinerInfo *aJoinerInfo, const otExtAddress *aJoinerId, void *aContext)
```
Pointer is called whenever the joiner state changes.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aEvent` | The joiner event type. | | `[in] aJoinerInfo` | A pointer to the Joiner Info. | | `[in] aJoinerId` | A pointer to the Joiner ID (if not known, it will be NULL). | | `[in] aContext` | A pointer to application-specific context. | |

### otCommissionerJoinerEvent

```
enum otCommissionerJoinerEvent otCommissionerJoinerEvent
```
Defines a Joiner Event on the Commissioner.

### otCommissionerPanIdConflictCallback

```
void(* otCommissionerPanIdConflictCallback)(uint16_t aPanId, uint32_t aChannelMask, void *aContext)
```
Pointer is called when the Commissioner receives a PAN ID Conflict message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aPanId` | The PAN ID value. | | `[in] aChannelMask` | The channel mask value. | | `[in] aContext` | A pointer to application-specific context. | |

### otCommissionerState

```
enum otCommissionerState otCommissionerState
```
Defines the Commissioner State.

### otCommissionerStateCallback

```
void(* otCommissionerStateCallback)(otCommissionerState aState, void *aContext)
```
Pointer is called whenever the commissioner state changes.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aState` | The Commissioner state. | | `[in] aContext` | A pointer to application-specific context. | |

### otCommissioningDataset

```
struct otCommissioningDataset otCommissioningDataset
```
Represents a Commissioning Dataset.

### otJoinerInfo

```
struct otJoinerInfo otJoinerInfo
```
Represents a Joiner Info.

### otJoinerInfoType

```
enum otJoinerInfoType otJoinerInfoType
```
Defines a Joiner Info Type.

### otJoinerPskd

```
struct otJoinerPskd otJoinerPskd
```
Represents a Joiner PSKd.

## Functions

### otCommissionerAddJoiner

```
otError otCommissionerAddJoiner(
  otInstance *aInstance,
  const otExtAddress *aEui64,
  const char *aPskd,
  uint32_t aTimeout
)
```
Adds a Joiner entry.


> [!NOTE]
> **Note:** Only use this after successfully starting the Commissioner role with [otCommissionerStart()](https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aEui64` | A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner. | | `[in] aPskd` | A pointer to the PSKd. | | `[in] aTimeout` | A time after which a Joiner is automatically removed, in seconds. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully added the Joiner. | | `OT_ERROR_NO_BUFS` | No buffers available to add the Joiner. | | `OT_ERROR_INVALID_ARGS` | `aEui64` or `aPskd` is invalid. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerAddJoinerWithDiscerner

```
otError otCommissionerAddJoinerWithDiscerner(
  otInstance *aInstance,
  const otJoinerDiscerner *aDiscerner,
  const char *aPskd,
  uint32_t aTimeout
)
```
Adds a Joiner entry with a given Joiner Discerner value.


> [!NOTE]
> **Note:** Only use this after successfully starting the Commissioner role with [otCommissionerStart()](https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aDiscerner` | A pointer to the Joiner Discerner. | | `[in] aPskd` | A pointer to the PSKd. | | `[in] aTimeout` | A time after which a Joiner is automatically removed, in seconds. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully added the Joiner. | | `OT_ERROR_NO_BUFS` | No buffers available to add the Joiner. | | `OT_ERROR_INVALID_ARGS` | `aDiscerner` or `aPskd` is invalid. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerAnnounceBegin

```
otError otCommissionerAnnounceBegin(
  otInstance *aInstance,
  uint32_t aChannelMask,
  uint8_t aCount,
  uint16_t aPeriod,
  const otIp6Address *aAddress
)
```
Sends an Announce Begin message.


> [!NOTE]
> **Note:** Only use this after successfully starting the Commissioner role with [otCommissionerStart()](https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aChannelMask` | The channel mask value. | | `[in] aCount` | The number of Announcement messages per channel. | | `[in] aPeriod` | The time between two successive MLE Announce transmissions (in milliseconds). | | `[in] aAddress` | A pointer to the IPv6 destination. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully enqueued the Announce Begin message. | | `OT_ERROR_NO_BUFS` | Insufficient buffers to generate an Announce Begin message. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerEnergyScan

```
otError otCommissionerEnergyScan(
  otInstance *aInstance,
  uint32_t aChannelMask,
  uint8_t aCount,
  uint16_t aPeriod,
  uint16_t aScanDuration,
  const otIp6Address *aAddress,
  otCommissionerEnergyReportCallback aCallback,
  void *aContext
)
```
Sends an Energy Scan Query message.


> [!NOTE]
> **Note:** Only use this after successfully starting the Commissioner role with [otCommissionerStart()](https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aChannelMask` | The channel mask value. | | `[in] aCount` | The number of energy measurements per channel. | | `[in] aPeriod` | The time between energy measurements (milliseconds). | | `[in] aScanDuration` | The scan duration for each energy measurement (milliseconds). | | `[in] aAddress` | A pointer to the IPv6 destination. | | `[in] aCallback` | A pointer to a function called on receiving an Energy Report message. | | `[in] aContext` | A pointer to application-specific context. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully enqueued the Energy Scan Query message. | | `OT_ERROR_NO_BUFS` | Insufficient buffers to generate an Energy Scan Query message. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerGetId

```
const char * otCommissionerGetId(
  otInstance *aInstance
)
```
Returns the Commissioner Id.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The Commissioner Id. |

### otCommissionerGetNextJoinerInfo

```
otError otCommissionerGetNextJoinerInfo(
  otInstance *aInstance,
  uint16_t *aIterator,
  otJoinerInfo *aJoiner
)
```
Get joiner info at aIterator position.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to instance. | | `[in,out] aIterator` | A pointer to the Joiner Info iterator context. | | `[out] aJoiner` | A reference to Joiner info. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully get the Joiner info. | | `OT_ERROR_NOT_FOUND` | Not found next Joiner. | |

### otCommissionerGetProvisioningUrl

```
const char * otCommissionerGetProvisioningUrl(
  otInstance *aInstance
)
```
Gets the Provisioning URL.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | A pointer to the URL string. |

### otCommissionerGetSessionId

```
uint16_t otCommissionerGetSessionId(
  otInstance *aInstance
)
```
Returns the Commissioner Session ID.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| **Returns** | The current commissioner session id. |

### otCommissionerGetState

```
otCommissionerState otCommissionerGetState(
  otInstance *aInstance
)
```
Returns the Commissioner State.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| Return Values | |---|---| | `OT_COMMISSIONER_STATE_DISABLED` | Commissioner disabled. | | `OT_COMMISSIONER_STATE_PETITION` | Becoming the commissioner. | | `OT_COMMISSIONER_STATE_ACTIVE` | Commissioner enabled. | |

### otCommissionerPanIdQuery

```
otError otCommissionerPanIdQuery(
  otInstance *aInstance,
  uint16_t aPanId,
  uint32_t aChannelMask,
  const otIp6Address *aAddress,
  otCommissionerPanIdConflictCallback aCallback,
  void *aContext
)
```
Sends a PAN ID Query message.


> [!NOTE]
> **Note:** Only use this after successfully starting the Commissioner role with [otCommissionerStart()](https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aPanId` | The PAN ID to query. | | `[in] aChannelMask` | The channel mask value. | | `[in] aAddress` | A pointer to the IPv6 destination. | | `[in] aCallback` | A pointer to a function called on receiving a PAN ID Conflict message. | | `[in] aContext` | A pointer to application-specific context. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully enqueued the PAN ID Query message. | | `OT_ERROR_NO_BUFS` | Insufficient buffers to generate a PAN ID Query message. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerRemoveJoiner

```
otError otCommissionerRemoveJoiner(
  otInstance *aInstance,
  const otExtAddress *aEui64
)
```
Removes a Joiner entry.


> [!NOTE]
> **Note:** Only use this after successfully starting the Commissioner role with [otCommissionerStart()](https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aEui64` | A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully removed the Joiner. | | `OT_ERROR_NOT_FOUND` | The Joiner specified by `aEui64` was not found. | | `OT_ERROR_INVALID_ARGS` | `aEui64` is invalid. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerRemoveJoinerWithDiscerner

```
otError otCommissionerRemoveJoinerWithDiscerner(
  otInstance *aInstance,
  const otJoinerDiscerner *aDiscerner
)
```
Removes a Joiner entry.


> [!NOTE]
> **Note:** Only use this after successfully starting the Commissioner role with [otCommissionerStart()](https://openthread.io/reference/group/api-commissioner#group__api-commissioner_1gae1865376814eb0549b8c64de3d1c0415).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aDiscerner` | A pointer to the Joiner Discerner. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully removed the Joiner. | | `OT_ERROR_NOT_FOUND` | The Joiner specified by `aEui64` was not found. | | `OT_ERROR_INVALID_ARGS` | `aDiscerner` is invalid. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerSendMgmtGet

```
otError otCommissionerSendMgmtGet(
  otInstance *aInstance,
  const uint8_t *aTlvs,
  uint8_t aLength
)
```
Sends MGMT_COMMISSIONER_GET.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aTlvs` | A pointer to TLVs. | | `[in] aLength` | The length of TLVs. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully send the meshcop dataset command. | | `OT_ERROR_NO_BUFS` | Insufficient buffer space to send. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerSendMgmtSet

```
otError otCommissionerSendMgmtSet(
  otInstance *aInstance,
  const otCommissioningDataset *aDataset,
  const uint8_t *aTlvs,
  uint8_t aLength
)
```
Sends MGMT_COMMISSIONER_SET.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aDataset` | A pointer to commissioning dataset. | | `[in] aTlvs` | A pointer to TLVs. | | `[in] aLength` | The length of TLVs. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully send the meshcop dataset command. | | `OT_ERROR_NO_BUFS` | Insufficient buffer space to send. | | `OT_ERROR_INVALID_STATE` | The commissioner is not active. | |

### otCommissionerSetId

```
otError otCommissionerSetId(
  otInstance *aInstance,
  const char *aId
)
```
Sets the Commissioner Id.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aId` | A pointer to a string character array. Must be null terminated. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the Commissioner Id. | | `OT_ERROR_INVALID_ARGS` | Given name is too long. | | `OT_ERROR_INVALID_STATE` | The commissioner is active and id cannot be changed. | |

### otCommissionerSetProvisioningUrl

```
otError otCommissionerSetProvisioningUrl(
  otInstance *aInstance,
  const char *aProvisioningUrl
)
```
Sets the Provisioning URL.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aProvisioningUrl` | A pointer to the Provisioning URL (may be NULL to set as empty string). | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the Provisioning URL. | | `OT_ERROR_INVALID_ARGS` | `aProvisioningUrl` is invalid (too long). | |

### otCommissionerStart

```
otError otCommissionerStart(
  otInstance *aInstance,
  otCommissionerStateCallback aStateCallback,
  otCommissionerJoinerCallback aJoinerCallback,
  void *aCallbackContext
)
```
Enables the Thread Commissioner role.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aStateCallback` | A pointer to a function that is called when the commissioner state changes. | | `[in] aJoinerCallback` | A pointer to a function that is called with a joiner event occurs. | | `[in] aCallbackContext` | A pointer to application-specific context. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully started the Commissioner service. | | `OT_ERROR_ALREADY` | Commissioner is already started. | | `OT_ERROR_INVALID_STATE` | Device is not currently attached to a network. | |

### otCommissionerStop

```
otError otCommissionerStop(
  otInstance *aInstance
)
```
Disables the Thread Commissioner role.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully stopped the Commissioner service. | | `OT_ERROR_ALREADY` | Commissioner is already stopped. | |

## Macros

### OT_COMMISSIONING_PASSPHRASE_MAX_SIZE

```
 OT_COMMISSIONING_PASSPHRASE_MAX_SIZE 255
```
Maximum size of the Commissioning Passphrase.

### OT_COMMISSIONING_PASSPHRASE_MIN_SIZE

```
 OT_COMMISSIONING_PASSPHRASE_MIN_SIZE 6
```
Minimum size of the Commissioning Passphrase.

### OT_JOINER_MAX_PSKD_LENGTH

```
 OT_JOINER_MAX_PSKD_LENGTH 32
```
Maximum string length of a Joiner PSKd (does not include null char).

### OT_PROVISIONING_URL_MAX_SIZE

```
 OT_PROVISIONING_URL_MAX_SIZE 64
```
Max size (number of chars) in Provisioning URL string (excludes null char).

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).