Line Item Options

Create a line item option if you want to add one or more SKU options to a line item. The SKU options cost is automatically added to the line item's amount.

The line item option object

A line item option object is returned as part of the response body of each successful create, list, retrieve or update API call. The following table contains the list of all its fields along with their type, description and example values.
Object fields:
name
string
The name of the line item option. When blank, it gets populated with the name of the associated sku option.
Example:
Embossing
quantity
integer
The line item option's quantity
Example:
2
currency_code
string
The international 3-letter currency code as defined by the ISO 4217 standard, automatically inherited from the order's market.
Example:
EUR
unit_amount_cents
integer
The unit amount of the line item option, in cents. When you add a line item option to an order, this is automatically populated from associated sku option's price.
Example:
990
unit_amount_float
float
The unit amount of the line item option, float. This can be useful to track the purchase on thrid party systems, e.g Google Analyitcs Enhanced Ecommerce.
Example:
9.9
formatted_unit_amount
string
The unit amount of the line item option, formatted. This can be useful to display the amount with currency in you views.
Example:
€9,90
total_amount_cents
integer
The unit amount x quantity, in cents.
Example:
1880
total_amount_float
float
The unit amount x quantity, float. This can be useful to track the purchase on thrid party systems, e.g Google Analyitcs Enhanced Ecommerce.
Example:
18.8
formatted_total_amount
string
The unit amount x quantity, formatted. This can be useful to display the amount with currency in you views.
Example:
€18,80
delay_hours
integer
The shipping delay that the customer can expect when adding this option (hours). Inherited from the associated sku option.
Example:
48
delay_days
integer
The shipping delay that the customer can expect when adding this option (days, rounded).
Example:
2
options
object
Set of key-value pairs that represent the selected options.
Example:
{"embossing_text":"Happy Birthday!"}
id
integer
Unique identifier for the resource.
Example:
1234
created_at
datetime
Time at which the resource was created.
Example:
2018-01-01T12:00:00.000Z
updated_at
datetime
Time at which the resource was last updated.
Example:
2018-01-01T12:00:00.000Z
reference
string
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
object
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
{"foo":"bar"}
relationship (N:1)
The associated line item.
relationship (N:1)
The associated sku option.

Create a line item option

To create a new line item option, send a POST request to the /api/line_item_options endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.
Arguments:
name
optional
The name of the line item option. When blank, it gets populated with the name of the associated sku option.
Example:
Embossing
quantity
required
The line item option's quantity
Example:
2
options
required
Set of key-value pairs that represent the selected options.
Example:
#
reference
optional
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
optional
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
#
required
The associated line item.
required
The associated sku option.
Example request:
POST /api/line_item_options HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "line_item_options",
    "attributes": {
      "quantity": "2",
      "options": {
        "embossing_text": "Happy Birthday!"
      }
    },
    "relationships": {
      "line_item": {
        "data": {
          "type": "line_items",
          "id": "1234"
        }
      },
      "sku_option": {
        "data": {
          "type": "sku_options",
          "id": "1234"
        }
      }
    }
  }
}
Example response: 201 Created
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "line_item_options",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/line_item_options/1234"
    },
    "attributes": {
      "name": "Embossing",
      "quantity": "2",
      "currency_code": "EUR",
      "unit_amount_cents": "990",
      "unit_amount_float": "9.9",
      "formatted_unit_amount": "€9,90",
      "total_amount_cents": "1880",
      "total_amount_float": "18.8",
      "formatted_total_amount": "€18,80",
      "delay_hours": "48",
      "delay_days": "2",
      "options": {
        "embossing_text": "Happy Birthday!"
      },
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "line_item": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/line_item",
          "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/line_item"
        }
      },
      "sku_option": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/sku_option",
          "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/sku_option"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

List all line item options

To fetch a collection of line item options, send a GET request to the /api/line_item_options endpoint.

Example request:
GET /api/line_item_options HTTP/1.1
Accept: application/vnd.api+json
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": [
    {
      "id": "1234",
      "type": "line_item_options",
      "links": {
        "self": "https://your-brand.commercelayer.io/api/line_item_options/1234"
      },
      "attributes": {
        "name": "Embossing",
        "quantity": "2",
        "currency_code": "EUR",
        "unit_amount_cents": "990",
        "unit_amount_float": "9.9",
        "formatted_unit_amount": "€9,90",
        "total_amount_cents": "1880",
        "total_amount_float": "18.8",
        "formatted_total_amount": "€18,80",
        "delay_hours": "48",
        "delay_days": "2",
        "options": {
          "embossing_text": "Happy Birthday!"
        },
        "id": "1234",
        "created_at": "2018-01-01T12:00:00.000Z",
        "updated_at": "2018-01-01T12:00:00.000Z",
        "reference": "ANYREFEFERNCE",
        "metadata": {
          "foo": "bar"
        }
      },
      "relationships": {
        "line_item": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/line_item",
            "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/line_item"
          }
        },
        "sku_option": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/sku_option",
            "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/sku_option"
          }
        }
      },
      "meta": {
        "mode": "test"
      }
    },
    {
      "other": "... 24 line_item_options (first page)"
    }
  ],
  "meta": {
    "record_count": 125,
    "page_count": 5
  },
  "links": {
    "first": "/api/line_item_options?page[number]=1&page[size]=25",
    "prev": "/api/line_item_options?page[number]=2&page[size]=25",
    "next": "/api/line_item_options?page[number]=4&page[size]=25",
    "last": "/api/line_item_options?page[number]=5&page[size]=25"
  }
}
Available filters
idtotal_amount_centsreferenceline_item_idsku_option_ididscreated_at_fromcreated_at_toupdated_at_fromupdated_at_to
Sortable attributes
nametotal_amount_centsdelay_hoursidcreated_atupdated_atreference

Retrieve a line item option

To fetch a single line item option, send a GET request to the /api/line_item_options/{{id}} endpoint, where {{id}} is the id of the resource that you want to retrieve.
Example request:
GET /api/line_item_options/1234 HTTP/1.1
Accept: application/vnd.api+json
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "line_item_options",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/line_item_options/1234"
    },
    "attributes": {
      "name": "Embossing",
      "quantity": "2",
      "currency_code": "EUR",
      "unit_amount_cents": "990",
      "unit_amount_float": "9.9",
      "formatted_unit_amount": "€9,90",
      "total_amount_cents": "1880",
      "total_amount_float": "18.8",
      "formatted_total_amount": "€18,80",
      "delay_hours": "48",
      "delay_days": "2",
      "options": {
        "embossing_text": "Happy Birthday!"
      },
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "line_item": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/line_item",
          "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/line_item"
        }
      },
      "sku_option": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/sku_option",
          "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/sku_option"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

Update a line item option

To update an existing line item option, send a PATCH request to the /api/line_item_options/{{id}} endpoint, where {{id}} is the id of the resource that you want to update. The following table contains the list of all the possible arguments that you can pass with the request body, along with their type, description and examples values. Please note that all arguments are optional.
Arguments:
name
optional
The name of the line item option. When blank, it gets populated with the name of the associated sku option.
Example:
Embossing
quantity
optional
The line item option's quantity
Example:
2
options
optional
Set of key-value pairs that represent the selected options.
Example:
#
reference
optional
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
optional
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
#
optional
The associated sku option.
Example request:
PATCH /api/line_item_options/1234 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "line_item_options",
    "id": 1234,
    "attributes": {
      "name": "Embossing"
    },
    "relationships": {
    }
  }
}
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "line_item_options",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/line_item_options/1234"
    },
    "attributes": {
      "name": "Embossing",
      "quantity": "2",
      "currency_code": "EUR",
      "unit_amount_cents": "990",
      "unit_amount_float": "9.9",
      "formatted_unit_amount": "€9,90",
      "total_amount_cents": "1880",
      "total_amount_float": "18.8",
      "formatted_total_amount": "€18,80",
      "delay_hours": "48",
      "delay_days": "2",
      "options": {
        "embossing_text": "Happy Birthday!"
      },
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "line_item": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/line_item",
          "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/line_item"
        }
      },
      "sku_option": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/line_item_options/1234/relationships/sku_option",
          "related": "https://your-brand.commercelayer.io/api/line_item_options/1234/sku_option"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

Delete a line item option

To delete a line item option, send a DELETE request to the /api/line_item_options/{{id}} endpoint, where {{id}} is the id of the resource that you want to delete.
Example request:
DELETE /api/line_item_options/1234 HTTP/1.1
Accept: application/vnd.api+json
Example response: 204 No Content
HTTP/1.1 204 No Content

Get our machine-readable JSON schema that follows the OpenAPI Specification (formerly Swagger).

Get our Postman collection in one click and start making real calls to Commerce Layer API in minutes.

Get in touch with our support team if you have any questions or want to learn more about Commerce Layer.