The Line Item is an object used to represent some Product added to an Order. Line Item is validated against the product it is created from. Several properties (like name and description) are copied from the product, afterwards the relationship between products and line items is not maintained.

With every order, there might be any number of Line Items.

Line Items, Products and Orders are available only to users who are on the Enterprise plan.

Account's administrators can disable changes to these entities in the account's settings. When disabled, all data are preserved but only GET requests are allowed.

JSON format

NameRead OnlyTypeDescription
idtruenumberUnique identifier of the line item.
product_idtruenumberUnique identifier of the product based on which line item is created. It is not available after creation.
valuefalsedecimalValue of one unit of the product. It is product's price after applying markup.
variationfalsedecimalVariation of the product's price for this line item. Value of 5 means that 5% markup is added, -10 means there is a 10% discount.
currencytruestringCurrency of value and price, specified in 3-character currency code (ISO4217) format.
quantityfalsenumberQuantity of the product included in this line item. Default value is 1.
pricetruestringPrice of one unit of the product. Value is copied from the product.
nametruestringName of the product. Value is copied from the product.
skutruestringStock Keeping Unit identification code. Value is copied from the product.
descriptiontruestringDescription of the product. Value is copied from the product.
created_attruestringDate and time that the associated contact was created in UTC (ISO8601 format).
updated_attruestringDate and time of the last update on the associated contact in UTC (ISO8601 format).

Retrieve order's line items

GET /v2/orders/:order_id/line_items

Returns all line items associated to order.

Parameters

NameRequiredTypeInDescription
pagefalsenumberQueryPage number to start from. Page numbering starts at 1, and omitting the page parameter will return the first page.
per_pagefalsenumberQueryNumber of records to return per page. Defaults to all records.
sort_byfalsestringQueryA field to sort by. Default ordering is ascending. If you want to change the sort ordering to descending, append :desc to the field e.g. sort_by=value:desc. Possible values: id, value, quantity, updated_at, created_at
idsfalsestringQueryComma-separated list of line item IDs to be returned in a request.
quantityfalsenumberQueryQuantity of line item.
valuefalsedecimalQueryValue of line item.

Allowed for

  • Agents

Using cURL

curl -v -X GET https://api.getbase.com/v2/orders/:order_id/line_items \-H "Accept: application/json" \-H "Authorization: Bearer $ACCESS_TOKEN"

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8Content-Language: en
{  "items": [    {      "data": {        "id": 1,        "name": "Enterprise Plan",        "sku": "enterprise-plan",        "description": "Includes more storage options",        "value": "3599.99",        "variation": "0.00",        "price": "3599.99",        "currency": "USD",        "quantity": 10,        "created_at": "2014-08-27T16:32:56Z",        "updated_at": "2014-08-27T17:32:56Z"      },      "meta": {        "type": "line_item"      }    }  ],  "meta": {    "type": "collection",    "count": 1,    "links": {      "self": "http://api.getbase.com/v2/orders/1/line_items?page=1&per_page=25"    }  }}

Create a line item

POST /v2/orders/:order_id/line_items

Adds a new line item to an existing order. Line items correspond to products in the catalog, so first you must create products. Because products allow defining different prices in different currencies, when creating a line item, the parameter currency is required.

If request does not specify value nor variation, we'll assume variation is 0 (no markup), and set value to the price of the product. Price is picked based on the provided currency.

If either value or variation is provided, the other value is computed based on the price from the product. You can also specify both, in which case we do no calculations.

In all cases, we do check that the value is obtained from the price by applying the markup equal to variation. We also check that variation is within max_discount and max_markup, if these are set for the product.

Parameters

NameRequiredTypeInDescription
order_idtruenumberQueryUnique identifier for the order.
product_idtruenumberBodyUnique identifier for the product.
valuefalsedecimalBodyValue of one unit of the product. It is product’s price after applying markup equal to variation.
variationfalsedecimalBodyVariation of the product's price for this line item. Value of 5 means that 5% markup is added.
currencytruestringBodyCurrency of the line item, specified in 3-character currency code (ISO4217) format. Used to choose price from product.
quantityfalsenumberBodyQuantity of line item.

Allowed for

  • Agents

Using cURL

curl -v -X POST https://api.getbase.com/v2/orders/1/line_items \-H "Accept: application/json" \-H "Content-Type: application/json" \-H "Authorization: Bearer $ACCESS_TOKEN" \-d '{  "data": {    "product_id": 1,    "value": "3599.99",    "currency": "USD",    "variation": "0.00",    "quantity": 10  },  "meta": {    "type": "line_item"  }}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8Content-Language: en
{  "data": {    "id": 1,    "name": "Enterprise Plan",    "sku": "enterprise-plan",    "description": "Includes more storage options",    "value": "3599.99",    "variation": "0.00",    "price": "3599.99",    "currency": "USD",    "quantity": 10,    "created_at": "2014-08-27T16:32:56Z",    "updated_at": "2014-08-27T17:32:56Z"  },  "meta": {    "type": "line_item"  }}

Retrieve a single line item

GET /v2/orders/:order_id/line_items/:line_item_id

Returns a single line item of an order, according to the unique line item ID provided.

Parameters

NameRequiredTypeInDescription
order_idtruenumberQueryUnique identifier of the order.
line_item_idtruenumberQueryUnique identifier of the line item.

Allowed for

  • Agents

Using cURL

curl -v -X GET https://api.getbase.com/v2/orders/1/line_items/2 \-H "Accept: application/json" \-H "Authorization: Bearer $ACCESS_TOKEN"

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8Content-Language: en
{  "data": {    "id": 1,    "name": "Enterprise Plan",    "sku": "enterprise-plan",    "description": "Includes more storage options",    "value": "3599.99",    "variation": "0.00",    "price": "3599.99",    "currency": "USD",    "quantity": 10,    "created_at": "2014-08-27T16:32:56Z",    "updated_at": "2014-08-27T17:32:56Z"  },  "meta": {    "type": "line_item"  }}

Update order's line item

PUT /v2/orders/:order_id/line_items/:line_item_id

Updates a line item associated with the order.

Parameters

NameRequiredTypeInDescription
order_idtruenumberQueryUnique identifier for the order.
line_item_idtruenumberQueryUnique identifier for the line item.
valuefalsedecimalBodyValue of one unit of the product, which is the product’s price after applying a markup equal to variation.
variationfalsedecimalBodyVariation of the product's price for this line item. For example, a value of 5 means that 5% markup is added.
currencytruestringBodyCurrency of the line item, specified in a three-character currency code (ISO4217) format. Used to choose price from product.
quantityfalsenumberBodyQuantity of line item.

Allowed for

  • Agents

Using cURL

curl -v -X PUT https://api.getbase.com/v2/orders/:order_id/line_items/:line_item_id \-H "Accept: application/json" \-H "Authorization: Bearer $ACCESS_TOKEN" \-H "Content-Type: application/json" \-d '{  "data": {    "product_id": 1,    "value": "3599.99",    "currency": "USD",    "variation": "0.00",    "quantity": 10  },  "meta": {    "type": "line_item"  }}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8Content-Language: en
{  "items": [    {      "data": {        "id": 1,        "name": "Enterprise Plan",        "sku": "enterprise-plan",        "description": "Includes more storage options",        "value": "3599.99",        "variation": "0.00",        "price": "3599.99",        "currency": "USD",        "quantity": 10,        "created_at": "2014-08-27T16:32:56Z",        "updated_at": "2014-08-27T17:32:56Z"      },      "meta": {        "type": "line_item"      }    }  ],  "meta": {    "type": "collection",    "count": 1,    "links": {      "self": "http://api.getbase.com/v2/orders/1/line_items?page=1&per_page=25"    }  }}

Remove a line item

DELETE /v2/orders/:order_id/line_items/:line_item_id

Remove an order's line item. This operation cannot be undone.

Parameters

NameRequiredTypeInDescription
order_idtruenumberQueryUnique identifier of the order.
line_item_idtruenumberQueryUnique identifier of the line item.

Allowed for

  • Agents

Using cURL

curl -v -X DELETE https://api.getbase.com/v2/orders/1/line_items/2 \-H "Authorization: Bearer $ACCESS_TOKEN"

Example response

HTTP/1.1 204 No Content