What customer fields could be edited through the PUT /admin/customers/#{id}.json?

7Spikes
Shopify Partner
24 0 3

Hi,

I am trying to use the customer api to edit customer information. However it is unclear what custom fields I am allowed to edit through the API?

Initially I assumed that whatever could be edited through the admin panel will also be editable from the API, like the default address for example.

But this does not seem to be the case. Is there documentation that specifies what could be edited through the API or it is a case of a trial and error?

Thanks

0 Likes
Nate19
Shopify Staff
Shopify Staff
95 0 6

Hi there,

All the attributes listed in the documentation for the Customer API should be available for editing, except where it does not make sense (i.e. 'id'). Which parts of the customer information are you having trouble updating?

 

0 Likes
7Spikes
Shopify Partner
24 0 3

Hi Nate,

Thanks for your quick reply. I am trying to edit the customer.default_address.address1 field.

The json I am sending to the server looks like this:

{
  "customer": {
    "id": 284362701,
    "first_name": "tester",
    "last_name": "test",
    "email": "info@softuni.bg",
    "default_address": {
      "address1": "tester",
      "address2": "sdfsdfsdf",
      "city": "sf",
      "company": "test",
      "country": "Bulgaria",
      "id": 348340049,
      "phone": "565465634",
      "province": "sofia",
      "zip": "6000",
      "default": false
    }
  }
}

If I change the customer.first_name for example it updates it correctly.  But if I change the customer.default_address.address1 it does not update the field.

0 Likes
Nate19
Shopify Staff
Shopify Staff
95 0 6

The default address can be updated via the 'addresses' attribute on the customer it will have an attribute 'default' set to true.

0 Likes
7Spikes
Shopify Partner
24 0 3

Hi Nate,

Thanks for the answer! I noticed that when you make a put request to the:

https://[my-shop].myshopify.com/admin/customers/[id].json

the information is actually updated correctly for the customer object (address information for example).

However the response you get from the API is a customer object with the old information. Which is why I got confused that nothing really happens on the server, when it is actually updating the customer.

Is this behavior correct? I would expect that the response returned by the API would contain the updated customer object.

0 Likes
7Spikes
Shopify Partner
24 0 3

Hi Nate,

Please comment on my previous post if you have any information on why the API behaves likes this.

One thing that I noticed which seems to be related to the above problem is that if I update a customer address through the API and then query shortly for the same customer data (in a few seconds), the query returns the old customer information, not the updated one. Could it be that the API is caching the customer information or the query result?

Thanks

0 Likes
Rich_Borek
Shopify Partner
56 0 11

Hey 7Spikes,

I've been working extensively with this API recently and I will tell you that managing addresses is "Rocket Science" as they are structured in the API they are not individually addressable objects like Order Transactions or Fulfillments which make them a bit of a pain to work with.  On a good note however I have successfully achieved what you are looking to do and here is the proper format for the Post to get them to look as you want.

{
  "customer": {
    "id": 284362701,
    "first_name": "tester",
    "last_name": "test",
    "email": "info@softuni.bg",
    "addresses":
     [
      {
      "address1": "tester",
      "address2": "sdfsdfsdf",
      "city": "sf",
      "company": "test",
      "country": "Bulgaria",
      "id": 348340049,
      "phone": "565465634",
      "province": "sofia",
      "zip": "6000",
      "default": false
      }
      {
      "address1": "tester 2",
      "address2": "sdfsdfsdf",
      "city": "sf",
      "company": "test second address",
      "country": "Bulgaria",
      "id": 348340049,
      "phone": "565465634",
      "province": "sofia",
      "zip": "6000",
      "default": false
      }
    ]
  }
}

UPDATE

After posting this I decided to take a look at my code that was updating addresses and found that I need to insert my shoe into my mouth because the API is now exposed for updating addresses.  Shopify is continually updating their API and BIG THUMBS UP GUYS THIS WAS LONG OVERDUE...

check out the documentation here CustomerAddress - Shopify API - Developer Resources

Efficiency through Simplicity is the only way to design...
0 Likes
7Spikes
Shopify Partner
24 0 3

Hi Rich,

Thanks a lot for the information! It is interesting that now there is a CustomerAddress API.

Please note that I have managed to update the addresses successfully as I wrote in my previous post. But the problem I am having is a different one. It has to do with the old information being returned by the call to the Update method. Also the get customer method seems to also get the old information if it is executed several seconds after the update, as if the old information is being cached somewhere. Please read my previous two posts for more information.

Still waiting for Shopify to comment on this.

0 Likes
michael-helium
Shopify Expert
183 1 107

You cannot edit custom fields with Shopify's Customer API.

However, we've built our own front-end API within the Customer Fields app that increases the functionality of Shopify's Customer API so you can add/edit custom fields (VAT, birth date, gender, etc.). The app is partner-friendly (install on any dev shop for free). Learn more about building with Customer Fields here: https://developers.customerfields.com/

Michael | Business Development @ Helium
Helium builds apps that merchants depend on:
- Customer Fields
- Meteor Mega Menu
0 Likes
michael-helium
Shopify Expert
183 1 107

To clarify my previous post, Shopify's Storefront and Admin APIs both have support for metafields.  However, Shopify's Storefront API only allows you to retrieve metafields, meaning you cannot create or update metafield data (more details here). That's where the APIs offered by Customer Fields may come in handy!

Michael | Business Development @ Helium
Helium builds apps that merchants depend on:
- Customer Fields
- Meteor Mega Menu
0 Likes