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:
| Field | Type | Required | Description |
|---|---|---|---|
firstName | String | Yes | First name of the sales rep (2 to 30 characters). |
email | String | Yes | Email address of the sales rep. Must be unique. |
lastName | String | No | Last name of the sales rep (up to 30 characters). |
phoneNumber | String | No | Phone number of the sales rep (6 to 15 characters). |
status | String | No | active, pending, invited or inactive. Default is invited. |
accessAll | Boolean | No | Give the sales rep access to every active company and all its customers. Default is false. |
salesRepCompanies | Array | No | Companies the sales rep can access. See Sales Rep Companies Object. |
assignAllCompanies | Boolean | No | Give the sales rep access to every active company. When true, salesRepCompanies is not used. |
defaultAccessType | String | No | Used with assignAllCompanies: customer, roles or all. Default is customer. |
defaultRoleIds | Array | No | Used with assignAllCompanies and defaultAccessType: "roles": IDs of the customer roles to grant. |
metaFields | Array | No | Custom field values. Each item has code (an existing metafield code) and value. |
Sales Rep Companies Object
| Field | Type | Required | Description |
|---|---|---|---|
company | String | Yes | ID of the company. |
customers | Array | No | IDs of customers the sales rep can work with. Each customer must belong to this company. |
roles | Array | No | IDs 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
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the sales rep was created. |
message | String | Result message. |
data | Object | The 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
invitedunless you send a differentstatus.