New customer with address and contact via REST API

I am trying to add a new customer, complete with address and contact details with the REST API and PHP. ERPnext has one table/DocType for customer, one for address, one for contact.

So far I have succeeded in adding a new customer record (no address or contact details) and a new address record separately, all via REST API, but I cannot link the two (customer and address) together.

The “Customer” DocType has the field “address_html” which does not reflect the linked address.
There is no address link table in the DocType. The “Address” DocType does not have a customer link field.

How can this be done with the REST API? How can one link two records on different DocTypes with REST API?

Hi @D_Petropoulos

There’s a links child table for the Address and Contact doctype under the Reference Section.

You need to populate this for both Address and Contact so that the Address/Contact can be linked back to customer.

Hope this helps. :slight_smile:

1 Like

Thank you for your response. That’s a good start. I’ll try and see what I can do with that. I don’t know how to work with dynamic links through REST API. Starting experiments.

Yes! That was it! Thank you so much @littlehera!

1 Like

You’re welcome and happy coding! :slight_smile: