# Onix API - Transfer orders (part 2/4) - Update order line's properties and form properties

**URL:** <https://community.onix.com/t/onix-api-transfer-orders-part-2-4-update-order-lines-properties-and-form-properties/627>\
**Category:** Knowledge base\
**Tags:** official, onix-api\
**Created:** [February 5, 2024, 3:28pm UTC](https://community.onix.com/t/onix-api-transfer-orders-part-2-4-update-order-lines-properties-and-form-properties/627 "2024-02-05T15:28:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![khoa.nguyen](https://dub1.discourse-cdn.com/flex013/user_avatar/community.onix.com/khoa.nguyen/32/1004_2.png) [@khoa.nguyen](https://community.onix.com/u/khoa.nguyen)\
**Post date:** [February 5, 2024, 3:28pm UTC](https://community.onix.com/t/onix-api-transfer-orders-part-2-4-update-order-lines-properties-and-form-properties/627/1 "2024-02-05T15:28:00Z")

</div>

This article is part of a series - click to read [part 1](https://community.onix.com/t/onixapi-transfer-orders-part-1-3/624), [part 3](https://community.onix.com/t/onixapi-transfer-orders-part-3-3/626) and [part 4](https://community.onix.com/t/onixapi-transfer-orders-part-1-4-create-an-order-or-order-line/624).

# 1. Update an order line’s properties

## API overview

| | |
| --- | --- |
| _Endpoint_ | `POST /v1/orders-lines/properties` |
| _Description_ | Update an order line’s properties. |
| _Usage_ | Make requests to this endpoint to update the order line’s properties.  
Only matched properties are updated; the rest is ignored. The rule is described in field `PropertyInfo` fields table.  
The order line’s properties come from the product’s properties or manually created by users on Onix Work. This endpoint does not support creating new properties.  
**Note** : Attempting to call this request for an order line when the workflow status on either itself or its order is marked as “ **Closed** ” will result in an error. |
| _Return_ | Returns a boolean value indicating the success of the updating process. |

## Request parameters and body

The corresponding request body type can be found at the Swagger page (see [Onix API overview](https://community.onix.com/t/onixapi-get-started/602#overview-1)), model `OrderLinePropertiesInfo` for the main request body and `OrderLineItemSerialInfo` for the `properties` model.

There are two ID pairs:

- `orderId` and `orderImportId`.
- `orderLineId` and `orderLineImportId`.

Despite those fields being nullable, the system requires the request body must contains at least one field for each pair.

Field precedence for ID pairs:

- `orderId` has _higher_ priority than `orderImportId`.
- `orderLineId` has _higher_ priority than `orderLineImportId`.

When a higher priority field is present, the lower priority field will be _ignored_.

When a field value is null, it follows the rules explained in section [API requests and responses](https://community.onix.com/t/onixapi-get-started/602#api-requests-and-responses-2), if no specific rules are mentioned.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `orderId` | `int` | **No** \* | The Onix Work system’s order ID.  
Either `orderId` or `orderImportId` must be provided.  
See field precendence above. |
| `orderImportId` | `string` | **No** \* | **Constraint** : length ≤ 50.  
Your system’s order ID.  
Either `orderId` or `orderImportId` must be provided.  
See field precendence above. |
| `orderLineId` | `int` | **No** \* | The Onix Work system’s order line ID.  
Either `orderLineId` or `orderLineImportId` must be provided.  
See field precendence above. |
| `orderLineImportId` | `string` | **No** \* | **Constraint** : length ≤ 50.  
Your system’s order line ID.  
Either `orderLineId` or `orderLineImportId` must be provided.  
See field precendence above. |
| `properties` | `PropertyInfo[]` | **Yes** | **Constraint** : length \> 0.  
The list of the order line’s properties.  
Only matched properties are updated; the rest are ignored.  
See the table below for more information and the properties update rule. |

## Response

| Status code | Response body | Description |
| --- | --- | --- |
| `200` | A boolean. | Indicate if the update process was successful or not. |
| `400` | The system’s standard error response object. | See an examples of error responses in section [API requests and responses](https://community.onix.com/t/onixapi-get-started/602#api-requests-and-responses-2). |

## Examples

Let’s use the `orderId` and `orderLineId` to update properties for the order line that’s just created in [part 1](https://community.onix.com/t/onixapi-transfer-orders-part-1-3/624):

- `orderId`: 546804.
- `orderLineId`: 3998608.

You can also use `orderImportId` and `orderLineImportId` instead.  
First, let’s examine the properties of the product that the order line has been using for better visualization:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/onix/original/2X/8/888728cb1a5556d215c5d89cfd5167b255a2d007.png)

Currently, there are two properties “_Color_” and “_Actual diameter (mm)_”, and the “_Color_” property has “_White_” as the default value. That means our order line also has two properties with the same values.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/onix/original/2X/d/dacc75fb0a40f6aa6476c5772a61846a94826c84.png)

To update the order line’s properties, make a request with the request body below, with `languageCode` is English (see [Onix API terminology](https://community.onix.com/t/onixapi-get-started/602#terminology-7)):

```js
{
  "orderId": 546804,
  "orderLineId": 3998608,
  "properties": [
    {
      "languageCode": 1,
      "description": "Color",
      "value": "Red"
    },
    {
      "languageCode": 1,
      "description": "Actual diameter (mm)",
      "value": "0.5"
    }
  ]
}

```

The system responsed with status code of 200, the response body indicates where the request was successful or not:

```js
true

```

The properties have been updated successfully. Let’s check the results in Onix Work by navigating to the order we have just been created in [part 1](https://community.onix.com/t/onixapi-transfer-orders-part-1-3/624) and click on the tab “ **Order lines** ” then “ **Properties** ” of the order line.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/onix/original/2X/9/9031088bd0af7c1c34be08a292cf85c13b69ff99.png)

The properties have updated according to the request. Let’s go to the next step: update the order line’s form properties.

# 2. Update an order line’s form properties

## API overview

| A | B |
| --- | --- |
| _Endpoint_ | `POST /v1/orders-lines/form-properties` |
| _Description_ | Update an order line’s form properties. |
| _Usage_ | Make requests to this endpoint to update the order line’s form properties.  
Only matched properties are updated; the rest is ignored. The rule is described in field ` FormPropertyKeyValueInfo` fields table.  
The order line’s form properties come from the product’s form properties or manually created by users on Onix Work. Make a request to this endpoint: `GET /v1/company/form-properties` to get a full list of available and editable form properties.  
**Note** : Attempting to call this request for an order line when the workflow status on either itself or its order is marked as “ **Closed** ” will result in an error. |
| _Return_ | Returns a boolean value indicating the success of the updating process. |

## Request parameters and body

The corresponding request body type can be found at the Swagger page (see [Onix API overview](https://community.onix.com/t/onixapi-get-started/602#overview-1)), model `OrderLineFormPropertiesInfo` for the main request body and `FormPropertyKeyValueInfo` for the `properties` model.

There are two ID pairs:

- `orderId` and `orderImportId`.
- `orderLineId` and `orderLineImportId`.

Despite those fields being nullable, the system requires the request body must contains at least one field for each pair.

Field precedence for ID pairs:

- `orderId` has _higher_ priority than `orderImportId`.
- `orderLineId` has _higher_ priority than `orderLineImportId`.

When a higher priority field is present, the lower priority field will be _ignored_.

When a field value is null, it follows the rules explained in section [API requests and responses](https://community.onix.com/t/onixapi-get-started/602#api-requests-and-responses-2), if no specific rules are mentioned.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `orderId` | `int` | **No** \* | The Onix Work system’s order ID.  
Either `orderId` or `orderImportId` must be provided.  
See field precendence above. |
| `orderImportId` | `string` | **No** \* | **Constraint** : length ≤ 50.  
Your system’s order ID.  
Either `orderId` or `orderImportId` must be provided.  
See field precendence above. |
| `orderLineId` | `int` | **No** \* | The Onix Work system’s order line ID.  
Either `orderLineId` or `orderLineImportId` must be provided.  
See field precendence above. |
| `orderLineImportId` | `string` | **No** \* | **Constraint** : length ≤ 50.  
Your system’s order line ID.  
Either `orderLineId` or `orderLineImportId` must be provided.  
See field precendence above. |
| `properties` | `FormPropertyKeyValueInfo[]` | **Yes** | **Constraint:** length \> 0.  
The list of the order line’s form properties.  
See the table below for more information. |

Model `FormPropertyKeyValueInfo` fields table:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | `string` | **Yes** | **Constraint** : length ≤ 50.  
The form property’s key – corresponding with the key field in endpoint:  
`GET /v1/company/form-properties` |
| `value` | `string` | No | **Constraint** : length ≤ 100.  
The form property’s value. |

## Response

| Status code | Response body | Description |
| --- | --- | --- |
| `200` | A boolean. | Indicate if the update process was successful or not. |
| `400` | The system’s standard error response object. | See an examples of error responses in section [API requests and responses](https://community.onix.com/t/onixapi-get-started/602#api-requests-and-responses-2). |

## Examples

Let’s use the `orderId` and `orderLineId` to update properties for the order line that’s just created in [part 1](https://community.onix.com/t/onixapi-transfer-orders-part-1-3/624):

- `orderId`: 546804.
- `orderLineId`: 3998608.

You can also use `orderImportId` and `orderLineImportId` instead.  
First, let’s examine the form of the product that the order line has been using for better visualization:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/onix/original/2X/7/760cb6a4815210f84a5190dca048636f96adbfa6.png)

There are one form and four properties, and only “_Proofload_” and “_Date of test_” can be updated. Typically, developers should check all available form properties using the endpoint:

```auto
GET /v1/company/form-properties

```

The results of this endpoint allow developers to find the suitable keys which can be used to update the form properties. The key for those two properties above is:

- `ApiKey_Proofload`: “_Proofload_” property.
- `ApiKey_DateOfTest`: “_Date of test_” property.

Use them and make a request with the request body below:

```js
{
  "orderId": 546804,
  "orderLineId": 3998608,
  "properties": [
    {
      "key": "ApiKey_Proofload",
      "value": "Test value"
    },
    {
      "key": "ApiKey_DateOfTest",
      "value": "2024.31.01"
    }
  ]
}

```

The system responsed with status code of 200, the response body indicates where the request was successful or not:

```js
true

```

The properties have been updated successfully. Let’s check the results in Onix Work by navigating to the order we have just been created and click on the tab “ **Order lines** ” then “ **Forms** ” of the order line.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/onix/original/2X/f/f9725e16e50a00e85d2c208812f4d14c37632df1.png)

Notice that the value of “_Proofload_” and “_Date of test_” updated accordingly to the request.

That completes the entire process of creating or updating an order. If you are currently using the Web API ( **deprecated** ), consider migrating to Onix API. Please refer to [part 3](https://community.onix.com/t/onix-api-transfer-orders-part-3-4-migrate-from-web-api-to-onix-api/626) for more information.

# Related articles

- [Onix API - Get started](https://community.onix.com/t/onix-api-get-started/602)
- [Part 1](https://community.onix.com/t/onix-api-transfer-orders-part-1-4-create-an-order-or-order-line/624): create and update an order, an order line and numbering an order line.
- [Part 2](https://community.onix.com/t/onix-api-transfer-orders-part-2-4-update-order-lines-properties-and-form-properties/627): update an order line’s properties and form properties.
- [Part 3](https://community.onix.com/t/onix-api-transfer-orders-part-3-4-migrate-from-web-api-to-onix-api/626): how to migrate from Web API to Onix API.
- [Part 4](https://community.onix.com/t/onix-api-transfer-orders-part-4-4-create-and-update-a-grouped-order-line/1213): create and update grouped order lines.

> If you encounter any issues or have questions, kindly describe your concern and:
> 
> - Send an email to [support@onix.com](mailto:support@onix.com); OR
> - Create a topic in #Q&A to receive assistance from all Community members.
