CustomAttributeValues Key issue (C# SDK 45.0.1)

I’m finally updating my C# web app that uses the Square API from SDK v40.1.0 (just before the significant breaking-changes SDK overhaul) to 45.0.1 and I’m running into an issue with the Key for CustomAttributeValues working differently than it did before. One of the things my web app does is retrieve an ItemVariation and then it just changes the TrackInventory state for that ItemVariation and Upserts the ItemVariation using a BatchUpsertRequest. The ItemVariation object in the BatchUpsertRequest has all the attributes that were in the retrieved ItemVariation completely unchanged (including a CustomAttributeValue), except for a different TrackInventory state. When I do this, the BatchUpsertRequest throws an exception like this:

{“errors”:[{“category”:“INVALID_REQUEST_ERROR”,“code”:“NOT_FOUND”,“detail”:“Custom attribute definition with key “Square:REDACTED-LONG-ID” not found”}]}

This seems very weird, since the key for the CustomAttributeValue in the upserted object is exactly the key retrieved from Square and this worked just fine in SDK v40.1.0. I have figured out that if I change the CustomAttributeValues in the ItemVariation that I’m upserting to have keys that omit the “Square:” portion of the string then I don’t get the exception. Is this really how it’s supposed to work now in the API? If so, unless I’m missing something, that adds a very cumbersome step to the code of having to check to see if the ItemVariation has CustomAttributeDefinitions and if it does, replace all of them with a key that strips off the “Square:” portion of the key that was in what was retrieved, just to update some other completely unrelated attribute in the ItemVariation. I think I must be missing something here…

You aren’t missing anything—Square’s SDK overhaul changed how custom attribute keys are namespaced on write. Stripping Square: before upserting is required now, though helper extension methods make it less cumbersome! MyMilestoneCard login

Okie doke. Seems an odd choice for the API along with a few other things I’ve noticed in the new SDK. But I won’t complain too much, because on the whole the Square API is very robust and reliable (and free).

We would not recommend treating this as a general namespace-removal rule. According to Square’s Catalog documentation, custom attributes owned by another application can use qualified keys in the form <application-id>:<key>; preserve those keys as returned. Only normalize the Square: entries affected by this issue, and handle any possible key collision.

Also, update the outer CustomAttributeValues dictionary key and not CatalogCustomAttributeValue.Key. That nested field is response/read-only metadata in the API model.

A retrieved object failing to round-trip for an unrelated update is unexpected. If you want, would you share a sanitized minimal example of:

  • the relevant portion of the retrieved ITEM_VARIATION response,
  • the corresponding BatchUpsertCatalogObjects request that fails,
  • the request after removing Square:, which succeeds, and
  • the SDK version and Square-Version header used for each request?

Please remove access tokens, IDs, and any sensitive merchant or catalog data. This will help us determine whether the returned Square: key should be accepted by Batch Upsert.

*If you can’t share a sanitized example publicly, please contact Developer Support and include the request ID(s).

Documentation: Add Custom Attributes

Let me know if you have any further questions!

Below is the info you asked for. All IDs are REDACTED except for the relevant custom attribute key. This is in a Sandbox environment, for what it’s worth. If you do a text compare on the two Upserts you’ll see that the only difference is the omission of “Square:” from the custom attribute key in the Upsert that succeeds. You can also see that “Square:” is present in the custom attribute key in the initially-retrieved item variation.

.NET SDK Version: 45.0.1
square-version: 2026-07-15

FAIL SCENARIO

RETRIEVED VARIATION
{“ItemVariationData”:{“ItemId”:“REDACTED”,“Name”:“Regular”,“Sku”:“Collection- 1.5#”,“PricingType”:{“Value”:“FIXED_PRICING”},“PriceMoney”:{“Amount”:2995,“Currency”:{“Value”:“USD”},“AdditionalProperties”:{}},“LocationOverrides”:[{“LocationId”:“REDACTED”,“TrackInventory”:false,“AdditionalProperties”:{}}],“TrackInventory”:false,“Sellable”:true,“Stockable”:true,“AdditionalProperties”:{}},“Id”:“REDACTED”,“UpdatedAt”:“2026-10-08T18:03:20.138Z”,“Version”:1791482600138,“IsDeleted”:false,“CustomAttributeValues”:{“Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7”:{“Name”:“NO_OP”,“CustomAttributeDefinitionId”:“REDACTED”,“Type”:{“Value”:“NUMBER”},“NumberValue”:“1.0”,“Key”:“Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7”,“AdditionalProperties”:{}},“PresentAtAllLocations”:false,“PresentAtLocationIds”:[“REDACTED”],“AdditionalProperties”:{“type”:{“ValueKind”:“string”},“created_at”:{“ValueKind”:“string”}}

CORRESPONDING UPSERT THAT FAILS
{“IdempotencyKey”:“REDACTED”,“Batches”:[{“Objects”:[{“Type”:“ITEM_VARIATION”,“Value”:{“ItemVariationData”:{“ItemId”:“REDACTED”,“Name”:“Regular”,“Sku”:“Collection- 1.5#”,“PricingType”:{“Value”:“FIXED_PRICING”},“PriceMoney”:{“Amount”:2995,“Currency”:{“Value”:“USD”},“AdditionalProperties”:{}},“LocationOverrides”:[{“LocationId”:“REDACTED”,“TrackInventory”:true,“AdditionalProperties”:{}}],“TrackInventory”:false,“Sellable”:true,“Stockable”:true,“AdditionalProperties”:{}},“Id”:“REDACTED”,“UpdatedAt”:“2026-10-08T18:03:20.138Z”,“Version”:1791482600138,“IsDeleted”:false,“CustomAttributeValues”:{“Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7”:{“Name”:“NO_OP”,“CustomAttributeDefinitionId”:“REDACTED”,“Type”:{“Value”:“NUMBER”},“NumberValue”:“1.0”,“Key”:“Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7”,“AdditionalProperties”:{}},“PresentAtAllLocations”:false,“PresentAtLocationIds”:[“REDACTED”],“AdditionalProperties”:{“type”:{“ValueKind”:“string”},“created_at”:{“ValueKind”:“string”}},“IsItem”:false,“IsImage”:false,“IsCategory”:false,“IsItemVariation”:true,“IsTax”:false,“IsDiscount”:false,“IsModifierList”:false,“IsModifier”:false,“IsPricingRule”:false,“IsProductSet”:false,“IsTimePeriod”:false,“IsMeasurementUnit”:false,“IsSubscriptionPlanVariation”:false,“IsItemOption”:false,“IsItemOptionVal”:false,“IsCustomAttributeDefinition”:false,“IsQuickAmountsSettings”:false,“IsSubscriptionPlan”:false,“IsAvailabilityPeriod”:false}],“AdditionalProperties”:{}}]}

RESPONSE ERROR
Status code: 404
Body: {“errors”:[{“category”:“INVALID_REQUEST_ERROR”,“code”:“NOT_FOUND”,“detail”:“Custom attribute definition with key “Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7” not found”}]}

SUCCESS SCENARIO

RETRIEVED VARIATION
{“ItemVariationData”:{“ItemId”:“REDACTED”,“Name”:“Regular”,“Sku”:“Collection- 1.5#”,“PricingType”:{“Value”:“FIXED_PRICING”},“PriceMoney”:{“Amount”:2995,“Currency”:{“Value”:“USD”},“AdditionalProperties”:{}},“LocationOverrides”:[{“LocationId”:“REDACTED”,“TrackInventory”:false,“AdditionalProperties”:{}}],“TrackInventory”:false,“Sellable”:true,“Stockable”:true,“AdditionalProperties”:{}},“Id”:“REDACTED”,“UpdatedAt”:“2026-10-08T18:03:20.138Z”,“Version”:1791482600138,“IsDeleted”:false,“CustomAttributeValues”:{“Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7”:{“Name”:“NO_OP”,“CustomAttributeDefinitionId”:“REDACTED”,“Type”:{“Value”:“NUMBER”},“NumberValue”:“1.0”,“Key”:“Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7”,“AdditionalProperties”:{}},“PresentAtAllLocations”:false,“PresentAtLocationIds”:[“REDACTED”],“AdditionalProperties”:{“type”:{“ValueKind”:“string”},“created_at”:{“ValueKind”:“string”}}

CORRESPONDING UPSERT THAT SUCCEEDS
{“IdempotencyKey”:“REDACTED”,“Batches”:[{“Objects”:[{“Type”:“ITEM_VARIATION”,“Value”:{“ItemVariationData”:{“ItemId”:“REDACTED”,“Name”:“Regular”,“Sku”:“Collection-1.5#”,“PricingType”:{“Value”:“FIXED_PRICING”},“PriceMoney”:{“Amount”:2995,“Currency”:{“Value”:“USD”},“AdditionalProperties”:{}},“LocationOverrides”:[{“LocationId”:“REDACTED”,“TrackInventory”:true,“AdditionalProperties”:{}}],“TrackInventory”:false,“Sellable”:true,“Stockable”:true,“AdditionalProperties”:{}},“Id”:“REDACTED”,“UpdatedAt”:“2026-10-08T18:03:20.138Z”,“Version”:1791482600138,“IsDeleted”:false,“CustomAttributeValues”:{“8dadcd11-6f96-407c-b910-10f40e9d5fe7”:{“Name”:“NO_OP”,“CustomAttributeDefinitionId”:“REDACTED”,“Type”:{“Value”:“NUMBER”},“NumberValue”:“1.0”,“Key”:“Square:8dadcd11-6f96-407c-b910-10f40e9d5fe7”,“AdditionalProperties”:{}},“PresentAtAllLocations”:false,“PresentAtLocationIds”:[“REDACTED”],“AdditionalProperties”:{“type”:{“ValueKind”:“string”},“created_at”:{“ValueKind”:“string”}},“IsItem”:false,“IsImage”:false,“IsCategory”:false,“IsItemVariation”:true,“IsTax”:false,“IsDiscount”:false,“IsModifierList”:false,“IsModifier”:false,“IsPricingRule”:false,“IsProductSet”:false,“IsTimePeriod”:false,“IsMeasurementUnit”:false,“IsSubscriptionPlanVariation”:false,“IsItemOption”:false,“IsItemOptionVal”:false,“IsCustomAttributeDefinition”:false,“IsQuickAmountsSettings”:false,“IsSubscriptionPlan”:false,“IsAvailabilityPeriod”:false}],“AdditionalProperties”:{}}]}

Thanks for the detailed examples, cbstl, and for confirming this is Sandbox.

Your examples show that changing the outer CustomAttributeValues dictionary key allows the upsert to succeed while the nested Key remains unchanged. I also located the exact object version from your sample in our server logs and confirmed that the response includes the Square: prefix.

Removing that prefix is a demonstrated workaround for this case, but we haven’t established that it’s an intended requirement or a change introduced by the SDK overhaul.

Could you DM me the failed request’s x-request-id and approximate UTC request time? If available, please include the successful request’s ID too. That will let us inspect the rejected call and compare the requests received by the API without asking you to repeat these examples.