Synchronise the company address from the ERP
Prerequisites
- An access token for the HIPE instance
- Existing companies in HIPE
API
If you want to synchronise your company addresses from the ERP with your HIPE instance, you will be able to do it by following this process.
- We search if the company address already exists in HIPE, if not we create it.
- We update the company address if it exists based on the retrieved information.
Search the company address
To search if the company address already exists in HIPE, you will need to make a GET request to the /api/companies/{ companyId }/addresses endpoint. API reference
curl --location 'https://{ YOUR INSTANCE }-hipe.packitoo.com/api/companies/{ companyId }/addresses'--header 'X-ACCESS-TOKEN: { YOUR ACCESS TOKEN }'The response should be a 200 with zero or one company address with the same external-id. If you don’t find any company address, you can create it.
Create the company address
To create a company address, you will need to make a POST request to the /api/companies/{ companyId }/addresses endpoint.
Body parameters:
name: The name of the addresscompanyId: The id of the company requiredaddress: The address requiredfirstComplementaryAddress: The first complementary addresssecondComplementaryAddress: The second complementary addresscity: The city requiredcountry: The country requiredstate: The statezipCode: The zip code required
You can found the other parameters in the API reference.
curl --location 'https://{ YOUR INSTANCE }-hipe.packitoo.com/api/companies/{ companyId }/addresses' \--header 'Content-Type: application/json' \--header 'X-ACCESS-TOKEN: { YOUR ACCESS TOKEN }' \--data '[ { "companyId": "{ companyId }", "city": "", "country": "", "address": "", "firstComplementaryAddress": "", "name": "", "secondComplementaryAddress": "", "state": "", "zipCode": "" }]'You should get a 201 code with the created company address in the response. You can use the id of the company address to update it now.
Update the company address
To update the company address, you will need to make a PATCH request to the /api/companies/{ companyId }/addresses/{ companyAddressId } endpoint.
You can refer to the API reference for the parameters.
curl --request PATCH --location "https://{ YOUR INSTANCE }-hipe.packitoo.com/api/companies/{ companyId }/addresses/{ companyAddressId }" \--header 'X-ACCESS-TOKEN: { YOUR ACCESS TOKEN }' \--header 'Content-Type: application/json' \--data '{ "name": "HQ", "companyId": "{ companyId }", "address": "123 Main St", "firstComplementaryAddress": "123 Main St", "secondComplementaryAddress": "123 Main St", "city": "123 Main St", "country": "123 Main St", "state": "123 Main St", "zipCode": "123 Main St"}'You should get a 200 code with the updated company address in the response.