# Server

# Server

This module includes functions to manage local network data with the OpenThread Server.

## Summary

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-server#group__api-server_1gac871204d82331cde29a529e58cdbfe2f(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-service-config *aConfig)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Add a service configuration to the local network data. |
| `https://openthread.io/reference/group/api-server#group__api-server_1ga9fcdd92a4753520d00a04cd472db2c73(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Provides a full or stable copy of the local Thread Network Data. |
| `https://openthread.io/reference/group/api-server#group__api-server_1ga8f1af649229a6dbfeebc1c3b2789e75e(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-thread-general#group__api-thread-general_1gac4be34b26a43e67d12ee7e0352ee4927 *aIterator, https://openthread.io/reference/struct/ot-service-config *aConfig)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Gets the next service in the local Network Data. |
| `https://openthread.io/reference/group/api-server#group__api-server_1gae6d57d2bb198dcc86a941405c267fe8a(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Immediately register the local network data with the Leader. |
| `https://openthread.io/reference/group/api-server#group__api-server_1gafff1abde637835a204e25b5648fef8d2(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aEnterpriseNumber, const uint8_t *aServiceData, uint8_t aServiceDataLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Remove a service configuration from the local network data. |

## Functions

### otServerAddService

```
otError otServerAddService(
  otInstance *aInstance,
  const otServiceConfig *aConfig
)
```
Add a service configuration to the local network data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aConfig` | A pointer to the service configuration. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully added the configuration to the local network data. | | `OT_ERROR_INVALID_ARGS` | One or more configuration parameters were invalid. | | `OT_ERROR_NO_BUFS` | Not enough room is available to add the configuration to the local network data. | |

**See also:**   
[otServerRemoveService](https://openthread.io/reference/group/api-server#group__api-server_1gafff1abde637835a204e25b5648fef8d2)   
[otServerRegister](https://openthread.io/reference/group/api-server#group__api-server_1gae6d57d2bb198dcc86a941405c267fe8a)   

### otServerGetNetDataLocal

```
otError otServerGetNetDataLocal(
  otInstance *aInstance,
  bool aStable,
  uint8_t *aData,
  uint8_t *aDataLength
)
```
Provides a full or stable copy of the local Thread Network Data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aStable` | TRUE when copying the stable version, FALSE when copying the full version. | | `[out] aData` | A pointer to the data buffer. | | `[in,out] aDataLength` | On entry, size of the data buffer pointed to by `aData`. On exit, number of copied bytes. | |

### otServerGetNextService

```
otError otServerGetNextService(
  otInstance *aInstance,
  otNetworkDataIterator *aIterator,
  otServiceConfig *aConfig
)
```
Gets the next service in the local Network Data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in,out] aIterator` | A pointer to the Network Data iterator context. To get the first service entry it should be set to OT_NETWORK_DATA_ITERATOR_INIT. | | `[out] aConfig` | A pointer to where the service information will be placed. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully found the next service. | | `OT_ERROR_NOT_FOUND` | No subsequent service exists in the Thread Network Data. | |

### otServerRegister

```
otError otServerRegister(
  otInstance *aInstance
)
```
Immediately register the local network data with the Leader.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully queued a Server Data Request message for delivery. | |

**See also:**   
[otServerAddService](https://openthread.io/reference/group/api-server#group__api-server_1gac871204d82331cde29a529e58cdbfe2f)   
[otServerRemoveService](https://openthread.io/reference/group/api-server#group__api-server_1gafff1abde637835a204e25b5648fef8d2)   

### otServerRemoveService

```
otError otServerRemoveService(
  otInstance *aInstance,
  uint32_t aEnterpriseNumber,
  const uint8_t *aServiceData,
  uint8_t aServiceDataLength
)
```
Remove a service configuration from the local network data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aEnterpriseNumber` | Enterprise Number of the service entry to be deleted. | | `[in] aServiceData` | A pointer to an Service Data to look for during deletion. | | `[in] aServiceDataLength` | The length of `aServiceData` in bytes. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully removed the configuration from the local network data. | | `OT_ERROR_NOT_FOUND` | Could not find the Border Router entry. | |

**See also:**   
[otServerAddService](https://openthread.io/reference/group/api-server#group__api-server_1gac871204d82331cde29a529e58cdbfe2f)   
[otServerRegister](https://openthread.io/reference/group/api-server#group__api-server_1gae6d57d2bb198dcc86a941405c267fe8a)   

## 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).