Create a line item option

How to create a line item option via API

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.

Request

POST https://yourdomain.commercelayer.io/api/line_item_options

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.name

string

Optional

attributes.quantity

integer

Required

attributes.unit_amount_cents

integer

Optional

attributes.options

object

Required

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.line_item

object

Required

relationships.sku_option

object

Required

relationships.tags

array

Optional

Example

The following request creates a new line item option:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/line_item_options' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "line_item_options",
    "attributes": {
      "quantity": 2,
      "options": {
        "embossing_text": "Happy Birthday!"
      }
    },
    "relationships": {
      "line_item": {
        "data": {
          "type": "line_items",
          "id": "ABCRtyUpBa"
        }
      },
      "sku_option": {
        "data": {
          "type": "sku_options",
          "id": "BCDRtyUpBa"
        }
      }
    }
  }
}'

Last updated