# Commands

These services provide the ability to perform actions such as commands, cancellations, or completion procedures for a package or transfer. The commands that can be executed for a Package or Transfer object are dependent on the current status of the relevant record. When a GET request is sent with the object's ID (PK) to be processed, the commands that can be run are listed under the "commands" keyword.

**Regardless of scenarios, the process of lowering and raising quotas continues, the quota amount continues to increase and decrease on a location basis. However, for these alterations to impact planning, the scenario rules must have the SELECT\_BY\_QUOTA value.**

* The maximum quota value specifies how many packages can be created from the respective location. The quota value is a user-unspecified parameter used for monitoring the maximum quota value and performing increase or decrease operations.
* max\_quota - quota = available\_quota
* If the available\_quota value is 0, no packages can be created. (To encounter this scenario, the SELECT\_BY\_QUOTA value must be chosen in the scenario rules.)
* For packages with a status below 400 and in the cancellation\_waiting state, the quota value increases by 1. (During this stage, when the package is in the waiting state, the quota amount is considered to increase by 1.)
* Upon packaging a package, the quota value decreases by 1. Consequently, the available\_quota increases, enhancing the likelihood of packaging from the respective location.
* In the event of a package cancellation, the quota amount decreases by 1 in a similar way.

## <mark style="color:red;">Usage</mark>​ <a href="#usage" id="usage"></a>

A sample packaging order: `https://<customer>-oms.akinon.net/api/v1/oms/packages/{package_id}`

* Package ID: XXX
* Transition ID: NNN (set after OMS installation)
* Slug: unique-slug-value

**Note:** When you execute a command, you must use Transition ID or Slug value. One is enough to execute command that you need. In the examples, the slug and TransitionID can be seen together, however you may only choose one when you send request.

**Command List Example:**

```
 [
  {
    "id": 1841, // TransitionID
    "label": "Test Label",
    "ui_visibility": [
      "oms_web"
    ],
    "slug": "package__assign_package_items_manually__waiting__packaging-canceled", // Unique-Slug
    "created_date": "2023-02-28T08:48:29.679101Z",
    "modified_date": "2023-02-28T08:48:29.679141Z",
    "translations": null,
    "command": "ASSIGN_PACKAGE_ITEMS_MANUALLY",
    "source_state": 33,
    "destination_state": 44
  },
  {
    "id": 1809,
    "label": "Test-2 Label",
    "ui_visibility": [
      "third_party",
      "oms_web",
      "instore"
    ],
    "slug": "package__pkg_state_transition__uzaktan-eylem-bekleniyor__hazırlanıyor",
    "created_date": "2023-02-03T11:16:08.065410Z",
    "modified_date": "2023-02-14T10:38:27.133471Z",
    "translations": null,
    "command": "PKG_STATE_TRANSITION",
    "source_state": 142,
    "destination_state": 34
  }
]
```

The system distinguishes the command to be run by the relevant ID (PK) and slug value. The command IDs will therefore be required in the future.

## <mark style="color:red;">Commands Examples​</mark> <a href="#commands-examples" id="commands-examples"></a>

### <mark style="color:red;">1. Pack Command​</mark> <a href="#id-1-pack-command" id="id-1-pack-command"></a>

The "pack" command is used to signify that the products are ready once all products to be placed in the package are confirmed to be in the current location. Executing this command generates the OMS Shipping information for the packaged products and prepares the Shipment receipt information, which can then be printed on the physical package. It should be noted that the shipment receipt is obtained from the integrated shipping company. Below is an example of how to execute the "pack" command.

**Request `POST`​**

**Path:** `<OMS_URL>/api/v1/oms/packages/<package_id>/command/`

**Request Header​**

**Content-Type:** `application/json`

**Request Body​**

```
{
  "transition": 333,
  "input_parameters": {},
  "slug": "unique-slug-value"
}
```

**Request Parameters​**

<table><thead><tr><th width="167.66015625">Name</th><th width="134.90625">Data Type</th><th>Explanation</th></tr></thead><tbody><tr><td>OMS_URL</td><td>string</td><td>The base URL information of the OMS application.</td></tr><tr><td>package_id</td><td>int</td><td>The ID of the package used to run the command.</td></tr><tr><td>transition_id</td><td>int</td><td>The ID of the “Pack” command in the commands listed when a GET request is sent to the package object.</td></tr><tr><td>slug</td><td>string</td><td>The Slug of the “Pack” command in the commands listed when a GET request is sent to the package object.</td></tr></tbody></table>

**Failed Response Example​**

**Error code: 406**

```
{
  "error": {
    "non_field_errors": "Command definition is not allowed! Check source & destination states of command to be created",
    "error_code": "commands_100_1"
  },
  "status_code": 406
}
```

***

### <mark style="color:red;">2. Ship Command​</mark> <a href="#id-2-ship-command" id="id-2-ship-command"></a>

The command that must be run after a package has been shipped. It signifies that the package has been shipped from the relevant store or warehouse.

**Request `POST`​**

**Path:** `<OMS_URL>/api/v1/oms/packages/<package_id>/command/`

**Request Header​**

**Content-Type:** `application/json`

**Request Body​**

```
{
  "transition": 333,
  "input_parameters": {
    "package_items": [
      1,
      2,
      3
    ]
  },
  "slug": "unique-slug-value"
}
```

**Request Parameters​**

<table><thead><tr><th width="173.0078125">Name</th><th width="125.02734375">Data Type</th><th>Explanation</th></tr></thead><tbody><tr><td>OMS_URL</td><td>string</td><td>The base URL information of the OMS application.</td></tr><tr><td>package_id</td><td>int</td><td>The ID of the package used to run the command.</td></tr><tr><td>transition_id</td><td>int</td><td>The ID of the “Pack” command in the commands listed when a GET request is sent to the package object.</td></tr><tr><td>slug</td><td>string</td><td>The Slug of the “Pack” command in the commands listed when a GET request is sent to the package object.</td></tr><tr><td>package_items</td><td>int array</td><td>Information regarding the package IDs of listed products that are faulty or unavailable. By sending a GET request for the relevant package, you can access the ID information of the package items under “packageitem_set” in the incoming result. When a request is sent successfully, a response is returned with the code 200 in the following format.</td></tr></tbody></table>

**Successful Response Example​**

**Error code: 200**

```
{
  "package_id": "<package_id>",
  "package_number": "<package_number>",
  "package_stock_location_id": "<stock_location_id>",
  "package_stock_location_name": "<stock_location_name>",
  "is_same_location": "<bool_value>"
}
```

**Response Parameters​**

| Name                           | Data Type | Explanation                                                                                                                                                                                                              |
| ------------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| package\_id                    | int       | The ID of the package used to run the command.                                                                                                                                                                           |
| package\_number                | string    | The numerical information for the relevant package.                                                                                                                                                                      |
| package\_stock\_location\_id   | int       | The ID information of the stock location for the relevant package.                                                                                                                                                       |
| package\_stock\_location\_name | string    | The name information of the stock location for the relevant package.                                                                                                                                                     |
| is\_same\_location             | bool      | The information regarding whether the relevant package exists in the same stock location, returned True or False In case of any problems, the response content related to the error with the error code 406 is returned. |

**Failed Response Example​**

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command definition is not allowed! Check source & destination states of command to be created",
    "error_code": "commands_100_1"
  },
  "status_code": 406
}
```

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command id and slug mismatch",
    "error_code": "commands_100_5"
  },
  "status_code": 406
}
```

**Status code: 400 (Validation Error)**

```
{
  "error": {
    "non_field_errors": "transition or slug required"
  },
  "status_code": 400
}
```

***

### <mark style="color:red;">3. Out-of-stock Command​</mark> <a href="#id-3-out-of-stock-command" id="id-3-out-of-stock-command"></a>

This command is used to indicate that one or more products in a package is/are unavailable in the relevant location. When this command is run, it will revise the products marked as “OMS Not Found” and “Needs Rescheduling”. If there is available stock, the command will assign it for packaging at a different location.

**Request `POST`​**

**Path:** `<OMS_URL>/api/v1/oms/packages/<package_id>/command/`

**Request Header​**

**Content-Type:** `application/json`

**Request Body​**

```
{
  "transition": 333,
  "input_parameters": {
    "package_items": [
      1,
      2,
      3
    ]
  },
  "slug": "unique-slug-value"
}
```

**Request Parameters​**

| Name           | Data Type | Explanation                                                                                                                                                                                                                                                                                                                                                |
| -------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OMS\_URL       | string    | The base URL information of the OMS application.                                                                                                                                                                                                                                                                                                           |
| package\_id    | int       | The ID of the package used to run the command.                                                                                                                                                                                                                                                                                                             |
| transition\_id | int       | The ID of the “Pack” command in the commands listed when a GET request is sent to the package object.                                                                                                                                                                                                                                                      |
| slug           | string    | The Slug of the “Pack” command in the commands listed when a GET request is sent to the package object.                                                                                                                                                                                                                                                    |
| package\_items | int array | Information regarding the package IDs of listed products that are faulty or unavailable. By sending a GET request for the relevant package, you can access the ID information of the package items under “packageitem\_set” in the incoming result. When a request is sent successfully, a response is returned with the code 200 in the following format. |

**Successful Response Example​**

**Error code: 200**

```
{
  "package_id": "<package_id>",
  "package_number": "<package_number>",
  "package_stock_location_id": "<stock_location_id>",
  "package_stock_location_name": "<stock_location_name>",
  "is_same_location": "<bool_value>"
}
```

**Response Parameters​**

<table><thead><tr><th width="181.39453125">Name</th><th width="129.8828125">Data Type</th><th>Explanation</th></tr></thead><tbody><tr><td>package_id</td><td>int</td><td>The ID of the package used to run the command.</td></tr><tr><td>package_number</td><td>string</td><td>The numerical information for the relevant package.</td></tr><tr><td>package_stock_location_id</td><td>int</td><td>The ID information of the stock location for the relevant package.</td></tr><tr><td>package_stock_location_name</td><td>string</td><td>The name information of the stock location for the relevant package.</td></tr><tr><td>is_same_location</td><td>bool</td><td>The information regarding whether the relevant package exists in the same stock location, returned True or False In case of any problems, the response content related to the error with the error code 406 is returned.</td></tr></tbody></table>

**Failed Response Example​**

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command definition is not allowed! Check source & destination states of command to be created",
    "error_code": "commands_100_1"
  },
  "status_code": 406
}
```

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command id and slug mismatch",
    "error_code": "commands_100_5"
  },
  "status_code": 406
}
```

**Status code: 400 (Validation Error)**

```
{
  "error": {
    "non_field_errors": "transition or slug required"
  },
  "status_code": 400
}
```

***

### <mark style="color:red;">4. Repack Command​</mark> <a href="#id-4-repack-command" id="id-4-repack-command"></a>

The command used to reschedule packages that have been marked “Out of Stock” or “Needs Rescheduling” by OMS, and used to prepare them for packaging.

**Request `POST`​**

**Path:** `<OMS_URL>/api/v1/oms/packages/<package_id>/command/`

**Request Header​**

**Content-Type:** `application/json`

**Request Body​**

```
{
  "transition": 333,
  "input_parameters": {},
  "slug": "unique-slug-value"
}
```

**Request Parameters​**

<table><thead><tr><th width="155.38671875">Name</th><th width="139.67578125">Data Type</th><th>Explanation</th></tr></thead><tbody><tr><td>OMS_URL</td><td>string</td><td>The base URL information of the OMS application.</td></tr><tr><td>package_id</td><td>int</td><td>The ID of the package used to run the command.</td></tr><tr><td>transition_id</td><td>int</td><td>The ID of the “Pack” command in the commands listed when a GET request is sent to the package object. When a request is sent successfully, a response is returned with the code 200 in the following format. In case of any problems, the response content related to the error with the error code 406 is returned.</td></tr><tr><td>slug</td><td>string</td><td>The Slug of the “Pack” command in the commands listed when a GET request is sent to the package object.</td></tr></tbody></table>

**Failed Response Example​**

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command definition is not allowed! Check source & destination states of command to be created",
    "error_code": "commands_100_1"
  },
  "status_code": 406
}
```

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command id and slug mismatch",
    "error_code": "commands_100_5"
  },
  "status_code": 406
}
```

**Status code: 400 (Validation Error)**

```
{
  "error": {
    "non_field_errors": "transition or slug required"
  },
  "status_code": 400
}
```

### <mark style="color:red;">5. Pack Order Command From Different Channels​</mark> <a href="#id-5-pack-order-command-from-different-channels" id="id-5-pack-order-command-from-different-channels"></a>

This command indicates that the products are prepared for shipment once all products intended for the package are confirmed to be in the current location. However, unlike the "Pack" command, this command does not generate any shipping documents. Instead, it proceeds directly to the shipment stage.

**Request `POST`​**

**Path:** `<OMS_URL>/api/v1/oms/packages/<package_id>/command/`

**Request Header​**

**Content-Type:** `application/json`

**Request Body​**

```
{
  "transition": 333,
  "input_parameters": {},
  "slug": "unique-slug-value"
}
```

**Request Parameters​**

<table><thead><tr><th width="172.36328125">Name</th><th width="154.87890625">Data Type</th><th>Explanation</th></tr></thead><tbody><tr><td>OMS_URL</td><td>string</td><td>The base URL information of the OMS application.</td></tr><tr><td>package_id</td><td>int</td><td>The ID of the package used to run the command.</td></tr><tr><td>transition_id</td><td>int</td><td>The ID of the “Pack” command in the commands listed when a GET request is sent to the package object. When a request is sent successfully, a response is returned with the code 200 in the following format. In case of any problems, the response content related to the error with the error code 406 is returned.</td></tr><tr><td>slug</td><td>string</td><td>The Slug of the “Pack” command in the commands listed when a GET request is sent to the package object.</td></tr></tbody></table>

**Failed Response Example​**

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command definition is not allowed! Check source & destination states of command to be created",
    "error_code": "commands_100_1"
  },
  "status_code": 406
}
```

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command id and slug mismatch",
    "error_code": "commands_100_5"
  },
  "status_code": 406
}
```

**Status code: 400 (Validation Error)**

```
{
  "error": {
    "non_field_errors": "transition or slug required"
  },
  "status_code": 400
}
```

### <mark style="color:red;">6. Advanced Ship Command​</mark> <a href="#id-6-advanced-ship-command" id="id-6-advanced-ship-command"></a>

The command that must be run after a package has been shipped. Unlike the standard ship command, the shipping company and number must be provided as parameters.

**Request `POST`​**

**Path:** `<OMS_URL>/api/v1/oms/packages/<package_id>/command/`

**Request Header​**

**Content-Type:** `application/json`

**Request Body​**

```
{
  "transition": 333,
  "input_parameters": {
    "tracking_number": "<tracking_number>",
    "cargo_company": "str or id !!!!!!!!!!!!!!"
  },
  "slug": "unique-slug-value"
}
```

**Request Parameters​**

| Name             | Data Type | Explanation                                                                                                                |
| ---------------- | --------- | -------------------------------------------------------------------------------------------------------------------------- |
| OMS\_URL         | string    | The base URL information of the OMS application.                                                                           |
| package\_id      | int       | The ID of the package used to run the command.                                                                             |
| transition\_id   | int       | The ID of the “Pack” command in the commands listed when a GET request is sent to the package object.                      |
| slug             | string    | The Slug of the “Pack” command in the commands listed when a GET request is sent to the package object.                    |
| tracking\_number | string    | The shipping number of the package to be shipped.                                                                          |
| cargo\_company   | int       | The ID of a shipping company that can be accessed upon issuing a GET request to “/api/v1/oms/cargo-company/” must be sent. |

When a request is sent successfully, a response is returned with the code 200 in the following format. In case of any problems, the response content related to the error with the error code 406 is returned.

**Failed Response Example​**

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command definition is not allowed! Check source & destination states of command to be created",
    "error_code": "commands_100_1"
  },
  "status_code": 406
}
```

**Status code: 406**

```
{
  "error": {
    "non_field_errors": "Command id and slug mismatch",
    "error_code": "commands_100_5"
  },
  "status_code": 406
}
```

**Status code: 400 (Validation Error)**

```
{
  "error": {
    "non_field_errors": "transition or slug required"
  },
  "status_code": 400
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akinon.com/technical-guides/oms/commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
