# CreateChannel

## Permission Scope

marketplace

## Overview

CreateChannel creates a draft sales channel for one company and one external sell-side context such as a marketplace or storefront.

## Business Rules

- Record is always created in DRAFT status.
- Channel type is required.
- Channel name must be unique enough to avoid operational ambiguity within the company.

## Process Flow

```mermaid
flowchart TD
    A[Receive create request] --> B[Validate references and required fields]
    B --> C{Validation passed?}
    C -->|No| D[Return validation error]
    C -->|Yes| E[Insert draft Channel record]
    E --> F[Return created Channel]
```

## External Dependencies

- [organization::GetCompany](../../../organization/docs/queries/GetCompany.md) - Validate company scope for the channel.

## Error Scenarios

- **CHANNEL_NOT_FOUND**: Referenced channel does not exist
- **INVALID_CHANNEL_TYPE**: Channel type is missing or unsupported.
- **DUPLICATE_CHANNEL_NAME**: A conflicting channel name already exists.

## Test Cases

- creates a draft channel with valid type and company
- throws when required Channel fields are missing
- creates the Channel in DRAFT status
- throws when the company does not exist
- throws when a conflicting channel name already exists
