# Appeals

## Overview

The Appeal API allows users to submit appeals against moderation decisions and enables moderators to review and decide on those appeals. Appeals can be submitted against review queue items (such as deleted messages, activities, or reactions) or against user bans (both global and channel-specific bans).

## Submit Appeal

This endpoint allows users to submit an appeal against a moderation decision. You can appeal against:

- **Deleted Content**
- **Blocked content**
- **User Bans**: Appeals against user bans (both global bans and channel-specific bans)

For each appeal, there must be an associated review queue item or a user ban. When appealing against content, only the user who created the content can submit an appeal. When appealing against a user ban, only the banned user can submit an appeal.

```php label="PHP"
$client->appeal(new AppealRequest(
    appealReason: 'I believe my message was wrongfully blocked',
    entityID: $contentEntityId,
    entityType: 'stream:chat:v1:message',
    attachments: ['imageurl'],
    userID: $userId,
));
```

### Request Parameters

| key           | required | type   | description                                                                                                                                                                            |
| ------------- | -------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| entity_id     | true     | string | Unique identifier of the entity being appealed. For user bans, this should be the user ID. For content, this should be the message/activity/reaction ID.                               |
| entity_type   | true     | string | Type of entity being appealed. Examples: `stream:chat:v1:message`, `stream:feeds:v2:activity`, `stream:feeds:v2:reaction`, `stream:user` (for user bans), or your own type (`listing`) |
| channel_cid   | false    | string | Only used when `entity_type` is `stream:user`. Identifies which ban is being appealed: omit to appeal the global ban, or set it to appeal that channel's ban.                          |
| appeal_reason | true     | string | Explanation for why the content is being appealed. Required. Maximum 500 characters; longer reasons are rejected.                                                                      |
| attachments   | false    | array  | Array of attachment URLs (e.g., images) providing evidence for the appeal. Maximum 10 attachments.                                                                                     |

### Response

| key       | type   | description                                   |
| --------- | ------ | --------------------------------------------- |
| appeal_id | string | Unique identifier of the created appeal item. |

### Appeal Rules and Restrictions

#### Appeals Against Content

Users can appeal Stream Chat messages, Stream Feeds activities, reactions, and comments, and your own (standalone) entity types. Any content that has a review queue item can be appealed: send its `entity_type` and `entity_id`.

- Only the user who created the entity can appeal against actions taken on it
- You cannot appeal if the item is unreviewed and just flagged (unless the recommended action is "remove")
- You cannot appeal against shadow-banned content
- You cannot appeal if the content is not deleted (for reviewed Stream Chat and Feeds items). Standalone entity types have no such check, since Stream doesn't store that content
- You cannot appeal if an appeal already exists for the item

#### Appeals Against User Bans

- Only the banned user can appeal against their own ban
- Use `channel_cid` to identify which ban you're appealing: omit it to appeal the global ban, or set it to appeal a specific channel's ban. The specific ban named by `channel_cid` (or the global ban, if omitted) must currently be active.
  - If `channel_cid` is omitted and the user has no global ban but has exactly one active channel ban, that channel ban is resolved automatically (for clients that predate this parameter). If the user has active bans in more than one channel, `channel_cid` is required — the request is rejected as ambiguous otherwise.
- You cannot submit a new appeal if a submitted appeal already exists **for that same ban** — but a user can hold multiple simultaneous open appeals across different bans at once (e.g. the global ban and several channel bans), up to a maximum of **10 simultaneously open ban appeals per user**
- Once a ban appeal is decided (accepted or rejected), the same ban can be appealed again if the user is banned on it again later

### Example: Appeal Against User Ban

```php label="PHP"
$client->appeal(new AppealRequest(
    appealReason: 'Appeal to unban me',
    entityID: $userId,
    entityType: 'stream:user',
    attachments: ['imageurl'],
    userID: $userId,
));
```

### Example: Appeal Against a Channel-Specific Ban

To appeal a ban that only applies to one channel (rather than the global ban), set `channel_cid`:

```php label="PHP"
$client->appeal(new AppealRequest(
    appealReason: 'I was wrongly banned from this channel',
    entityID: $userId,
    entityType: 'stream:user',
    channelCID: 'messaging:general',
    userID: $userId,
));
```

A user banned both globally and in one or more channels can submit an independent appeal for each ban — the global ban and every channel ban are appealed and decided separately.

## Query Appeals

This endpoint allows you to query appeals with filters, sorting, and pagination. Client-side requests only return the signed-in user's own appeals, unless that user's role has the `ViewAppeals` permission. Use server-side requests for moderator tools that need to see all appeals.

```php label="PHP"
$client->queryAppeals(new QueryAppealsRequest(
    filter: ['id' => ['$eq' => 'appeal_id']],
    sort: [new SortParam(field: 'created_at', direction: -1)],
    limit: 20,
));
```

### Request Parameters

| key    | required | type   | description                                   |
| ------ | -------- | ------ | --------------------------------------------- |
| filter | false    | object | Filter conditions for appeals (see below)     |
| sort   | false    | array  | Sorting parameters for appeals                |
| limit  | false    | number | Maximum number of appeals to return           |
| next   | false    | string | Cursor for pagination (from previous request) |

### Supported Filters

You can filter appeals by the following fields:

| field       | type     | description                                                  |
| ----------- | -------- | ------------------------------------------------------------ |
| id          | string   | Filter by specific appeal ID                                 |
| user_id     | string   | Filter by user ID who created the appeal                     |
| entity_type | string   | Filter by entity type (e.g., `stream:chat:v1:message`)       |
| entity_id   | string   | Filter by entity ID                                          |
| status      | string   | Filter by appeal status: `submitted`, `accepted`, `rejected` |
| created_at  | datetime | Filter by creation date                                      |
| updated_at  | datetime | Filter by last update date                                   |

### Response

| key   | type   | description                         |
| ----- | ------ | ----------------------------------- |
| items | array  | List of appeal items                |
| next  | string | Next cursor for pagination (if any) |

## Get Appeal

This endpoint allows you to retrieve a specific appeal item by its ID. When used from the client-side, users can only retrieve their own appeals.

```php label="PHP"
$client->getAppeal('appeal_id');
```

### Request Parameters

| key | required | type   | description                     |
| --- | -------- | ------ | ------------------------------- |
| id  | true     | string | Unique identifier of the appeal |

### Response

| key  | type   | description                   |
| ---- | ------ | ----------------------------- |
| item | object | Appeal item with full details |

The appeal item includes:

- `id`: Appeal ID
- `user`: User who created the appeal
- `entity_type`: Type of entity being appealed
- `entity_id`: ID of the entity being appealed
- `channel_cid`: For content appeals, the channel the entity belongs to (if applicable). For `stream:user` appeals, identifies which ban is being appealed — empty for the global ban.
- `appeal_reason`: Appeal Reason/explanation
- `status`: Appeal status (`submitted`, `accepted`, `rejected`)
- `decision_reason`: Reason provided by moderator (if decided)
- `attachments`: Array of attachment URLs
- `created_at`: When the appeal was created
- `updated_at`: When the appeal was last updated

## Resolve an appeal

The [Submit Action](https://getstream.io/moderation/docs/php/content-moderation/actions/#submit-action) endpoint can be used to accept or reject appeals when taking moderation actions. Most moderation actions automatically accept an appeal if one exists for the review queue item.

### Accepting Appeals

The following actions automatically accept an appeal if one exists:

- `unban`: Unbanning a user
- `mark_reviewed`: Marking an item as reviewed
- `restore`: Restoring deleted, blocked, or shadow-blocked content
- `unblock`: Deprecated. Use `restore`

When performing these actions, you can optionally provide a `decision_reason` to explain why the appeal was accepted. The user who appealed sees it. For an internal note that only moderators see, set `reason` in the same object (`mark_reviewed` and `restore`). See [Moderator notes](https://getstream.io/moderation/docs/php/content-moderation/actions/#moderator-notes).

When `mark_reviewed` accepts an appeal and the content is restored automatically, the action is logged as `restore` and keeps `mark_reviewed.reason`.

```php label="PHP"
// Approve appeal while unbanning user
$client->submitAction(new SubmitActionRequest(
    actionType: 'unban',
    appealId: 'appeal_id',
    unban: new UnbanActionRequestPayload(
        decisionReason: 'I am unbanning a user',
    ),
    userID: $moderatorId,
));

// Approve appeal while restoring content
$client->submitAction(new SubmitActionRequest(
    actionType: 'restore',
    itemID: 'item_id',
    restore: new RestoreActionRequestPayload(
        decisionReason: 'I am restoring content',
    ),
    userID: $moderatorId,
));
```

### Rejecting Appeals

To reject an appeal, use the `reject_appeal` action type:

```php label="PHP"
$client->submitAction(new SubmitActionRequest(
    actionType: 'reject_appeal',
    appealId: 'appeal_id',
    rejectAppeal: new RejectAppealRequestPayload(
        decisionReason: 'I am rejecting your appeal',
    ),
    userID: $moderatorId,
));
```

### Request Parameters for Appeal Actions

| key             | required | type   | description                                                                                                            |
| --------------- | -------- | ------ | ---------------------------------------------------------------------------------------------------------------------- |
| action_type     | true     | string | Type of action: `unban`, `restore`, `mark_reviewed`, or `reject_appeal`. `unblock` is deprecated; use `restore`.       |
| item_id         | false    | string | Review queue item ID (required for most actions, except `reject_appeal` and `unban` without review queue item)         |
| appeal_id       | false    | string | Appeal ID (required for `reject_appeal`, optional for other actions - will be inferred from `item_id` if not provided) |
| decision_reason | false    | string | Not a top-level field. Set it inside `unban`, `restore`, `mark_reviewed`, or `reject_appeal`.                          |
| action_params   | false    | object | Action-specific parameters (e.g., `unban`, `restore`, `unblock`, `reject_appeal`)                                      |

### Appeal Status Values

Appeals can have the following statuses:

- `submitted`: The appeal has been submitted and is awaiting review
- `accepted`: The appeal has been accepted by a moderator
- `rejected`: The appeal has been rejected by a moderator

The `decided_by` field is automatically populated with the moderator's user ID when an appeal is accepted or rejected. This field is not shown to users but is tracked internally for audit purposes.

## Bulk action

`POST /api/v2/moderation/appeals/bulk_action` applies one action to many appeals. Send 1 to 100 `appeal_ids`. `action_type` is `unban`, `restore`, `mark_reviewed`, or `reject_appeal`. `unblock` is accepted and deprecated; use `restore`.

```js label="Node.js"
await client.moderation.bulkActionAppeals({
  action_type: "restore",
  appeal_ids: ["appeal_1", "appeal_2"],
  restore: { decision_reason: "Restored after review" },
  user_id: moderatorId,
});
```

## Filter by Appeal in Query Review Queue

The [Query Review Queue](https://getstream.io/moderation/docs/php/content-moderation/review-queue/#query-review-queue) endpoint supports filtering by appeal-related fields. This allows you to:

- Filter review queue items that have appeals
- Filter by appeal status
- Filter by specific appeal ID

This is particularly useful for implementing moderation dashboards where you want to show items with pending appeals separately from other items.

### Appeal Filters in Query Review Queue

| filter        | type    | description                                                                 |
| ------------- | ------- | --------------------------------------------------------------------------- |
| appeal        | boolean | Filter items that have an appeal (`true`) or don't have an appeal (`false`) |
| appeal_status | string  | Filter items by appeal status: `submitted`, `accepted`, `rejected`          |
| appeal_id     | string  | Filter items by specific appeal ID                                          |

### Example: Query Review Queue Items with Appeals

```php label="PHP"
// Query items with submitted appeals
$client->queryReviewQueue(new QueryReviewQueueRequest(
    filter: ['appeal' => true, 'appeal_status' => 'submitted'],
    sort: [new SortParam(field: 'created_at', direction: -1)],
    limit: 20,
));

// Query items with a specific appeal
$client->queryReviewQueue(new QueryReviewQueueRequest(
    filter: ['appeal_id' => ['$eq' => 'appeal_id']],
    sort: [new SortParam(field: 'created_at', direction: -1)],
    limit: 20,
));
```

Instead of moving review queue items from "Reviewed" to "Inbox" or vice versa, you can query review queue items with appeal status filters. This approach avoids potential problems that could arise from changing the status of review queue items and provides a more flexible way to organize your moderation workflow.

## Complete Workflow Example

Here's a complete example of the appeal workflow:

1. **User submits an appeal** against deleted content:

```jsx
const appealResponse = await client.moderation.appeal(
  {
    appealReason: "This message was deleted by mistake. Please restore it.",
    entityID: "message_id",
    entityType: "stream:chat:v1:message",
    attachments: [],
  },
  { user_id: userId },
);

console.log("Appeal ID:", appealResponse.appeal_id);
```

2. **Moderator queries appeals** to see pending appeals:

```jsx
const appeals = await client.moderation.queryAppeals({
  filter: {
    status: "submitted",
  },
  sort: [{ field: "created_at", direction: -1 }],
  limit: 50,
});
```

3. **Moderator reviews the appeal** and decides to accept it by restoring the content:

```jsx
await client.moderation.submitAction(
  {
    action_type: "restore",
    item_id: "review_queue_item_id",
    restore: {},
    decision_reason: "The content was deleted by mistake. Appeal accepted.",
  },
  { user_id: moderatorId },
);
```

4. **User queries their appeals** to see the decision:

```jsx
const myAppeals = await client.moderation.queryAppeals(
  {
    filter: {},
    sort: [{ field: "created_at", direction: -1 }],
    limit: 20,
  },
  { user_id: userId },
);
```

5. **User gets specific appeal details**:

```jsx
const appeal = await client.moderation.getAppeal(appealResponse.appeal_id, {
  user_id: userId,
});
console.log("Appeal status:", appeal.item.status);
console.log("Decision reason:", appeal.item.decision_reason);
```

---

For the most recent version of this documentation, visit [https://getstream.io/moderation/docs/php/content-moderation/appeals/](https://getstream.io/moderation/docs/php/content-moderation/appeals/).