# StartSyncJob

## Permission Scope

marketplace

## Overview

StartSyncJob creates and starts a sync execution for one channel and one direction. It is the operational record used to track import, export, replay, or recovery work against the external channel integration.

## Business Rules

- Referenced channel must exist and be eligible for sync execution.
- Direction and execution context are required.
- New sync jobs start in RUNNING status with counts initialized to zero.

## Process Flow

```mermaid
flowchart TD
    A[Receive start request] --> B[Validate channel and direction]
    B --> C[Create SyncJob in RUNNING status]
    C --> D[Begin processing channel payloads or outbound events]
    D --> E[Persist counts and terminal outcome]
    E --> F[Return sync job summary]
```

## External Dependencies

- [getChannel](../queries/GetChannel.md) - Validate the target channel and company scope.

## Error Scenarios

- **CHANNEL_NOT_FOUND**: Referenced channel does not exist
- **CHANNEL_NOT_SYNCABLE**: Channel is inactive or blocked for new sync execution.
- **SYNC_DIRECTION_REQUIRED**: Sync direction is required.

## Test Cases

- starts a running sync job for an active channel
- initializes sync counts to zero
- throws when channel is inactive for new sync execution
- throws when direction is missing
