NUMBER custom_attribute_values not updating using the upsert catalog object endpoint

Hello! I was trying to upsert/create a new item using the upsert catalog object endpoint. The request turned out to have a 200 response and the item was created fine. However, it seems like the custom_attribute_values was not reflected/created correctly. In the following example, my custom attribute value “expiry-date” was set to be 20221231 in the request, but you can see that it was set to 0.0 in the json response. Is this a bug on Square’s end?

custom_attribute_values in request:

"custom_attribute_values": {
  "63c5f5f1-430e-4079-9879-80898e6cf310": {
    "boolean_value": false,
    "name": "expiry-date",
    "number_value": "20221231"
  }
},

custom_attribute_values in response:

"custom_attribute_values": {
  "Square:63c5f5f1-430e-4079-9879-80898e6cf310": {
    "name": "expiry-date",
    "custom_attribute_definition_id": "EMOUBMKM6N2GVRH67JGW375T",
    "type": "NUMBER",
    "number_value": "0.0",
    "key": "Square:63c5f5f1-430e-4079-9879-80898e6cf310"
  }
}

My custom attribute definition object for expiry-date:

{
  "objects": [
    {
      "type": "CUSTOM_ATTRIBUTE_DEFINITION",
      "id": "EMOUBMKM6N2GVRH67JGW375T",
      "updated_at": "2022-04-01T04:45:15.575Z",
      "created_at": "2022-03-11T05:58:25.724Z",
      "version": 1648788315575,
      "is_deleted": false,
      "present_at_all_locations": true,
      "custom_attribute_definition_data": {
        "type": "NUMBER",
        "name": "expiry-date",
        "source_application": {
          "application_id": "Square"
        },
        "allowed_object_types": [
          "ITEM",
          "ITEM_VARIATION"
        ],
        "seller_visibility": "SELLER_VISIBILITY_READ_WRITE_VALUES",
        "app_visibility": "APP_VISIBILITY_READ_WRITE_VALUES",
        "number_config": {
          "precision": 0
        },
        "key": "63c5f5f1-430e-4079-9879-80898e6cf310"
      }
    }
  ],
  "latest_time": "2022-07-07T23:18:26.852Z"
}

Full request:

curl https://connect.squareup.com/v2/catalog/object \
  -X POST \
  -H 'Square-Version: 2022-06-16' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "9b0b2689-8818-4bf1-9c81-62f785ec6ec3",
    "object": {
      "id": "#duplicate",
      "type": "ITEM",
      "is_deleted": false,
      "present_at_all_locations": false,
      "present_at_location_ids": [
        "LB5F8WYCHXM5V"
      ],
      "version": 1657015438005,
      "item_data": {
        "available_electronically": false,
        "available_for_pickup": false,
        "available_online": false,
        "category_id": "WEG4H64NYKZZSAZZQUIJK77N",
        "description": "xxx",
        "image_ids": [
          "JAUCWUL22HMOTRM2PJIOS6SX"
        ],
        "name": "xxx",
        "product_type": "REGULAR",
        "skip_modifier_screen": false,
        "tax_ids": [
          "EPUSQLNPY23CEEZH26SPLZVA"
        ],
        "variations": [
          {
            "id": "#duplicatee",
            "type": "ITEM_VARIATION",
            "category_data": {
              "name": "xxx"
            },
            "custom_attribute_values": {
              "63c5f5f1-430e-4079-9879-80898e6cf310": {
                "boolean_value": false,
                "name": "expiry-date",
                "number_value": "20221231"
              }
            },
            "image_data": {
              "caption": "Puffcorn (Salty)",
              "url": "https://items-images-production.s3.us-west-2.amazonaws.com/files/c4ca5493077ec98a4f05747821527b9ad372ff42/original.jpeg"
            },
            "is_deleted": false,
            "item_variation_data": {
              "inventory_alert_threshold": 5,
              "inventory_alert_type": "LOW_QUANTITY",
              "name": "50g",
              "price_money": {
                "amount": 350,
                "currency": "CAD"
              },
              "pricing_type": "FIXED_PRICING",
              "sellable": true,
              "sku": "318130007",
              "stockable": true,
              "track_inventory": true,
              "upc": "4710015118251"
            },
            "present_at_all_locations": false,
            "present_at_location_ids": [
              "LB5F8WYCHXM5V"
            ],
            "tax_data": {
              "applies_to_custom_amounts": true,
              "calculation_phase": "TAX_SUBTOTAL_PHASE",
              "enabled": true,
              "inclusion_type": "ADDITIVE",
              "name": "GST",
              "percentage": "5"
            },
            "version": 1657015438005
          }
        ]
      }
    }
  }'

Full response:

{
  "catalog_object": {
    "type": "ITEM",
    "id": "WBNBFGQJERVCSP66ZR46UHKF",
    "updated_at": "2022-07-07T10:36:39.719Z",
    "created_at": "2022-07-07T10:36:39.719Z",
    "version": 1657190199719,
    "is_deleted": false,
    "present_at_all_locations": false,
    "present_at_location_ids": [
      "LB5F8WYCHXM5V"
    ],
    "item_data": {
      "name": "xxx",
      "available_online": false,
      "available_for_pickup": false,
      "available_electronically": false,
      "category_id": "WEG4H64NYKZZSAZZQUIJK77N",
      "tax_ids": [
        "EPUSQLNPY23CEEZH26SPLZVA"
      ],
      "variations": [
        {
          "type": "ITEM_VARIATION",
          "id": "JRMWWCQPH6YXIFVG7X53VWK5",
          "updated_at": "2022-07-07T10:36:39.719Z",
          "created_at": "2022-07-07T10:36:39.719Z",
          "version": 1657190199719,
          "is_deleted": false,
          "custom_attribute_values": {
            "Square:63c5f5f1-430e-4079-9879-80898e6cf310": {
              "name": "expiry-date",
              "custom_attribute_definition_id": "EMOUBMKM6N2GVRH67JGW375T",
              "type": "NUMBER",
              "number_value": "0.0",
              "key": "Square:63c5f5f1-430e-4079-9879-80898e6cf310"
            }
          },
          "present_at_all_locations": false,
          "present_at_location_ids": [
            "LB5F8WYCHXM5V"
          ],
          "item_variation_data": {
            "item_id": "WBNBFGQJERVCSP66ZR46UHKF",
            "name": "50g",
            "sku": "318130007",
            "upc": "4710015118251",
            "ordinal": 0,
            "pricing_type": "FIXED_PRICING",
            "price_money": {
              "amount": 350,
              "currency": "CAD"
            },
            "location_overrides": [
              {
                "location_id": "LB5F8WYCHXM5V",
                "sold_out": true
              }
            ],
            "track_inventory": true,
            "inventory_alert_type": "LOW_QUANTITY",
            "inventory_alert_threshold": 5,
            "sellable": true,
            "stockable": true
          }
        }
      ],
      "product_type": "REGULAR",
      "skip_modifier_screen": false,
      "image_ids": [
        "JAUCWUL22HMOTRM2PJIOS6SX"
      ]
    }
  },
  "id_mappings": [
    {
      "client_object_id": "#duplicate",
      "object_id": "WBNBFGQJERVCSP66ZR46UHKF"
    },
    {
      "client_object_id": "#duplicatee",
      "object_id": "JRMWWCQPH6YXIFVG7X53VWK5"
    }
  ]
}

:wave: The team just got back to me and you are providing a number value and a boolean value which isn’t available with custom attributes but we didn’t throw an error. Given the order that they were provided the custom attribute is respecting the last value which is the boolean. The team is working on making this better but in the meantime if you remove the boolean it will set the number value correctly. :slightly_smiling_face: