Client Endpoint

How to create a client using the API

💡 This is useful for creating a client from a website newsletter signup

Method: POST > Create Client for a business

Endpoint: /third-party-api-server/api/business/{businessId}/client

Postman URL: https://platform.phorest.com/third-party-api-server/api/business/INSERT BUSINESS_ID HERE/client

Note: To create a client, remove client_id from the body request.

Body request

{  
"address": {  
 "city": "Toronto",  
 "country": "Canada",  
 "postalCode": "",  
 "state": "Toronto",  
 "streetAddress1": "SomeStreet",  
 "streetAddress2": "SomeTown"  
},  
"archived": false,  
"banned": false,  
"birthDate": "1975-08-01",  
"clientCategoryIds": [  
  "sV-l8hImJQDBdpFGFGB1bA"  
],  
"clientSince": "2021-08-01T14:21:48.487Z",  
"createdAt": "2021-08-01T14:21:48.487Z",  
"creditAccount": {  
 "creditDays": 5,  
 "creditLimit": 502.32,  
 "outstandingBalance": 0  
},  
"deleted": false,  
"email": "[[email protected]](mailto:[email protected]) ",  
"emailMarketingConsent": true,  
"emailReminderConsent": true,  
"firstName": "Eamonn2",  
"gender": "MALE",  
"landLine": 35318345657,  
"lastName": "Phorest",  
"mobile": 189654879229145,  
"notes": "sample",  
"smsMarketingConsent": true,  
"smsReminderConsent": true,  
"updatedAt": "2021-10-01T14:21:48.487Z",  
"version": 1  
}

Response

{  
   "clientId": "igK6P6lu40g3UeT_zhmJhw",  
   "version": 1,  
   "firstName": "Amanda",  
   "lastName": "Doe",  
   "mobile": "1234871229345",  
   "landLine": "35312345667",  
   "email": "[[email protected]](mailto:[email protected])",  
   "createdAt": "2021-10-04T09:39:46.000Z",  
   "updatedAt": "2021-10-04T09:39:46.000Z",  
   "address": {  
       "streetAddress1": "Test",  
       "streetAddress2": "Test2",  
       "city": "Toronto",  
       "state": "Toronto",  
       "postalCode": "",  
       "country": "Canada"  
   },  
   "birthDate": "2021-10-01",  
   "clientSince": "2021-10-01T14:21:48.000Z",  
   "gender": "FEMALE",  
   "notes": "sample",  
   "smsMarketingConsent": true,  
   "emailMarketingConsent": true,  
   "smsReminderConsent": true,  
   "emailReminderConsent": true,  
   "creditAccount": {  
       "outstandingBalance": 0,  
       "creditDays": 0,  
       "creditLimit": 500.00  
   },  
   "archived": false,  
   "deleted": false,  
   "banned": false,  
   "clientCategoryIds": \[]  
}

Updating a client

Method: PUT > Update Client for a business

Endpoint: /third-party-api-server/api/business/{businessId}/client/{clientId}

Postman URL: https://platform.phorest.com/third-party-api-server/api/business/INSERT BUSINESS_ID HERE/client/INSERT CLIENT_ID HERE


🚧

Pay special attention to the "version" field. For the versioning, you must put the current version in the body request. For the next update for that client you'll have to increment + 1 (for instance, looking at the screenshot below, if you want to make a new request, you need to use "version": 17 on the body request).

There is no need to add the creatingBranchId on the body request in order to update the client. It's a creatingBranchId so it's just the branch the client is created at. Clients are on a business level.


Body request

{  
 "clientId": "lHTy5IXdYz5F1-d9zCdelQ",  
 "creatingBranchId": "tQHEfFVAijm4MzlI3gM9Gg",  
 "email": "[[email protected]](mailto:[email protected])",  
 "firstName": "Dmitry",  
 "lastName": "Doe",  
 "mobile": 871229348,  
 "version": 16  
}

Response

{  
   "clientId": "lHTy5IXdYz5F1-d9zCdelQ",  
   "version": 17,  
   "firstName": "Dmitry",  
   "lastName": "Doe",  
   "mobile": "871229348",  
   "landLine": "",  
   "email": "[[email protected]](mailto:[email protected])",  
   "createdAt": "2021-04-16T10:28:41.000Z",  
   "updatedAt": "2021-11-03T15:15:29.000Z",  
   "address": {  
       "streetAddress1": "",  
       "streetAddress2": "",  
       "city": "",  
       "state": "",  
       "postalCode": "",  
       "country": ""  
   },  
   "clientSince": "2021-04-16T10:28:41.000Z",  
   "gender": "FEMALE",  
   "notes": "",  
   "smsMarketingConsent": false,  
   "emailMarketingConsent": false,  
   "smsReminderConsent": true,  
   "emailReminderConsent": true,  
   "preferredStaffId": "nfyCJWf4KYalrmI7H2JwYw",  
   "creditAccount": {  
       "outstandingBalance": 10.00,  
       "creditDays": 0,  
       "creditLimit": 2345.00  
   },  
   "creatingBranchId": "tQHEfFVAijm4MzlI3gM9Gg",  
   "archived": false,  
   "deleted": false,  
   "banned": false,  
   "clientCategoryIds": [  
       "GjU9lkUGvysJwI9zxJYt8w"  
   ]  
}