Unable to set Line Item hs_external_id property

I ran the CRM Properties API and it show hs_external_id as a property for line items, but when I try to update a line item the hs_external_id still comes back null.

Update request

curl --request PATCH \
 --url https://api.hubapi.com/crm/v3/objects/line_items/3942492049 \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
 --header 'content-type: application/json' \
 --data '{
 "properties": {
 "hs_external_id": "111111111"
 }
}'

Response

{
 "id": "3942492049",
 "properties": {
 "createdate": "2022-10-25T17:47:31.621Z",
 "hs_lastmodifieddate": "2022-10-25T17:47:31.621Z",
 "hs_object_id": "3942492049"
 },
 "createdAt": "2022-10-25T17:47:31.621Z",
 "updatedAt": "2022-10-25T17:47:31.621Z",
 "archived": false
}

GET Request

HTTP 200

{
 "id": "3942492049",
 "properties": {
 "createdate": "2022-10-25T17:47:31.621Z",
 "hs_external_id": null,
 "hs_lastmodifieddate": "2022-10-25T17:47:31.621Z",
 "hs_object_id": "3942492049"
 },
 "createdAt": "2022-10-25T17:47:31.621Z",
 "updatedAt": "2022-10-25T17:47:31.621Z",
 "archived": false
}

Hey, @eibach-cv :waving_hand: Thanks for reaching out. The short answer is this property is set as read-only.

We can verify this by using the Properties API and making a request for the Line Item properties. I took this response and dumped it into VSCode and searched for:

hs_external_id

Which is read-only

The documentation states read-only properties will be ignored when making a PATCH request:

“Read-only and non-existent properties will be ignored.”

What I do not have is any documentation on using this property or if it is being phased in or phased out, for example. It’s read-able and visible, as you found, but there isn’t much else to go on.

Hey, @himanshurauthan, do you have any additional insight here?

Best,

Jaycee

Thank you! I missed that readOnly property when I was looking at the proeprties API.

Is there a way to create a custom property for line items? I am looking at the properties API again, but the create method doesn’t say anything about line items:

GRANULAR SCOPE(S)

crm.schemas.deals.writeorcrm.schemas.contacts.writeorcrm.schemas.companies.write

Hey, @eibach-cv :blush: It is covered by the Standard Scope “e-commerce”. I ran a quick test:

  • Created a Private app with only the “e-commerce” scope

  • Request

    curl --request POST \
     --url https://api.hubapi.com/crm/v3/properties/0-8 \
     --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
     --header 'content-type: application/json' \
     --data '{
     "name": "burritos",
     "label": "Burrito",
     "type": "string",
     "fieldType": "text",
     "groupName": "lineiteminformation",
     "hidden": false,
     "displayOrder": 2,
     "hasUniqueValue": false,
     "formField": true
    }'​
    
  • Response

    HTTP 201
    
    {
     "updatedAt": "2023-01-10T18:37:17.361Z",
     "createdAt": "2023-01-10T18:37:17.361Z",
     "name": "burritos",
     "label": "Burrito",
     "type": "string",
     "fieldType": "text",
     "description": "",
     "groupName": "lineiteminformation",
     "options": [],
     "createdUserId": "10233975",
     "updatedUserId": "10233975",
     "displayOrder": 2,
     "calculated": false,
     "externalOptions": false,
     "archived": false,
     "hasUniqueValue": false,
     "hidden": false,
     "modificationMetadata": {
     "archivable": true,
     "readOnlyDefinition": false,
     "readOnlyValue": false
     },
     "formField": true
    }​
    

Other details —

  • you can use “line_items” or “0-8” for objectType.
  • For groupName, I referenced the default group names returned in the GET request for all Line Item properties and used one of the default values — lineiteminformation in this case.

I hope this helps. Have fun building! — Jaycee