# Reason Codes

## Retrieves a list of reason codes, optionally filtered by search text.

`reason_codes.list_reason_codes(ReasonCodeListReasonCodesParams**kwargs)  -> ReasonCodeListReasonCodesResponse`

**get** `/api/v2/public/reasoncodes`

Retrieves a list of reason codes, optionally filtered by search text.

### Parameters

- `code: Optional[str]`

  Filter by reason code.

- `code_description: Optional[str]`

  Filter by reason code description.

- `function_key: Optional[str]`

  Filter by function key.

- `is_gain: Optional[bool]`

  Filter by gain-type reason codes.

- `is_loss: Optional[bool]`

  Filter by loss-type reason codes.

- `is_store: Optional[bool]`

  Filter by store-level reason codes.

### Returns

- `List[ReasonCodeListReasonCodesResponseItem]`

  - `code: int`

  - `is_comment_mandatory: bool`

  - `is_gain: bool`

  - `is_image_mandatory: bool`

  - `is_loss: bool`

  - `is_order_number_mandatory: bool`

  - `is_picking_list: bool`

  - `is_rollback_allowed: bool`

  - `is_sales_order_discsount: bool`

  - `is_store: bool`

  - `reason_code_type: int`

  - `review_status: int`

  - `code_description: Optional[str]`

  - `description: Optional[str]`

  - `function_key: Optional[str]`

  - `store_type: Optional[str]`

### Example

```python
import os
from colleqtive_sdk import Colleqtive

client = Colleqtive(
    bearer_token=os.environ.get("COLLEQTIVE_BEARER_TOKEN"),  # This is the default and can be omitted
)
response = client.reason_codes.list_reason_codes()
print(response)
```

#### Response

```json
[
  {
    "code": 0,
    "is_comment_mandatory": true,
    "is_gain": true,
    "is_image_mandatory": true,
    "is_loss": true,
    "is_order_number_mandatory": true,
    "is_picking_list": true,
    "is_rollback_allowed": true,
    "is_sales_order_discsount": true,
    "is_store": true,
    "reason_code_type": 0,
    "review_status": 0,
    "code_description": "code_description",
    "description": "description",
    "function_key": "function_key",
    "store_type": "store_type"
  }
]
```

## Create or update public v2 reason codes

`reason_codes.create_reason_codes(ReasonCodeCreateReasonCodesParams**kwargs)  -> ReasonCodeCreateReasonCodesResponse`

**post** `/api/v2/public/reasoncodes`

Creates or updates reason codes. See request schema for required fields and enum details.

### Parameters

- `reason_codes: Iterable[ReasonCode]`

  List of reason codes to create or update.

  - `default_review_status: int`

    Default review status value. Required.

  - `is_comment_mandatory: bool`

    Indicates if comment is mandatory. Required.

  - `is_gain: bool`

    Indicates if this is a gain reason code. Required.

  - `is_image_mandatory: bool`

    Indicates if image is mandatory. Required.

  - `is_loss: bool`

    Indicates if this is a loss reason code. Required.

  - `is_order_number_mandatory: bool`

    Indicates if order number is mandatory. Required.

  - `is_picking_list: bool`

    Indicates if used for picking list. Required.

  - `is_sales_order_discount: bool`

    Indicates if used for sales order discount. Required.

  - `is_store: bool`

    Indicates if the reason code is store-visible. Required.

  - `reason_code: int`

    Reason code identifier. Required.

  - `reason_code_description: str`

    Reason code description. Required. Max length: 250.

  - `reason_code_type: Literal[1, 2, 3, 6 more]`

    Allowed values:<br/>1 = LossReasonCode (Loss Reason Code)<br/>2 = RejectionReasonCode (Rejection Reason Code)<br/>3 = MovementReasonCode (Movement Reason Code)<br/>4 = SalesOrderDiscountReasonCode (Sales Order Discount Reason Code)<br/>5 = LocationTags (Location Tags Code)<br/>6 = CountReasonCode (Count Reason Code)<br/>7 = GainLossReasonCode (Gain Loss Code)<br/>8 = SalesOrderTypeReasonCode (Sales Order Type)<br/>9 = DeliveryOrderTypeReasonCode (Delivery Order Type)

    - `1`

    - `2`

    - `3`

    - `4`

    - `5`

    - `6`

    - `7`

    - `8`

    - `9`

  - `code_description: Optional[str]`

    Optional additional code description. Max length: 500.

- `flush: Optional[bool]`

  When true, existing reason codes are flushed before inserting.

### Returns

- `class ReasonCodeCreateReasonCodesResponse: …`

  Standard success response returned by mutation endpoints.

  - `success: bool`

    Indicates whether the operation completed successfully.

  - `data: Optional[str]`

    Optional data payload returned by the operation.

  - `message: Optional[str]`

    Human-readable message describing the result.

### Example

```python
import os
from colleqtive_sdk import Colleqtive

client = Colleqtive(
    bearer_token=os.environ.get("COLLEQTIVE_BEARER_TOKEN"),  # This is the default and can be omitted
)
response = client.reason_codes.create_reason_codes(
    reason_codes=[{
        "reason_code": 101,
        "reason_code_description": "Damaged on arrival",
        "is_store": True,
        "code_description": "Used when product arrives damaged",
        "is_loss": True,
        "is_comment_mandatory": True,
        "is_image_mandatory": False,
        "is_order_number_mandatory": False,
        "is_picking_list": False,
        "is_sales_order_discount": False,
        "default_review_status": 0,
        "reason_code_type": 1,
        "is_gain": False,
    }],
)
print(response.success)
```

#### Response

```json
{
  "success": true,
  "data": "data",
  "message": "message"
}
```

## Domain Types

### Reason Code List Reason Codes Response

- `List[ReasonCodeListReasonCodesResponseItem]`

  - `code: int`

  - `is_comment_mandatory: bool`

  - `is_gain: bool`

  - `is_image_mandatory: bool`

  - `is_loss: bool`

  - `is_order_number_mandatory: bool`

  - `is_picking_list: bool`

  - `is_rollback_allowed: bool`

  - `is_sales_order_discsount: bool`

  - `is_store: bool`

  - `reason_code_type: int`

  - `review_status: int`

  - `code_description: Optional[str]`

  - `description: Optional[str]`

  - `function_key: Optional[str]`

  - `store_type: Optional[str]`

### Reason Code Create Reason Codes Response

- `class ReasonCodeCreateReasonCodesResponse: …`

  Standard success response returned by mutation endpoints.

  - `success: bool`

    Indicates whether the operation completed successfully.

  - `data: Optional[str]`

    Optional data payload returned by the operation.

  - `message: Optional[str]`

    Human-readable message describing the result.
