---
docId: doc_8324b8a378b84e1e8ff34eb6f0f36d2b
title: Moderate a contact
description: Block, unblock or reset a contact's moderation strikes in a single call.
api:
  group: clientes
  auth: bearer
  operations:
    - operationId: updateClientModeration
      method: PATCH
      path: '/v1/clients/{id}/moderation'
      postmanName: Moderate a Client
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Moderate a contact

Block, unblock or reset a contact's strikes. The API updates their moderation and affected conversations.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X PATCH https://api.platic.ai/v1/clients/$CLIENT_ID/moderation \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "blocked", "reason": "Abusive messages" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.clients.block("client_123", { reason: "Abusive messages" });
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `id` | string | Can be the contact's ID or their phone number in E.164 format without `+` | ✓ |

## Request body

You must send at least one of `status`, `resetStrikes` or `clearHistory`.

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `status` | enum | — | `blocked` to block, `active` to unblock |
| `reason` | string | — | Reason for the block, which gets recorded. Maximum 120 characters. Only applies with `status: "blocked"`. Default: `api_request` |
| `resetStrikes` | boolean | — | Sets the strikes to zero. Implicit when you send `status: "active"` |
| `clearHistory` | boolean | — | Also erases the record of the last offense |

### How to do each operation

**Block**

```json
{ "status": "blocked", "reason": "reported_abuse" }
```

**Unblock**

```json
{ "status": "active" }
```

**Reset the strikes without unblocking**

```json
{ "resetStrikes": true }
```

**Unblock and erase the whole moderation history**

```json
{ "status": "active", "clearHistory": true }
```

### What each field does

#### `status: "blocked"`

1. It leaves the contact with `status: "blocked"`, so their **future** conversations are born marked as spam and agents skip them.
2. It records `moderation.blockedAt`, `moderation.blockedBy` and `moderation.blockedReason`.
3. It marks as `spam` the conversations the contact already had open, so the block applies right away. Those already in `spam`, `finished` or `expired` are not touched.

<Note type="tip">

Blocking stops replies in open threads. You may receive a `conversation.status.updated` for each affected thread, in addition to `client.updated`.

</Note>

#### `status: "active"`

1. It leaves the contact with `status: "active"` and clears the `moderation.blocked*` fields.
2. It **sets the strikes to zero**, even if you did not ask for it.
3. It returns to `finished` the conversations that were in `spam`.

#### `resetStrikes` and `clearHistory`

`resetStrikes` sets `moderation.totalStrikes` to zero and erases `moderation.lastAction`. `clearHistory` also erases `moderation.lastFlaggedAt`, `lastSource`, `lastCategories`, `lastMatchedTerms` and `lastSeverity`.

Neither changes the `status`: resetting strikes does not unblock the contact. You can clear accumulated violations without changing their status.

## Response

```json
{
  "status": "success",
  "message": "Client moderation updated successfully",
  "data": {
    "id": "274fc73cb7d84a17955914fdc1a1f9d0",
    "status": "active",
    "strikesReset": true,
    "clearedHistory": false,
    "previousStrikes": 3,
    "conversationsUpdated": 2
  }
}
```

| Field | Description |
|-------|-------------|
| `id` | Internal ID of the contact |
| `status` | Status the contact ended up with |
| `strikesReset` | Whether the strikes were set to zero |
| `clearedHistory` | Whether the record of the last offense was erased |
| `previousStrikes` | Strikes the contact had before the call |
| `conversationsUpdated` | How many conversations were synced. Always `0` if you did not send `status` |

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | The body asks for nothing (`details.issues` points at `status`), has unknown fields, `status` is not `active` or `blocked`, or `reason` is not between 1 and 120 characters |
| `400` | `INVALID_REQUEST` | The credential covers several workspaces and `?workspace=` is missing, or the supplied workspace is not authorized. `details.available` lists the available ones and `details.requested` shows the one you sent |
| `401` | `UNAUTHENTICATED` | The credential is missing or invalid |
| `403` | `FORBIDDEN` | The credential does not have the Contacts module (`Missing contacts permission`), or the user's role is read-only |
| `403` | `INSUFFICIENT_SCOPE` | An OAuth token without the `platica:write` scope tried to write. `details.requiredScope` says which one is missing |
| `404` | `CLIENT_NOT_FOUND` | No contact in that workspace has that identifier, it was deleted, or it is outside the reach of the user's role |
| `409` | `MULTIPLE_CONTACTS_MATCH` | Two contacts have that email: use the ID. `details.clientIds` lists them |

The general error format is in [Errors](/api-reference/errors).

## Notes

### Webhooks

| What you sent | `source` of `client.updated` |
|---------------|------------------------------|
| `status: "blocked"` | `api.client.blocked` |
| `status: "active"` | `api.client.unblocked` |
| Only `resetStrikes` / `clearHistory` | `api.client.strikes_reset` |

When you send `status` you also receive a `conversation.status.updated` for each synced conversation.

<Note type="tip">

`PATCH /v1/clients/{id}` with `{"status": "blocked"}` also applies this moderation and accepts an ID, phone number or email. Use the ID for webchat, Instagram or Telegram contacts that have no phone number.

</Note>
