Manage Sales Rep Company Access
Sets which customers or customer roles a sales rep can work with in one company. If the sales rep has no access to the company yet, it is granted. The sales rep's access to other companies is not changed.
HTTP Request
- URL:
/salesRep/{id}/companyAccess/{companyId} - Method:
PUT - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_CUSTOMERorREAD_WRITE_CUSTOMER
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | String | Required. The ID of the sales rep. |
companyId | String | Required. The ID of the company. |
Request Body
The request body is a JSON object with at least one of the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
customers | Array | No | IDs of the customers the sales rep can work with. Replaces the current list. |
roles | Array | No | IDs of the customer roles the sales rep can work with. Replaces the current list. See Get All Customer Roles. |
The access type is set automatically:
| What you send | Resulting accessType |
|---|---|
Only roles has values | roles |
| Any other combination | customer |
cURL Example
curl --location --request PUT '<BASE_URL>/salesRep/66b1c2d3e4f5a6b7c8d9e0f1/companyAccess/665434c100e82884676936b9' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"customers": ["66a5023524b16685e42a1eda", "66a5023524b16685e42a1edb"],
"roles": []
}'
Response
- 200 OK: The company access was saved successfully.
- 400 Bad Request: The access token is missing or invalid, the token does not have the required scope, the request body is empty, or a value is invalid.
- 404 Not Found: No sales rep matches the ID (
Sales Rep doesn't exist), or no company matches the company ID (Company doesn't exist).
Sample JSON Response
{
"success": true,
"message": "Company access updated successfully",
"data": {
"id": "66b1c2d3e4f5a6b7c8d9e0f2",
"salesRepId": "66b1c2d3e4f5a6b7c8d9e0f1",
"companyId": "665434c100e82884676936b9",
"accessType": "customer",
"customerIds": ["66a5023524b16685e42a1eda", "66a5023524b16685e42a1edb"],
"roleIds": [],
"company": {
"id": "665434c100e82884676936b9",
"name": "Northwind Supply",
"email": "purchasing@northwindsupply.com",
"phoneNumber": "9735550100",
"status": "active",
"isSubCompany": false
},
"createdAt": "2024-08-06T09:12:51.311Z",
"updatedAt": "2024-10-09T13:05:59.120Z"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the access was saved. |
message | String | Result message. |
data | Object | The saved company access. The fields are the same as in Get All Sales Rep Company Access. |
Notes
- Always send the full list of customers and roles you want. Lists you send replace the current ones, and a list you leave out is cleared.
- To remove all customers and roles for the company, send
{ "customers": [], "roles": [] }. - Use Get Sales Rep Company Access to check the current access.