Skip to main content

Create Sales Rep

Creates a new sales rep. You can also choose which companies, customers and customer roles the sales rep can access.

HTTP Request​

  • URL: /salesRep
  • Method: POST
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_WRITE_CUSTOMER

Request Body​

The request body is a JSON object with the following fields:

FieldTypeRequiredDescription
firstNameStringYesFirst name of the sales rep (2 to 30 characters).
emailStringYesEmail address of the sales rep. Must be unique.
lastNameStringNoLast name of the sales rep (up to 30 characters).
phoneNumberStringNoPhone number of the sales rep (6 to 15 characters).
statusStringNoactive, pending, invited or inactive. Default is invited.
accessAllBooleanNoGive the sales rep access to every active company and all its customers. Default is false.
salesRepCompaniesArrayNoCompanies the sales rep can access. See Sales Rep Companies Object.
assignAllCompaniesBooleanNoGive the sales rep access to every active company. When true, salesRepCompanies is not used.
defaultAccessTypeStringNoUsed with assignAllCompanies: customer, roles or all. Default is customer.
defaultRoleIdsArrayNoUsed with assignAllCompanies and defaultAccessType: "roles": IDs of the customer roles to grant.
metaFieldsArrayNoCustom field values. Each item has code (an existing metafield code) and value.

Sales Rep Companies Object​

FieldTypeRequiredDescription
companyStringYesID of the company.
customersArrayNoIDs of customers the sales rep can work with. Each customer must belong to this company.
rolesArrayNoIDs of customer roles the sales rep can work with. See Get All Customer Roles.

The access type is set automatically: roles when only roles is sent, otherwise customer.

cURL Example​

curl --location '<BASE_URL>/salesRep' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"firstName": "James",
"lastName": "Carter",
"email": "james.carter@aximcommerce.com",
"phoneNumber": "2125550188",
"salesRepCompanies": [
{
"company": "665434c100e82884676936b9",
"customers": ["66a5023524b16685e42a1eda"]
},
{
"company": "665434c100e82884676936ba",
"roles": ["663a0aff4587085935a4fb95"]
}
],
"metaFields": [
{ "code": "territory", "value": "Northeast" }
]
}'

Response​

  • 200 OK: The sales rep was created successfully.
  • 400 Bad Request: The access token is missing or invalid, the token does not have the required scope, a field is missing or invalid, a customer does not exist or belongs to another company, or the email is already in use.

Sample JSON Response​

{
"success": true,
"message": "SalesRep created successfully",
"data": {
"id": "66b1c2d3e4f5a6b7c8d9e0f1",
"firstName": "James",
"lastName": "Carter",
"email": "james.carter@aximcommerce.com",
"phoneNumber": "2125550188",
"status": "invited",
"verifiedEmail": false,
"accessAll": false,
"metaFields": [
{
"id": "66b1c2d3e4f5a6b7c8d9e0f9",
"metaFieldId": "6650c1a2b3c4d5e6f7a8b9c1",
"code": "territory",
"label": "Territory",
"valueType": "text",
"displayStorefront": false,
"value": "Northeast"
}
],
"createdBy": {
"name": "ERP Connector api",
"type": "api"
},
"createdAt": "2024-08-06T09:12:51.204Z",
"updatedAt": "2024-08-06T09:12:51.204Z"
}
}

Response Details​

FieldTypeDescription
successBooleanWhether the sales rep was created.
messageStringResult message.
dataObjectThe new sales rep. The fields are the same as in Get All Sales Reps.

Notes​

  • The response does not include the company access. Use Get Sales Rep to see it.
  • New sales reps start with the status invited unless you send a different status.