# UpdateListing

## Permission Scope

marketplace

## Overview

UpdateListing revises listing metadata such as identifiers, assortment settings, or channel-specific operational attributes before or after activation when policy permits.

## Business Rules

- Retired listings cannot be updated through this command.
- Updated external identifiers must remain unique within the channel context.

## Process Flow

```mermaid
flowchart TD
    A[Receive update request] --> B[Load listing]
    B --> C{Listing retired?}
    C -->|Yes| D[Return LISTING_NOT_EDITABLE]
    C -->|No| E[Validate changed metadata]
    E --> F[Persist listing changes]
    F --> G[Return updated listing]
```

## External Dependencies

- [getListing](../query/GetListing.md) - Load the current listing and channel context.

## Error Scenarios

- **LISTING_NOT_FOUND**: Referenced listing does not exist.
- **LISTING_NOT_EDITABLE**: Retired listings cannot be updated.
- **DUPLICATE_EXTERNAL_IDENTIFIER**: External identifier conflicts with another listing on the same channel.

## Test Cases

- updates listing metadata while listing remains active or paused
- returns error when listing is retired
- returns error when updated external identifier conflicts with another listing
