# Reason Codes

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

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

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

### Query Parameters

- `code: optional string`

  Filter by reason code.

- `code_description: optional string`

  Filter by reason code description.

- `function_key: optional string`

  Filter by function key.

- `is_gain: optional boolean`

  Filter by gain-type reason codes.

- `is_loss: optional boolean`

  Filter by loss-type reason codes.

- `is_store: optional boolean`

  Filter by store-level reason codes.

### Returns

- `code: number`

- `is_comment_mandatory: boolean`

- `is_gain: boolean`

- `is_image_mandatory: boolean`

- `is_loss: boolean`

- `is_order_number_mandatory: boolean`

- `is_picking_list: boolean`

- `is_rollback_allowed: boolean`

- `is_sales_order_discsount: boolean`

- `is_store: boolean`

- `reason_code_type: number`

- `review_status: number`

- `code_description: optional string`

- `description: optional string`

- `function_key: optional string`

- `store_type: optional string`

### Example

```http
curl https://api.colleqtive.net/api/v2/public/reasoncodes \
    -H "Authorization: $COLLEQTIVE_BEARER_TOKEN"
```

#### 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

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

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

### Query Parameters

- `flush: optional boolean`

  When true, existing reason codes are flushed before inserting.

### Body Parameters

- `reason_codes: array of object { default_review_status, is_comment_mandatory, is_gain, 10 more }`

  List of reason codes to create or update.

  - `default_review_status: number`

    Default review status value. Required.

  - `is_comment_mandatory: boolean`

    Indicates if comment is mandatory. Required.

  - `is_gain: boolean`

    Indicates if this is a gain reason code. Required.

  - `is_image_mandatory: boolean`

    Indicates if image is mandatory. Required.

  - `is_loss: boolean`

    Indicates if this is a loss reason code. Required.

  - `is_order_number_mandatory: boolean`

    Indicates if order number is mandatory. Required.

  - `is_picking_list: boolean`

    Indicates if used for picking list. Required.

  - `is_sales_order_discount: boolean`

    Indicates if used for sales order discount. Required.

  - `is_store: boolean`

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

  - `reason_code: number`

    Reason code identifier. Required.

  - `reason_code_description: string`

    Reason code description. Required. Max length: 250.

  - `reason_code_type: 1 or 2 or 3 or 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 string`

    Optional additional code description. Max length: 500.

### Returns

- `success: boolean`

  Indicates whether the operation completed successfully.

- `data: optional string`

  Optional data payload returned by the operation.

- `message: optional string`

  Human-readable message describing the result.

### Example

```http
curl https://api.colleqtive.net/api/v2/public/reasoncodes \
    -H 'Content-Type: application/json' \
    -H "Authorization: $COLLEQTIVE_BEARER_TOKEN" \
    -d '{
          "reason_codes": [
            {
              "default_review_status": 0,
              "is_comment_mandatory": true,
              "is_gain": false,
              "is_image_mandatory": false,
              "is_loss": true,
              "is_order_number_mandatory": false,
              "is_picking_list": false,
              "is_sales_order_discount": false,
              "is_store": true,
              "reason_code": 101,
              "reason_code_description": "Damaged on arrival",
              "reason_code_type": 1,
              "code_description": "Used when product arrives damaged"
            }
          ]
        }'
```

#### Response

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

## Domain Types

### Reason Code List Reason Codes Response

- `ReasonCodeListReasonCodesResponse = array of object { code, is_comment_mandatory, is_gain, 13 more }`

  - `code: number`

  - `is_comment_mandatory: boolean`

  - `is_gain: boolean`

  - `is_image_mandatory: boolean`

  - `is_loss: boolean`

  - `is_order_number_mandatory: boolean`

  - `is_picking_list: boolean`

  - `is_rollback_allowed: boolean`

  - `is_sales_order_discsount: boolean`

  - `is_store: boolean`

  - `reason_code_type: number`

  - `review_status: number`

  - `code_description: optional string`

  - `description: optional string`

  - `function_key: optional string`

  - `store_type: optional string`

### Reason Code Create Reason Codes Response

- `ReasonCodeCreateReasonCodesResponse object { success, data, message }`

  Standard success response returned by mutation endpoints.

  - `success: boolean`

    Indicates whether the operation completed successfully.

  - `data: optional string`

    Optional data payload returned by the operation.

  - `message: optional string`

    Human-readable message describing the result.
