Skip to main content

Update Sales Rep

This PUT endpoint is used to update the details of an existing sales representative identified by their unique ID. You can update personal information, contact details, status, and company/customer assignments.

Endpoint

  • URL: /api/salesRep/:id
  • Method: PUT

Path Parameters

ParameterTypeDescription
idstringThe unique identifier of the sales rep to update.

Authentication

  • Header: accessToken
  • Type: Bearer Token
  • Value: <ACCESS-TOKEN>

Request Headers

HeaderTypeDescription
Content-TypestringMust be application/json.
accessTokenstringAccess token for authentication. (required)

Request Body

The body of the request should be a JSON object containing the updated details of the sales rep. All fields are optional - include only the fields you want to update:

FieldTypeDescription
firstNamestringThe first name of the sales rep.
lastNamestringThe last name of the sales rep.
emailstringThe email address of the sales rep.
phoneNumberstringThe contact number of the sales rep.
statusstringThe status of the sales rep (e.g., "active", "inactive").
salesRepCompaniesarrayArray of company assignments with customers and access type.
metaFieldsarrayArray of meta-information fields for the sales rep.

Sales Rep Companies Object (salesRepCompanies[])

FieldTypeDescription
companystringCompany ID that the sales rep is assigned to.
customersarrayArray of customer IDs assigned to this sales rep.
accessTypestringType of access for this company. Valid values: "customer", "role", "all". Defaults to "customer" if not specified.

MetaFields Object (metaFields[])

FieldTypeDescription
codestringCode for the metafield.
valuemixedValue of the metafield.

Note: When updating metafields, existing metafields with the same code will be updated, and new ones will be added.

Sample Request Body

{
"firstName": "John",
"lastName": "Doe",
"email": "john.doe.updated@example.com",
"phoneNumber": "+1234567890",
"status": "active",
"salesRepCompanies": [
{
"company": "665434c100e82884676936b9",
"customers": [
"66a5023524b16685e42a1eda",
"66a5023524b16685e42a1edb",
"66a5023524b16685e42a1edc"
],
"accessType": "customer"
},
{
"company": "665434c100e82884676936ba",
"customers": [
"66a5023524b16685e42a1edd"
],
"accessType": "role"
}
],
"metaFields": [
{
"code": "territory",
"value": "Southeast"
},
{
"code": "commission_rate",
"value": 7.5
}
]
}

Response

  • Status Code: 200 OK

Success Response Body

{
"success": true,
"message": "SalesRep updated successfully",
"data": {
"id": "66a5023524b16685e42a1eda",
"email": "john.doe.updated@example.com",
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "+1234567890",
"status": "active",
"verifiedEmail": true,
"salesRepCompanies": [
{
"id": "665434c100e82884676936b9",
"company": "665434c100e82884676936b9",
"customers": [
"66a5023524b16685e42a1eda",
"66a5023524b16685e42a1edb",
"66a5023524b16685e42a1edc"
],
"accessType": "customer"
},
{
"id": "665434c100e82884676936ba",
"company": "665434c100e82884676936ba",
"customers": [
"66a5023524b16685e42a1edd"
],
"accessType": "role"
}
],
"metaFields": [
{
"id": "66a5023524b16685e42a1edf",
"code": "territory",
"value": "Southeast"
},
{
"id": "66a5023524b16685e42a1ee0",
"code": "commission_rate",
"value": 7.5
}
],
"createdBy": {
"name": "API Name api",
"type": "api"
},
"createdAt": "2024-07-27T14:20:37.573Z",
"updatedAt": "2024-08-15T10:45:22.891Z"
}
}

Success Response Structure

FieldTypeDescription
successbooleanIndicates if the request was successful.
messagestringMessage indicating the update result.
dataobjectContains details of the updated sales rep.

Data Object (data)

FieldTypeDescription
idstringUnique identifier for the sales rep.
emailstringEmail address of the sales rep.
firstNamestringFirst name of the sales rep.
lastNamestringLast name of the sales rep.
phoneNumberstringContact number of the sales rep.
statusstringCurrent status of the sales rep.
verifiedEmailbooleanEmail verification status.
salesRepCompaniesarrayArray of company assignments with IDs transformed.
metaFieldsarrayAdditional metadata with generated IDs.
createdByobjectInformation about who created the sales rep.
createdAtstring (ISO 8601)Timestamp of when the sales rep was created.
updatedAtstring (ISO 8601)Timestamp of the last update (reflects this update).

Error Responses

Status CodeDescription
400 Bad RequestThe request body contains invalid data or validation errors.
401 UnauthorizedThe access token is invalid or missing.
403 ForbiddenYou do not have permission to update sales reps.
404 Not FoundNo sales rep matches the specified id.
500 Internal Server ErrorAn error occurred on the server.