# Update user public data (/docs/apis/management/users/PatchPublicData)

`PATCH /users/{user_id}/public_data`

Applies a partial update to the public data associated with the specified user. Only fields included in the request are updated. Public data fields can be removed by sending a `null` value for the corresponding key. Intended for non-sensitive attributes that may be safely exposed to client applications. When surfaced via custom claims, these values may appear in tokens issued to frontend or user-facing applications. Store only data that remains safe even if accessed through browser storage, logs, or debugging tools.

Base URL: `https://{tenant}.{region}.monocloud.com/api`, where `{tenant}`, `{region}` (one of us, eu, in) come from your tenant. Authentication: send your Management API key in the `X-API-KEY` header.

## Parameters

- `user_id` (path) (string, required) The unique identifier of the user.

## Request body

JSON, required. The request payload used to update a user's public data.

- `public_data` (Record<string, any>, required) A structured payload for updating public data. Supports strings, numbers, booleans, arrays, and nested objects. Fields omitted remain unchanged; fields set to `null` are removed.

## Response body

`200`, JSON. The user's public data was updated successfully

Returns `UserPublicData`.

- `public_data` (Record<string, any>, required) The public data associated with the user's account.

## Errors

- `400` Bad Request
  - `type` (string, required) A URI reference that identifies the error type. When accessed, it may provide human-readable documentation.
  - `title` (string, required) A short, human-readable summary of the error.
  - `status` (integer, required, int32) The HTTP status code associated with this error response.
  - `trace_id` (string, required) A unique identifier for the request, used for tracing and diagnostics.
  - `detail` (string) A human-readable explanation specific to this occurrence of the error.
  - `instance` (string) A URI reference that identifies the specific occurrence of the error.
- `401` Unauthorized
- `403` Forbidden
- `404` Not Found
  Same body as `400`.
- `422` Unprocessable Entity
  - `KeyValidationProblemDetails`
    - `type` (string, required) A URI reference that identifies the error type. When accessed, it may provide human-readable documentation.
    - `title` (string, required) A short, human-readable summary of the error.
    - `status` (integer, required, int32) The HTTP status code associated with this error response.
    - `trace_id` (string, required) A unique identifier for the request, used for tracing and diagnostics.
    - `detail` (string) A human-readable explanation specific to this occurrence of the error.
    - `instance` (string) A URI reference that identifies the specific occurrence of the error.
    - `errors` (Record<string, string[]>, required) A key-value map of validation errors, where each key represents a request field and the value contains one or more messages describing why the request could not be processed.
  - `IdentityValidationProblemDetails`
    - `type` (string, required) A URI reference that identifies the error type. When accessed, it may provide human-readable documentation.
    - `title` (string, required) A short, human-readable summary of the error.
    - `status` (integer, required, int32) The HTTP status code associated with this error response.
    - `trace_id` (string, required) A unique identifier for the request, used for tracing and diagnostics.
    - `detail` (string) A human-readable explanation specific to this occurrence of the error.
    - `instance` (string) A URI reference that identifies the specific occurrence of the error.
    - `errors` (IdentityError[], required) List of identity validation errors describing why the request could not be processed.

## Example (MonoCloud .NET SDK)

```csharp
using MonoCloud.Management;
using MonoCloud.Management.Models;
using MonoCloud.Management.Core.Base;

var apiClient = new MonoCloudManagementClient(new MonoCloudConfig("<your-domain>", "[[API-Key]]"));


var userId = "WUgDGqaqzqkRmsgd3PFAT";

var requestBody = new UpdatePublicDataRequest
  {
    PublicData = new Dictionary<string, object>
    {
      {
        "color_preference", new Dictionary<string, object>
          {
            {
              "dashboard", "monochrome"
            },
          }
      },
      {
        "send_emails", true
      },
      {
        "days_to_retain", 1
      },
    },
  };


var result = await apiClient.Users.PatchPublicDataAsync(userId, requestBody);
```

## Example (MonoCloud Javascript SDK)

```javascript
import { MonoCloudManagementClient } from '@monocloud/management';

const apiClient = MonoCloudManagementClient.init({ domain: '<your-domain>', apiKey: '[[API-Key]]' });

const userId = 'WUgDGqaqzqkRmsgd3PFAT';

const requestBody = {
  public_data: {
    color_preference: {
      dashboard: 'monochrome'
    },
    send_emails: true,
    days_to_retain: 1
  }
};

const result = apiClient.users.patchPublicData(userId, requestBody);
```