upsertCustomerCustomAttribute only working after manually setting a value in Square web UI

I’m calling the upsertCustomerCustomAttribute function in the CustomerCustomAttributesApi.php file.

And it’s working… kind of… If I open up the square website and create a new customer, all the custom attributes will be blank. If I then try and set their values via the API using upsertCustomerCustomAttribute, the results returned from the API says that the operation was successful. But when I go back and check the square customer page, I see that the value for the custom attribute is still blank.

If I manually enter a, initial value for the custom attributeon the Square webpage, then the upsertCustomerCustomAttribute works just fine and will update the custom attribute without any problem.

So, there must be some other step to creating the custom attribute for a given customer before I can use the upsertCustomerCustomAttribute function. I’ve scoured the documentation and cannot find anything on this.

Any help you can provide would be very appreciated.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Use Custom Attributes for Merchants
Custom Attributes for Merchants
Custom Attributes for Orders

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Based on the information provided, it seems like you’re doing everything correctly. The UpsertCustomerCustomAttribute API should create the custom attribute for a customer if it doesn’t exist, or update it if it does.

However, it’s important to note that the custom attribute definition must be created first before setting custom attributes for customer profiles. This is done by calling the CreateCustomerCustomAttributeDefinition API. This API defines the properties of the custom attribute, such as its key identifier, visibility setting, allowed data type, and other properties.

Once the custom attribute definition is created, you can then use the UpsertCustomerCustomAttribute API to set the custom attribute for any customer profile in the seller’s Customer Directory.

If you’ve already done this and are still experiencing issues, it might be a problem that needs further investigation.

This answer was reviewed by @Bryan-Square.

What’s your application ID, customer_id that didn’t update, and the custom attribute you set with the API but didn’t show in the customer profile? :slightly_smiling_face:

I created the custom attribute manually via the square webpage. Then I got the custom attribute ID from getCustomerCustomAttributesApi so I can upsert the attributes value.

So, since the attribute is already created through the website, I assume I don’t need to run CreateCustomerCustomAttributeDefinition? Or are you saying that I need to create a definition of each attribute for each customer record?

Does my question make sense?

Do I just post that publicly here?

Once the attribute is created you can just add the value to the customer profile. Yes, the only value that isn’t safe to post is your access token. All other values like the application ID are safe to post publicly. :slightly_smiling_face:

Here is the app ID and the customer ID. But the problem happens with all customers.

APPID: sq0idp-FZFwWk3ytjntfu9FNA2H1A

What’s the custom attribute you set with the API that’s not showing in the Dashboard? :slightly_smiling_face:

Thanks for the prompt response.

Here are all of the custom attribute definition names and their IDs. They all behave the same way regarding this issue. I really appreciate your help with figuring this out.

“Rank Begin Date” square:e58f2bfe-080e-43f8-b32d-0b8f03f661f7
“Creation Date” square:aa6e492f-c7fa-4205-9440-c329880c0a42
“FamilyID” square:404dc342-afe1-4634-b5d2-b45a8c17a14c
“BDay” square:b33b7b50-4d9d-4fcd-8f04-3c46bbfd85eb
“Current Rank” square:71eb58e0-df51-44da-af48-8ad520927a3a
“billingContact” square:3b5d16c5-9e1f-4b82-a916-20169fde9466
“Enrollment Cancel Date” square:defd4e92-6d27-4738-93cf-5f17b08051a0
“Active In SatoriMGMT” square:7d270d90-a51d-4dd7-bfed-bf70b0c8bb68
“Enrolled” square:587d80f6-fca0-4d9a-a8ee-a32c03435f20
“First Lesson Topic” square:352c97f9-9e04-4147-bb2c-3151b98f5112

You probably already know this but I just want to clarify, all of the attributes are being displayed in the dashboard since I created them in the dashboard by going to “Customers > Settings > Configure Profiles”

When creating a new customer these attributes are displayed in the dashboard but their value is blank/null. At this point, UpsertCustomerCustomAttribute will not update their values.

If I set the value of these attributes through the dashoboard one time, from then on, the UpsertCustomerCustomAttribute will update their values. Its like the attribute isn’t really attached to the customer until I set a value for it in the dashboard.