Get Customer

GET/customers/:customerId

Request Configuration

Method: GET
URL: https://api.mpowerpromo.com/customers/{{customerId}}
Authentication: Required (JWT Bearer token)


Path Parameters

Parameter Description Required Data Type Example
customerId MongoDB ObjectId of the customer Yes ObjectId 507f1f77bcf86cd799439011

Headers

Header Description Required Example
Authorization Bearer JWT token Yes {{vault:bearer-token}}
Content-Type Content type No application/json
portal Portal identifier (admin/customer) No admin

Query Parameters

None - This endpoint does not accept query parameters.


Response Fields

Core Customer Fields

Field Description Data Type
_id Customer's unique MongoDB ID ObjectId
customerId Sequential customer ID number Number
email Customer's email address String
firstName Customer's first name String
lastName Customer's last name String
jobTitle Customer's job title String
isActive Whether account is active Boolean
rank Customer ranking/priority Number
deletedAt Soft delete timestamp (if deleted) Date / null
createdAt Account creation timestamp Date (ISO 8601)
updatedAt Last update timestamp Date (ISO 8601)

Company Information (Populated)

Field Description Data Type
companyId Company object (populated) Object / null
companyId._id Company's MongoDB ID ObjectId
companyId.companyName Company name String
companyId.photo Company logo URL String
companyId.distributorId Company's distributor ID ObjectId
companyId.referenceFields Custom company fields Object
companyId.notes Company notes String

User Relationships (Populated)

Field Description Data Type
userId Account Manager object (populated) Object / null
userId._id User's MongoDB ID ObjectId
userId.firstName User's first name String
userId.lastName User's last name String
userId.photo User's profile photo URL String
adminUserId Sales Admin object (populated) Object / null
sourceUserId User who created customer (populated) Object / null

Ownership & Distribution

Field Description Data Type
distributorId Distributor's MongoDB ID ObjectId
supplierId Supplier's MongoDB ID (if applicable) ObjectId / null
source Creation source (Web, API, Import, etc.) String
createdBy User ID who created the record ObjectId

Store Access

Field Description Data Type
stores Array of store IDs customer has access to Array[ObjectId]

Contact Information

Field Description Data Type
CustomerPhoneNumbers Array of phone number objects Array[Object]
CustomerPhoneNumbers[]._id Phone record ID ObjectId
CustomerPhoneNumbers[].phoneNumber Phone number String
CustomerPhoneNumbers[].phoneType Type: Work, Cell, Home, Fax String
CustomerPhoneNumbers[].extension Phone extension String

Addresses

Field Description Data Type
CustomerAddresses Array of shipping addresses Array[Object]
CustomerAddresses[]._id Address record ID ObjectId
CustomerAddresses[].street Street address line 1 String
CustomerAddresses[].street1 Street address line 2 String
CustomerAddresses[].city City String
CustomerAddresses[].state State/Province String
CustomerAddresses[].zip Zip/Postal code String
CustomerAddresses[].country Country code String
CustomerAddresses[].isDefault Default address flag Boolean

Billing Addresses

Field Description Data Type
CustomerBillingAddress Array of billing addresses Array[Object]
CustomerBillingAddress[]._id Billing address record ID ObjectId
CustomerBillingAddress[].street Street address String
CustomerBillingAddress[].city City String
CustomerBillingAddress[].state State/Province String
CustomerBillingAddress[].zip Zip/Postal code String
CustomerBillingAddress[].country Country code String
CustomerBillingAddress[].isDefault Default billing address flag Boolean

Shipper Accounts

Field Description Data Type
CustomerShippers Array of shipper accounts Array[Object]
CustomerShippers[]._id Shipper record ID ObjectId
CustomerShippers[].shipperName Shipper company name String
CustomerShippers[].accountNumber Account number String
CustomerShippers[].isDefault Default shipper flag Boolean

Notes & Communication

Field Description Data Type
CustomerNotes Array of notes (with user populated) Array[Object]
CustomerNotes[]._id Note ID ObjectId
CustomerNotes[].note Note text String
CustomerNotes[].userId User object who created note Object
CustomerNotes[].userId._id User's ID ObjectId
CustomerNotes[].userId.firstName User's first name String
CustomerNotes[].userId.lastName User's last name String
CustomerNotes[].userId.photo User's photo URL String
CustomerNotes[].createdAt Note creation date Date
lastContactedAt Last contact timestamp Date / null

Documents (Populated)

Field Description Data Type
Documents Array of document objects (populated) Array[Object]
Documents[]._id Document ID ObjectId
Documents[].fileName Original filename String
Documents[].title Document title String
Documents[].url S3 URL to document String
Documents[].fileSize File size in bytes Number
Documents[].uploadDate Upload timestamp Date
Documents[].userId User who uploaded (populated) Object

Roles & Permissions (Populated)

Field Description Data Type
roles Array of role objects (populated) Array[Object]
roles[]._id Role ID ObjectId
roles[].name Role name String
roles[].settings Role settings/permissions Object

Device & Tracking

Field Description Data Type
customerDevice Device info from account creation Object / null
customerDevice._id Device record ID ObjectId
customerDevice.source Device source (CREATE_ACCOUNT, etc.) String
customerDevice.location Location data Object
customerDevice.userAgent Browser user agent String
customerDevice.referrer Referrer URL String
customerDeviceId Current device ID reference ObjectId / null

UTM & Marketing Data

Field Description Data Type
utmData UTM tracking data Object / null
utmData.utmSource UTM source parameter String
utmData.utmMedium UTM medium parameter String
utmData.utmCampaign UTM campaign parameter String

Social Authentication

Field Description Data Type
socialData Array of social login connections Array[Object]
socialData[].service Service name (facebook, google) String
socialData[].id Social network user ID String

Registration & Activity

Field Description Data Type
registrationsSent Array of registration email records Array[Object]
registrationsSent[].createdAt Email sent date Date
registrationsSent[].storeId Store ID email was sent for ObjectId
hasFollowUps Whether customer has active follow-ups Boolean
reviewsToken Token for product reviews String

Custom Fields

Field Description Data Type
referenceFields Custom fields specific to distributor Object
CustomerArtwork Array of artwork references Array[ObjectId]

Excluded Fields (Not Returned)

These fields are explicitly excluded for security:

  • ❌ password - Encrypted password

  • ❌ passwordResetToken - Password reset token

  • ❌ passwordOrigin - Original plain text password


Example Request

GET https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: {{vault:bearer-token}}

Example Response (Success - 200)

{
"_id": "507f1f77bcf86cd799439011",
"customerId": 12345,
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "Marketing Manager",
"isActive": true,
"rank": 5,
"source": "Web",
"distributorId": "507f1f77bcf86cd799439012",
"stores": [
"507f1f77bcf86cd799439013"
],
"companyId": {
"_id": "507f1f77bcf86cd799439014",
"companyName": "Acme Corporation",
"photo": "https://s3.amazonaws.com/company-logo.png",
"distributorId": "507f1f77bcf86cd799439012",
"referenceFields": {},
"notes": ""
},
"userId": {
"_id": "507f1f77bcf86cd799439015",
"firstName": "Jane",
"lastName": "Smith",
"photo": "https://s3.amazonaws.com/user-photo.png"
},
"adminUserId": {
"_id": "507f1f77bcf86cd799439016",
"firstName": "Bob",
"lastName": "Manager",
"photo": null
},
"sourceUserId": {
"_id": "507f1f77bcf86cd799439017",
"firstName": "Alice",
"lastName": "Creator",
"photo": null
},
"CustomerPhoneNumbers": [
{
"_id": "507f1f77bcf86cd799439018",
"phoneNumber": "555-123-4567",
"phoneType": "Work",
"extension": "123"
},
{
"_id": "507f1f77bcf86cd799439019",
"phoneNumber": "555-987-6543",
"phoneType": "Cell"
}
],
"CustomerAddresses": [
{
"_id": "507f1f77bcf86cd79943901a",
"street": "123 Main Street",
"street1": "Suite 400",
"city": "New York",
"state": "NY",
"zip": "10001",
"country": "US",
"isDefault": true
}
],
"CustomerBillingAddress": [
{
"_id": "507f1f77bcf86cd79943901b",
"street": "123 Main Street",
"city": "New York",
"state": "NY",
"zip": "10001",
"country": "US",
"isDefault": true
}
],
"CustomerShippers": [
{
"_id": "507f1f77bcf86cd79943901c",
"shipperName": "FedEx",
"accountNumber": "123456789",
"isDefault": true
}
],
"CustomerNotes": [
{
"_id": "507f1f77bcf86cd79943901d",
"note": "Prefers email communication",
"userId": {
"_id": "507f1f77bcf86cd799439015",
"firstName": "Jane",
"lastName": "Smith",
"photo": "https://s3.amazonaws.com/user-photo.png"
},
"createdAt": "2025-10-20T10:00:00.000Z"
}
],
"Documents": [
{
"_id": "507f1f77bcf86cd79943901e",
"fileName": "contract.pdf",
"title": "Service Contract",
"url": "https://s3.amazonaws.com/documents/contract.pdf",
"fileSize": 245678,
"uploadDate": "2025-10-15T14:30:00.000Z",
"userId": {
"_id": "507f1f77bcf86cd799439015",
"firstName": "Jane",
"lastName": "Smith",
"photo": "https://s3.amazonaws.com/user-photo.png"
}
}
],
"roles": [
{
"_id": "507f1f77bcf86cd79943901f",
"name": "Customer",
"settings": {
"general": ["view_orders", "place_orders"],
"menu": ["orders", "products"]
}
}
],
"customerDevice": {
"_id": "507f1f77bcf86cd799439020",
"source": "CREATE_ACCOUNT",
"location": {
"city": "New York",
"country": "US",
"ip": "192.168.1.1"
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)...",
"referrer": "https://google.com"
},
"utmData": {
"utmSource": "google",
"utmMedium": "cpc",
"utmCampaign": "summer_2025"
},
"socialData": [],
"registrationsSent": [
{
"createdAt": "2025-10-01T09:00:00.000Z",
"storeId": "507f1f77bcf86cd799439013"
}
],
"hasFollowUps": false,
"reviewsToken": "abc123xyz456",
"referenceFields": {},
"createdAt": "2025-10-01T09:00:00.000Z",
"updatedAt": "2025-10-28T10:00:00.000Z"
}

Error Responses

404 - Customer Not Found (Invalid ID)

{
"message": "Customer not found"
}

404 - Customer Not Found

{
"message": "Customer not found!"
}

401 - Unauthorized

{
"message": "Unauthorized"
}

403 - Forbidden (No Access)

Returned when user doesn't have permission to view this customer.


Access Control

The endpoint applies role-based access:

  1. Admin Users: Can view all customers in the system

  2. Distributor Users: Can only view customers within their distributor

  3. Regular Users: Access based on role settings


Quick Copy Format (CSV-style)

Field,Description,Data Type,Populated
_id,Customer's unique MongoDB ID,ObjectId,No
customerId,Sequential customer ID number,Number,No
email,Customer's email address,String,No
firstName,Customer's first name,String,No
lastName,Customer's last name,String,No
jobTitle,Customer's job title,String,No
isActive,Whether account is active,Boolean,No
rank,Customer ranking/priority,Number,No
companyId,Company object,Object,Yes
userId,Account Manager object,Object,Yes
adminUserId,Sales Admin object,Object,Yes
sourceUserId,User who created customer,Object,Yes
distributorId,Distributor's MongoDB ID,ObjectId,No
stores,Array of store IDs,Array[ObjectId],No
CustomerPhoneNumbers,Array of phone numbers,Array[Object],No
CustomerAddresses,Array of shipping addresses,Array[Object],No
CustomerBillingAddress,Array of billing addresses,Array[Object],No
CustomerShippers,Array of shipper accounts,Array[Object],No
CustomerNotes,Array of notes,Array[Object],Yes (userId)
Documents,Array of documents,Array[Object],Yes (full)
roles,Array of role objects,Array[Object],Yes (full)
customerDevice,Device info from creation,Object,No
utmData,UTM tracking data,Object,No
socialData,Social login connections,Array[Object],No
registrationsSent,Registration email records,Array[Object],No
createdAt,Account creation timestamp,Date,No
updatedAt,Last update timestamp,Date,No

Notes:

  1. Authentication Required: Must provide valid JWT Bearer token

  2. Valid ObjectId: customerId must be a valid 24-character hex string

  3. Excluded Fields: Password fields are never returned

  4. Populated Fields: Related objects (company, users, documents, roles) are fully populated

  5. Null Values: Fields may be null if not set

  6. Access Control: Response filtered based on user permissions

  7. No Query Params: This endpoint doesn't accept filtering or selection parameters

Find Customers

GET/customers

Request Configuration

Method: GET
URL: https://api.mpowerpromo.com/customers
Authentication: Required (JWT Bearer token)


Complete Query Parameters Reference Table

Pagination & Limits

Parameter Description Required Data Type Default Example
page Page number for pagination No Number 1 page=1
limit Number of records per page No Number 25 limit=25
onlyCount Return only count, no data No Boolean false onlyCount=true

Sorting & Ordering

Parameter Description Required Data Type Default Example
ascending Sort order (1=ascending, 0=descending) No Number 0 ascending=1
byColumn Enable column-specific sorting No Number 0 byColumn=1
orderBy Field name to sort by No String - orderBy=lastName

Search & Basic Filtering

Parameter Description Required Data Type Default Example
query Search term (searches across multiple fields) No String - query=john
email Filter by exact email No String - [email protected]
firstName Filter by first name No String - firstName=John
lastName Filter by last name No String - lastName=Doe
jobTitle Filter by job title No String - jobTitle=Manager
isActive Filter by active status No Boolean - isActive=true
rank Filter by customer rank No Number - rank=5
source Filter by creation source No String - source=Web

Company & Store Filtering

Parameter Description Required Data Type Default Example
companyId Filter by company ID No ObjectId - companyId=507f1f77bcf86cd799439011
stores Filter by store ID (alias: store) No ObjectId - stores=507f1f77bcf86cd799439012
store Filter by store ID No ObjectId - store=507f1f77bcf86cd799439012

User Assignment Filtering

Parameter Description Required Data Type Default Example
userId Filter by account manager No ObjectId - userId=507f1f77bcf86cd799439013
adminUserId Filter by sales admin No ObjectId - adminUserId=507f1f77bcf86cd799439014
accountManagerId Filter by account manager (alternative) No ObjectId - accountManagerId=507f1f77bcf86cd799439013
salesAdminId Filter by sales admin (alternative) No ObjectId - salesAdminId=507f1f77bcf86cd799439014
sourceUserId Filter by user who created customer No ObjectId - sourceUserId=507f1f77bcf86cd799439015

External ID Filtering (Integration Systems)

Parameter Description Required Data Type Default Example
customerId Filter by sequential customer ID No Number - customerId=12345
externalId Filter by external/third-party ID No String - externalId=EXT-12345
customerQBId Filter by QuickBooks customer ID No String - customerQBId=QB-12345
customerZohoId Filter by Zoho CRM customer ID No String - customerZohoId=ZOHO-12345
customerHubspotId Filter by HubSpot customer ID No String - customerHubspotId=HS-12345
customerXeroId Filter by Xero accounting customer ID No String - customerXeroId=XERO-12345
customerStripeId Filter by Stripe customer ID No String - customerStripeId=cus_12345

Data Population

Parameter Description Required Data Type Default Example
populate Array of fields to populate (comma-separated) No String - populate=companyId,userId
populate[] Array of fields to populate (multiple params) No String - populate[]=companyId&populate[]=userId

Export Options

Parameter Description Required Data Type Default Example
exportFormat Export format (csv, xlsx, etc.) No String - exportFormat=csv
exportFields Fields to include in export No String - exportFields=email,firstName,lastName

Special Filters

Parameter Description Required Data Type Default Example
withLastFollowUp Include last follow-up information No Number 0 withLastFollowUp=1
hasFollowUps Filter by follow-up status No Boolean - hasFollowUps=true
noDistributor Disable auto distributor filtering No Boolean false noDistributor=true
loadByAccountManager Load by account manager context No Boolean false loadByAccountManager=true
forceQueryByName Force search by name even if no results No Boolean false forceQueryByName=true
defaultValue Include specific customer ID in results No ObjectId - defaultValue=507f1f77bcf86cd799439016

Date Filters

Parameter Description Required Data Type Default Example
createdAt Filter by creation date No Date / Object - createdAt[gte]=2025-01-01
updatedAt Filter by update date No Date / Object - updatedAt[lte]=2025-12-31
lastContactedAt Filter by last contact date No Date / Object - lastContactedAt[gte]=2025-10-01

Example Requests

1. Basic List with Pagination

GET https://api.mpowerpromo.com/customers?page=1&limit=25&ascending=1
Authorization: Bearer {{token}}

2. Search Customers

GET https://api.mpowerpromo.com/customers?query=john&page=1&limit=25
Authorization: Bearer {{token}}

3. Filter by External ID

GET https://api.mpowerpromo.com/customers?externalId=EXT-12345
Authorization: Bearer {{token}}

4. Filter by QuickBooks ID

GET https://api.mpowerpromo.com/customers?customerQBId=QB-12345&populate=companyId
Authorization: Bearer {{token}}

5. Filter by Stripe ID

GET https://api.mpowerpromo.com/customers?customerStripeId=cus_abc123xyz
Authorization: Bearer {{token}}

6. Filter by HubSpot ID

GET https://api.mpowerpromo.com/customers?customerHubspotId=12345678&page=1&limit=1
Authorization: Bearer {{token}}

7. Filter by Store and Sort

GET https://api.mpowerpromo.com/customers?store=507f1f77bcf86cd799439012&orderBy=lastName&ascending=1&page=1&limit=50
Authorization: Bearer {{token}}

8. With Follow-ups and Populated Fields

GET https://api.mpowerpromo.com/customers?page=1&limit=25&withLastFollowUp=1&populate=companyId,userId,stores
Authorization: Bearer {{token}}

9. Filter by Account Manager

GET https://api.mpowerpromo.com/customers?userId=507f1f77bcf86cd799439013&page=1&limit=25&ascending=1
Authorization: Bearer {{token}}

10. Search Active Customers Only

GET https://api.mpowerpromo.com/customers?isActive=true&query=&page=1&limit=25
Authorization: Bearer {{token}}

11. Get Only Count

GET https://api.mpowerpromo.com/customers?onlyCount=true&isActive=true
Authorization: Bearer {{token}}

12. Export to CSV

GET https://api.mpowerpromo.com/customers?exportFormat=csv&exportFields=email,firstName,lastName,companyId,externalId
Authorization: Bearer {{token}}

13. Date Range Filter (Created in October 2025)

GET https://api.mpowerpromo.com/customers?createdAt[gte]=2025-10-01&createdAt[lte]=2025-10-31&page=1&limit=25
Authorization: Bearer {{token}}

14. Multiple Filters Combined

GET https://api.mpowerpromo.com/customers?store=507f1f77bcf86cd799439012&isActive=true&userId=507f1f77bcf86cd799439013&page=1&limit=25&orderBy=lastName&ascending=1&populate=companyId
Authorization: Bearer {{token}}

15. Filter by Sequential Customer ID

GET https://api.mpowerpromo.com/customers?customerId=12345
Authorization: Bearer {{token}}

Response Format

Standard Response (with data)

{
"data": [
{
"_id": "507f1f77bcf86cd799439011",
"customerId": 12345,
"externalId": "EXT-12345",
"customerQBId": "QB-12345",
"customerStripeId": "cus_abc123xyz",
"customerHubspotId": "12345678",
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "Marketing Manager",
"isActive": true,
"rank": 5,
"distributorId": "507f1f77bcf86cd799439012",
"stores": ["507f1f77bcf86cd799439013"],
"companyId": {
"_id": "507f1f77bcf86cd799439014",
"companyName": "Acme Corp"
},
"userId": {
"_id": "507f1f77bcf86cd799439015",
"firstName": "Jane",
"lastName": "Manager",
"photo": null
},
"source": "Web",
"createdAt": "2025-10-01T09:00:00.000Z",
"updatedAt": "2025-10-28T10:00:00.000Z"
}
],
"count": 150,
"referenceFields": []
}

Response Fields

Field Description Data Type
data Array of customer objects Array[Object]
count Total number of matching records Number
referenceFields Custom reference fields (if applicable) Array

Count Only Response (onlyCount=true)

{
"count": 150
}

Export Response (exportFormat=csv)

Returns CSV file as text/plain with customer data.


Customer Object Fields (in response)

Field Description Data Type Populated
_id Customer MongoDB ID ObjectId No
customerId Sequential customer ID Number No
externalId External/third-party ID String No
customerQBId QuickBooks customer ID String No
customerZohoId Zoho CRM customer ID String No
customerHubspotId HubSpot customer ID String No
customerXeroId Xero accounting customer ID String No
customerStripeId Stripe customer ID String No
email Email address String No
firstName First name String No
lastName Last name String No
jobTitle Job title String No
isActive Active status Boolean No
rank Customer rank Number No
distributorId Distributor ID ObjectId No
supplierId Supplier ID ObjectId No
stores Store IDs array Array[ObjectId] Optional
companyId Company object Object Optional
userId Account manager Object Optional
adminUserId Sales admin Object Optional
sourceUserId Creator user Object Optional
CustomerPhoneNumbers Phone numbers array Array[Object] No
CustomerAddresses Addresses array Array[Object] No
source Creation source String No
createdAt Creation date Date No
updatedAt Last update date Date No
lastContactedAt Last contact date Date No
hasFollowUps Has active follow-ups Boolean No

Note: Password fields (password, passwordOrigin, passwordResetToken) are excluded from responses.


Complete Quick Copy Format (CSV-style)

Parameter,Description,Required,Data Type,Example
page,Page number for pagination,No,Number,page=1
limit,Number of records per page,No,Number,limit=25
onlyCount,Return only count no data,No,Boolean,onlyCount=true
ascending,Sort order (1=asc 0=desc),No,Number,ascending=1
byColumn,Enable column sorting,No,Number,byColumn=1
orderBy,Field to sort by,No,String,orderBy=lastName
query,Search term,No,String,query=john
email,Filter by email,No,String,[email protected]
firstName,Filter by first name,No,String,firstName=John
lastName,Filter by last name,No,String,lastName=Doe
jobTitle,Filter by job title,No,String,jobTitle=Manager
isActive,Filter by active status,No,Boolean,isActive=true
rank,Filter by customer rank,No,Number,rank=5
source,Filter by creation source,No,String,source=Web
companyId,Filter by company,No,ObjectId,companyId=507f...
stores,Filter by store,No,ObjectId,stores=507f...
store,Filter by store (alias),No,ObjectId,store=507f...
userId,Filter by account manager,No,ObjectId,userId=507f...
adminUserId,Filter by sales admin,No,ObjectId,adminUserId=507f...
accountManagerId,Filter by account manager,No,ObjectId,accountManagerId=507f...
salesAdminId,Filter by sales admin,No,ObjectId,salesAdminId=507f...
sourceUserId,Filter by creator user,No,ObjectId,sourceUserId=507f...
customerId,Filter by sequential customer ID,No,Number,customerId=12345
externalId,Filter by external/third-party ID,No,String,externalId=EXT-12345
customerQBId,Filter by QuickBooks ID,No,String,customerQBId=QB-12345
customerZohoId,Filter by Zoho CRM ID,No,String,customerZohoId=ZOHO-12345
customerHubspotId,Filter by HubSpot ID,No,String,customerHubspotId=HS-12345
customerXeroId,Filter by Xero accounting ID,No,String,customerXeroId=XERO-12345
customerStripeId,Filter by Stripe customer ID,No,String,customerStripeId=cus_12345
populate,Fields to populate,No,String,populate=companyId,userId
exportFormat,Export format,No,String,exportFormat=csv
exportFields,Fields to export,No,String,exportFields=email,firstName
withLastFollowUp,Include follow-up info,No,Number,withLastFollowUp=1
hasFollowUps,Filter by follow-up status,No,Boolean,hasFollowUps=true
noDistributor,Disable distributor filter,No,Boolean,noDistributor=true
loadByAccountManager,Load by account manager context,No,Boolean,loadByAccountManager=true
forceQueryByName,Force search by name,No,Boolean,forceQueryByName=true
defaultValue,Include specific customer,No,ObjectId,defaultValue=507f...
createdAt,Filter by creation date,No,Date/Object,createdAt[gte]=2025-01-01
updatedAt,Filter by update date,No,Date/Object,updatedAt[lte]=2025-12-31
lastContactedAt,Filter by last contact date,No,Date/Object,lastContactedAt[gte]=2025-10-01

Access Control & Behavior

  1. Auto-filtering by Distributor: Results automatically filtered by logged-in user's distributor (unless admin with noDistributor=true)

  2. Deleted Records: Automatically excluded (deletedAt: { $exists: false })

  3. Role-based Access:

    • Admin roles can view all distributor customers

    • Regular users see customers based on role settings

  4. Populate: Only populated if explicitly requested via populate parameter

  5. Search Query: Searches across multiple fields (email, firstName, lastName, etc.)

  6. External IDs: All external ID filters perform exact matches


Common Use Cases

1. Standard List View

/customers?page=1&limit=25&ascending=1&orderBy=lastName

2. Search Customers

/customers?query=john&page=1&limit=25

3. Find by External System ID

/customers?externalId=EXT-12345
/customers?customerQBId=QB-12345
/customers?customerStripeId=cus_12345

4. Filter by Store

/customers?store=507f1f77bcf86cd799439012&page=1&limit=25

5. Get Customer Count

/customers?onlyCount=true&isActive=true

6. Export All Customers

/customers?exportFormat=csv&exportFields=email,firstName,lastName,companyId,externalId

7. With Related Data

/customers?page=1&limit=25&populate=companyId,userId,stores&withLastFollowUp=1

Notes:

  1. Required Parameters: None - all parameters are optional

  2. Empty Query String: query="" is valid and returns all customers

  3. Multiple Filters: Can combine multiple filter parameters

  4. Date Filtering: Use MongoDB query operators like [gte], [lte], [gt], [lt]

  5. Populate Performance: Only populate fields you need to reduce response size

  6. Export: When exporting, pagination is ignored and all matching records are returned

  7. Authentication: Valid JWT Bearer token required in all cases

  8. External IDs: All external ID fields are case-sensitive and perform exact matches

  9. Case Sensitivity: Most string filters are case-sensitive unless using query parameter

Create Customer

POST/customers

Core Fields

Field Description Required Data Type
email Customer email address (unique per distributor) Yes String
stores Array of store IDs customer has access to Yes Array[ObjectId]
firstName Customer's first name No String
lastName Customer's last name No String
password Plain text password (auto-encrypted) No String
passwordOrigin Original password (stored separately) No String

Company Information

Field Description Required Data Type
customerCompany Company name (auto-creates company record) No String
companyId Direct reference to existing company No ObjectId
jobTitle Customer's job title/position No String

Ownership & Tracking

Field Description Required Data Type
sourceUserId User who created this customer (auto-set) No ObjectId
distributorId Distributor ID (auto-assigned) No ObjectId
supplierId Supplier ID if applicable No ObjectId
source Creation source (defaults to "Web") No String
createdBy User who created the record (auto-set) No ObjectId

Account Management

Field Description Required Data Type
userId Account Manager user ID No ObjectId
adminUserId Sales Admin user ID No ObjectId
accountManagerId Alternative account manager field No ObjectId
salesAdminId Alternative sales admin field No ObjectId
isActive Whether customer account is active No Boolean
rank Customer ranking/priority No Number
customerId Sequential customer ID (auto-generated) No Number

Contact Arrays

Field Description Required Data Type
CustomerPhoneNumbers Array of phone number objects No Array[Object]
CustomerPhoneNumbers[].phoneNumber Phone number string No String
CustomerPhoneNumbers[].phoneType Type: Work, Cell, Home, Fax No String
CustomerPhoneNumbers[].extension Phone extension No String

Address Arrays

Field Description Required Data Type
CustomerAddresses Array of shipping address objects No Array[Object]
CustomerAddresses[].street Street address line 1 No String
CustomerAddresses[].street1 Street address line 2 No String
CustomerAddresses[].city City name No String
CustomerAddresses[].state State/Province code No String
CustomerAddresses[].zip Zip/Postal code No String
CustomerAddresses[].country Country code (ISO 2-letter) No String
CustomerAddresses[].isDefault Mark as default address No Boolean

Billing Address Arrays

Field Description Required Data Type
CustomerBillingAddress Array of billing address objects No Array[Object]
CustomerBillingAddress[].street Street address line 1 No String
CustomerBillingAddress[].city City name No String
CustomerBillingAddress[].state State/Province code No String
CustomerBillingAddress[].zip Zip/Postal code No String
CustomerBillingAddress[].country Country code (REQUIRED for billing) Yes* String
CustomerBillingAddress[].isDefault Mark as default billing address No Boolean

Shipper Information

Field Description Required Data Type
CustomerShippers Array of shipper account objects No Array[Object]
CustomerShippers[].shipperName Shipper company name No String
CustomerShippers[].accountNumber Shipper account number No String
CustomerShippers[].isDefault Mark as default shipper No Boolean

Notes & Documentation

Field Description Required Data Type
CustomerNotes Array of note objects No Array[Object]
CustomerNotes[].note Note text content No String
CustomerNotes[].userId User who created note No ObjectId
CustomerNotes[].createdAt Note creation timestamp No Date (ISO 8601)
Documents Array of document/upload IDs No Array[ObjectId]

Permissions & Roles

Field Description Required Data Type
roles Array of customer role IDs No Array[ObjectId]

Social Authentication

Field Description Required Data Type
socialData Array of social login objects No Array[Object]
socialData[].service Social network (facebook, google, etc.) No String
socialData[].id Social network user ID No String

Email & Communication

Field Description Required Data Type
sendRegistrationEmail Send welcome email immediately No Boolean
registrationsSent Array of registration email records No Array[Object]

Custom & Reference Fields

Field Description Required Data Type
referenceFields Custom fields specific to distributor No Object
CustomerArtwork Array of artwork objects (rarely used) No Array[Object]

Device Tracking

Field Description Required Data Type
customerDeviceId Customer device tracking ID No ObjectId

Notes:

  1. Required Fields: Only email and stores are strictly required

  2. Auto-Generated: Fields like customerId, createdBy, sourceUserId, and distributorId are auto-set if not provided

  3. Conditional Required: CustomerBillingAddress[].country is required IF you're adding billing addresses

  4. ObjectId Format: Use valid MongoDB ObjectId strings (24 hex characters)

  5. Date Format: Use ISO 8601 format (e.g., "2025-10-28T10:00:00.000Z")

  6. Country Codes: Use ISO 2-letter codes (US, CA, GB, etc.)

  7. Phone Types: Common values are "Work", "Cell", "Home", "Fax"

Example request body

{
  "email": "[email protected]",
  "stores": [
    "507f1f77bcf86cd799439011"
  ],
  "firstName": "John",
  "lastName": "Doe",
  "jobTitle": "Marketing Manager",
  "password": "SecurePassword123!",
  "passwordOrigin": "SecurePassword123!",
  "customerCompany": "Acme Corporation",
  "source": "Web",
  "userId": "507f1f77bcf86cd799439016",
  "adminUserId": "507f1f77bcf86cd799439017",
  "isActive": true,
  "rank": 5,
  "sendRegistrationEmail": true,
  "CustomerPhoneNumbers": [
    {
      "phoneNumber": "555-123-4567",
      "phoneType": "Work",
      "extension": "123"
    },
    {
      "phoneNumber": "555-987-6543",
      "phoneType": "Cell"
    }
  ],
  "CustomerAddresses": [
    {
      "street": "123 Main Street",
      "street1": "Suite 400",
      "city": "New York",
      "state": "NY",
      "zip": "10001",
      "country": "US",
      "isDefault": true
    }
  ],
  "CustomerBillingAddress": [
    {
      "street": "123 Main Street",
      "city": "New York",
      "state": "NY",
      "zip": "10001",
      "country": "US",
      "isDefault": true
    }
  ],
  "CustomerShippers": [
    {
      "shipperName": "FedEx",
      "accountNumber": "123456789",
      "isDefault": true
    }
  ],
  "CustomerNotes": [
    {
      "note": "Prefers email communication",
      "userId": "507f1f77bcf86cd799439018",
      "createdAt": "2025-10-28T10:00:00.000Z"
    }
  ],
  "roles": [
    "507f1f77bcf86cd799439019"
  ],
  "Documents": [],
  "socialData": [],
  "CustomerArtwork": []
}

Update Customer

PUT/customers/:customerId

Request Configuration

Method: PUT or PATCH
URL: https://api.mpowerpromo.com/customers/{{customerId}}
Authentication: Required (JWT Bearer token)

Note: Both PUT and PATCH methods are supported and use the same handler.


Path Parameters

Parameter Description Required Data Type Example
customerId MongoDB ObjectId of the customer Yes ObjectId 507f1f77bcf86cd799439011

Headers

Header Description Required Example
Authorization Bearer JWT token Yes {{vault:bearer-token}}
Content-Type Content type Yes application/json

Request Body Parameters

Basic Information Fields

Field Description Required Data Type Notes
email Customer email address No String Must be unique per distributor
firstName Customer's first name No String -
lastName Customer's last name No String -
jobTitle Job title/position No String -
isActive Account active status No Boolean -
rank Customer ranking/priority No Number -

Company Information

Field Description Required Data Type Notes
customerCompany Company name (updates company record) No String Updates linked company's name
companyId Company ObjectId reference No ObjectId -

Password Management

Field Description Required Data Type Notes
passwordOrigin Original password (plain text) No String Stored separately, encrypts automatically

Important: password field is automatically removed from updates for security. Use passwordOrigin to update password.

User Assignments

Field Description Required Data Type Notes
userId Account Manager ObjectId No ObjectId -
adminUserId Sales Admin ObjectId No ObjectId -
sourceUserId User who created customer No ObjectId -

Store & Distribution

Field Description Required Data Type Notes
stores Array of store IDs No Array[ObjectId] Duplicates auto-removed
distributorId Distributor ObjectId No ObjectId -
supplierId Supplier ObjectId No ObjectId -
source Creation source No String e.g., "Web", "API", "Import"

External IDs (Integration Systems)

Field Description Required Data Type Notes
externalId External/third-party ID No String -
customerQBId QuickBooks customer ID No String -
customerZohoId Zoho CRM customer ID No String -
customerHubspotId HubSpot customer ID No String -
customerXeroId Xero accounting customer ID No String -
customerStripeId Stripe customer ID No String -

Contact Arrays

Field Description Required Data Type Notes
CustomerPhoneNumbers Complete array of phone objects No Array[Object] Replaces entire array
CustomerAddresses Complete array of address objects No Array[Object] State fields auto-filled
CustomerBillingAddress Complete array of billing address objects No Array[Object] State fields auto-filled
CustomerShippers Complete array of shipper objects No Array[Object] Replaces entire array
CustomerNotes Complete array of note objects No Array[Object] Replaces entire array

Phone Number Object Structure

{
"_id": "507f1f77bcf86cd799439011",
"phoneNumber": "555-123-4567",
"phoneType": "Work",
"extension": "123"
}

Address Object Structure

{
"_id": "507f1f77bcf86cd799439012",
"street": "123 Main Street",
"street1": "Suite 400",
"city": "New York",
"state": "NY",
"zip": "10001",
"country": "US",
"isDefault": true
}

Billing Address Object Structure

{
"_id": "507f1f77bcf86cd799439013",
"street": "123 Main Street",
"city": "New York",
"state": "NY",
"zip": "10001",
"country": "US",
"isDefault": true
}

Shipper Object Structure

{
"_id": "507f1f77bcf86cd799439014",
"shipperName": "FedEx",
"accountNumber": "123456789",
"isDefault": true
}

Note Object Structure

{
"_id": "507f1f77bcf86cd799439015",
"note": "Important customer note",
"userId": "507f1f77bcf86cd799439016",
"createdAt": "2025-10-28T10:00:00.000Z"
}

Additional Fields

Field Description Required Data Type Notes
Documents Array of document ObjectIds No Array[ObjectId] -
roles Array of role ObjectIds No Array[ObjectId] -
socialData Array of social login objects No Array[Object] -
referenceFields Custom fields specific to distributor No Object -
hasFollowUps Whether customer has active follow-ups No Boolean -
lastContactedAt Last contact timestamp No Date ISO 8601 format

Read-Only / Auto-Managed Fields

These fields are automatically managed and cannot be directly updated:

  • ❌ password - Removed for security (use passwordOrigin)

  • ❌ __v - Mongoose version key

  • ✅ customerId - Auto-generated if missing

  • ✅ updatedAt - Auto-updated on save


Example Requests

1. Update Basic Information

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"jobTitle": "Senior Marketing Manager"
}

2. Update External IDs

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"externalId": "EXT-12345",
"customerQBId": "QB-98765",
"customerStripeId": "cus_abc123xyz",
"customerHubspotId": "12345678"
}

3. Update Password

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"passwordOrigin": "NewSecurePassword123!"
}

4. Update Account Manager and Status

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"userId": "507f1f77bcf86cd799439016",
"adminUserId": "507f1f77bcf86cd799439017",
"isActive": true,
"rank": 5
}

5. Update Company

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"customerCompany": "Acme Corporation Updated",
"jobTitle": "VP of Marketing"
}

6. Update Stores

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"stores": [
"507f1f77bcf86cd799439020",
"507f1f77bcf86cd799439021"
]
}

7. Update Phone Numbers

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"CustomerPhoneNumbers": [
{
"phoneNumber": "555-123-4567",
"phoneType": "Work",
"extension": "123"
},
{
"phoneNumber": "555-987-6543",
"phoneType": "Cell"
}
]
}

8. Update Addresses

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"CustomerAddresses": [
{
"street": "456 Oak Avenue",
"street1": "Building B",
"city": "Los Angeles",
"state": "CA",
"zip": "90001",
"country": "US",
"isDefault": true
}
]
}

9. Update Billing Address

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"CustomerBillingAddress": [
{
"street": "789 Billing Street",
"city": "Chicago",
"state": "IL",
"zip": "60601",
"country": "US",
"isDefault": true
}
]
}

10. Complete Update (Multiple Fields)

PUT https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}
Content-Type: application/json
{
"firstName": "Jane",
"lastName": "Smith",
"email": "[email protected]",
"jobTitle": "Director of Operations",
"externalId": "EXT-UPDATED-001",
"customerStripeId": "cus_newstripe123",
"isActive": true,
"rank": 10,
"userId": "507f1f77bcf86cd799439016",
"stores": [
"507f1f77bcf86cd799439020"
],
"CustomerPhoneNumbers": [
{
"phoneNumber": "555-111-2222",
"phoneType": "Work"
}
],
"referenceFields": {
"customField1": "Updated Value",
"customField2": "New Value"
}
}

Response Format

Success Response (200)

{
"$$notification": {
"success": "Successfully Saved"
},
"model": {
"_id": "507f1f77bcf86cd799439011",
"customerId": 12345,
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "Senior Marketing Manager",
"externalId": "EXT-12345",
"customerQBId": "QB-98765",
"customerStripeId": "cus_abc123xyz",
"customerHubspotId": "12345678",
"isActive": true,
"rank": 5,
"distributorId": "507f1f77bcf86cd799439012",
"stores": ["507f1f77bcf86cd799439020"],
"userId": "507f1f77bcf86cd799439016",
"adminUserId": "507f1f77bcf86cd799439017",
"CustomerPhoneNumbers": [
{
"_id": "507f1f77bcf86cd799439018",
"phoneNumber": "555-123-4567",
"phoneType": "Work",
"extension": "123"
}
],
"CustomerAddresses": [
{
"_id": "507f1f77bcf86cd79943901a",
"street": "456 Oak Avenue",
"city": "Los Angeles",
"state": "CA",
"zip": "90001",
"country": "US"
}
],
"createdAt": "2025-10-01T09:00:00.000Z",
"updatedAt": "2025-10-28T10:30:00.000Z"
}
}

Error Responses

422 - Email Already in Use

{
"$$notification": {
"error": "Email already in use"
}
}

422 - Validation Error

{
"$$notification": {
"error": "Validation error message"
}
}

500 - User Not Available (Deleted)

{
"error": "User is not available"
}

404 - Customer Not Found

{
"message": "Customer not found"
}

401 - Unauthorized

{
"message": "Unauthorized"
}

Automatic Behaviors

1. Email Uniqueness Check

  • Validates email is unique across the distributor

  • Excludes the current customer from uniqueness check

  • Case-insensitive check

2. Company Name Update

  • If customerCompany is provided, updates the linked company's name

  • Uses the existing companyId to find and update the company

3. Password Handling

  • password field is automatically removed from request body

  • passwordOrigin is extracted and handled separately

  • Password is encrypted automatically before saving

4. Address State Population

  • If both CustomerAddresses and CustomerBillingAddress are provided

  • State fields are automatically filled/validated

5. Store Duplicates Removal

  • If stores array is updated, duplicates are automatically removed

  • Uses clearStoresDuplicates() helper

6. SendGrid Sync

  • If stores are updated, customer is automatically synced to SendGrid

7. Sequential Customer ID

  • If missing, automatically generates next customerId from sequence

8. Change Logging

  • All changes are logged to the Log collection

  • Tracks before/after state with detailed diff

  • Includes IP, user, and timestamp

9. Cache Clearing

  • Automatically clears all cache keys after update

  • Clears runtime cache

10. HubSpot Sync

  • Automatically updates customer in HubSpot after save (async)

11. Private Data Removal

  • Automatically removes private/sensitive fields via removePrivateData()

  • Based on user permissions and context


Important Notes

Fields You CANNOT Update Directly:

  1. password - Use passwordOrigin instead (auto-encrypted)

  2. __v - Mongoose version key (auto-managed)

  3. deletedAt - Use DELETE endpoint instead

Fields That Are Auto-Generated:

  1. customerId - Auto-generated sequential ID if missing

  2. updatedAt - Auto-updated timestamp

  3. createdBy - Cannot be changed after creation

Special Validations:

  1. Email - Must be valid email format and unique per distributor

  2. CustomerBillingAddress - Entries without country are filtered out

  3. Stores - Duplicates automatically removed

  4. ObjectId Fields - Must be valid MongoDB ObjectIds

Automatic Side Effects:

  1. SendGrid - Customer synced to SendGrid if stores updated

  2. HubSpot - Customer synced to HubSpot after save

  3. Cache - All caches cleared after update

  4. Logging - Changes tracked in Log collection with full diff

  5. Company - Company name updated if customerCompany provided


Complete Field Reference Table (CSV)

Field,Description,Required,Data Type,Updatable,Notes
email,Customer email address,No,String,Yes,Must be unique per distributor
firstName,First name,No,String,Yes,-
lastName,Last name,No,String,Yes,-
jobTitle,Job title,No,String,Yes,-
isActive,Active status,No,Boolean,Yes,-
rank,Customer rank,No,Number,Yes,-
customerCompany,Company name,No,String,Yes,Updates linked company record
companyId,Company reference,No,ObjectId,Yes,-
passwordOrigin,Plain text password,No,String,Yes,Auto-encrypted
userId,Account Manager,No,ObjectId,Yes,-
adminUserId,Sales Admin,No,ObjectId,Yes,-
sourceUserId,Creator user,No,ObjectId,Yes,-
stores,Store IDs array,No,Array[ObjectId],Yes,Auto-deduped
distributorId,Distributor ID,No,ObjectId,Yes,-
supplierId,Supplier ID,No,ObjectId,Yes,-
source,Creation source,No,String,Yes,-
externalId,External/third-party ID,No,String,Yes,-
customerQBId,QuickBooks ID,No,String,Yes,-
customerZohoId,Zoho CRM ID,No,String,Yes,-
customerHubspotId,HubSpot ID,No,String,Yes,-
customerXeroId,Xero ID,No,String,Yes,-
customerStripeId,Stripe ID,No,String,Yes,-
CustomerPhoneNumbers,Phone array,No,Array[Object],Yes,Replaces entire array
CustomerAddresses,Address array,No,Array[Object],Yes,Replaces entire array
CustomerBillingAddress,Billing address array,No,Array[Object],Yes,Replaces entire array
CustomerShippers,Shipper array,No,Array[Object],Yes,Replaces entire array
CustomerNotes,Notes array,No,Array[Object],Yes,Replaces entire array
Documents,Document IDs,No,Array[ObjectId],Yes,-
roles,Role IDs,No,Array[ObjectId],Yes,-
socialData,Social login data,No,Array[Object],Yes,-
referenceFields,Custom fields,No,Object,Yes,-
hasFollowUps,Has follow-ups flag,No,Boolean,Yes,-
lastContactedAt,Last contact date,No,Date,Yes,ISO 8601 format
password,Password (encrypted),No,String,No,Use passwordOrigin instead
customerId,Sequential customer ID,No,Number,No,Auto-generated if missing
__v,Version key,No,Number,No,Auto-managed by Mongoose

Best Practices

  1. Partial Updates: Only send fields you want to update

  2. Email Changes: Verify email uniqueness before updating

  3. Password Updates: Always use passwordOrigin, never password

  4. Array Fields: When updating arrays, send the complete array (not individual items)

  5. External IDs: Use appropriate external ID fields for integrations

  6. Validation: Check for validation errors in response

  7. Logging: All changes are logged - ensure user has proper context

  8. Cache: Updates clear cache - may affect performance in high-volume scenarios

Example request body

{
  "userId": null,
  "adminUserId": null,
  "email": "[email protected]",
  "passwordOrigin": "11111",
  "sourceUserId": "5f989350956add0fd61f08bb",
  "companyId": null,
  "CustomerPhoneNumbers": [],
  "CustomerBillingAddress": [
    {
      "country": "",
      "state": ""
    }
  ],
  "stores": [
    {
      "_id": "63911c18053945656f1cecf6",
      "storeName": "MPower Distributor Store",
      "storeUrl": "storeprod.mpowerpromo.com"
    }
  ],
  "states": [],
  "isActive": true,
  "isTest": false,
  "firstName": "Customer",
  "lastName": "Lastname"
}

Delete Customer

DELETE/customers/:customerId

Request Configuration

Method: DELETE
URL: https://api.mpowerpromo.com/customers/{{customerId}}
Authentication: Required (JWT Bearer token)

Important: This is a soft delete - the customer record is not permanently removed from the database. Instead, a deletedAt timestamp is set, marking the customer as deleted.


Path Parameters

Parameter Description Required Data Type Example
customerId MongoDB ObjectId of the customer Yes ObjectId 507f1f77bcf86cd799439011

Headers

Header Description Required Example
Authorization Bearer JWT token Yes {{vault:bearer-token}}

Request Body

None - This endpoint does not require a request body.


Query Parameters

None - This endpoint does not accept query parameters.


Example Requests

Basic Delete Request

DELETE https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}

Using Postman

Method: DELETE
URL: https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Headers:

Authorization: Bearer {{token}}

Body: None


Response Format

Success Response (200)

Returns the deleted customer object with the deletedAt field set:

{
"_id": "507f1f77bcf86cd799439011",
"customerId": 12345,
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe",
"jobTitle": "Marketing Manager",
"externalId": "EXT-12345",
"customerQBId": "QB-98765",
"customerStripeId": "cus_abc123xyz",
"isActive": true,
"distributorId": "507f1f77bcf86cd799439012",
"stores": ["507f1f77bcf86cd799439013"],
"companyId": "507f1f77bcf86cd799439014",
"userId": "507f1f77bcf86cd799439015",
"CustomerPhoneNumbers": [],
"CustomerAddresses": [],
"createdAt": "2025-10-01T09:00:00.000Z",
"updatedAt": "2025-10-28T10:00:00.000Z",
"deletedAt": "2025-10-28T15:30:00.000Z"
}

Error Responses

404 - Customer Not Found

{
"message": "Customer not found"
}

401 - Unauthorized

{
"message": "Unauthorized"
}

403 - Forbidden

{
"message": "Access denied"
}

Behavior & Side Effects

What Happens on Delete:

  1. Soft Delete

    • Customer record is NOT permanently removed

    • deletedAt field is set to current timestamp

    • Customer remains in database but is marked as deleted

  2. API Token Logging

    • Delete action is logged via logCustomerApiTokenRequest()

    • Tracks which user/token performed the deletion

    • Includes timestamp and customer information

  3. Customer Visibility

    • Deleted customers are automatically excluded from GET /customers list queries

    • Filter applied: deletedAt: { $exists: false }

    • Can still be retrieved by direct ID if needed (for audit/recovery)

  4. Related Data

    • Customer's orders, artwork, documents remain intact

    • Relationships preserved for historical/audit purposes

    • No cascade deletion of related records


Important Notes

Soft Delete vs Hard Delete

✅ What This Endpoint Does (Soft Delete):

  • Sets deletedAt timestamp

  • Hides customer from normal queries

  • Preserves all data for audit/recovery

  • Maintains referential integrity

❌ What This Endpoint Does NOT Do (Hard Delete):

  • Does not permanently remove the record

  • Does not delete related orders

  • Does not delete customer artwork

  • Does not remove from database

Recovery

To restore a soft-deleted customer, you would need to:

  1. Use a direct database update to remove the deletedAt field

  2. Or use a custom restore endpoint if available

Access Control

  • User must have appropriate permissions to delete customers

  • Typically restricted to admin users or account managers

  • Deletion is logged for audit trail

Integration Impact

Important for integrations:

  • External IDs (externalId, customerQBId, customerStripeId, etc.) remain in the database

  • If re-creating a customer with the same external ID, you may encounter conflicts

  • Consider checking for soft-deleted customers before creating new ones


After Deletion

Finding Deleted Customers

Deleted customers can still be queried directly by ID:

GET https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}

Response will include:

{
"_id": "507f1f77bcf86cd799439011",
"deletedAt": "2025-10-28T15:30:00.000Z",
...
}

Excluded from List Queries

Deleted customers are automatically excluded:

GET https://api.mpowerpromo.com/[email protected]
Authorization: Bearer {{token}}

Response:

{
"data": [],
"count": 0
}

Use Cases

1. Remove Inactive Customer

DELETE https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439011
Authorization: Bearer {{token}}

2. Clean Up Test Accounts

DELETE https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439012
Authorization: Bearer {{token}}

3. GDPR/Privacy Request (Soft Archive)

DELETE https://api.mpowerpromo.com/customers/507f1f77bcf86cd799439013
Authorization: Bearer {{token}}

Note: For full GDPR compliance, you may need additional steps to anonymize or permanently delete data.


Related Endpoints

Create Customer

POST https://api.mpowerpromo.com/customers

Update Customer

PUT https://api.mpowerpromo.com/customers/{{customerId}}

Get Customer (Including Deleted)

GET https://api.mpowerpromo.com/customers/{{customerId}}

List Active Customers (Excludes Deleted)

GET https://api.mpowerpromo.com/customers?page=1&limit=25

Complete Quick Reference

Aspect Details
Method DELETE
URL https://api.mpowerpromo.com/customers/:customerId
Auth Required (Bearer token)
Body None
Query Params None
Delete Type Soft delete (sets deletedAt)
Returns Updated customer object with deletedAt
Cascade No - related data preserved
Logging Yes - API token request logged
Reversible Yes - via database update
Response Code 200 (Success), 404 (Not Found), 401 (Unauthorized)

CSV Format Reference

Field,Value
Method,DELETE
Endpoint,/customers/:customerId
Authentication,Required (JWT Bearer)
Request Body,None
Query Parameters,None
Delete Type,Soft Delete
Sets Field,deletedAt
Returns,Customer object with deletedAt timestamp
Removes Data,No - soft delete only
Cascade Delete,No
Logged,Yes - via logCustomerApiTokenRequest
Reversible,Yes - requires database update
Success Code,200
Error Codes,"404 (Not Found), 401 (Unauthorized), 403 (Forbidden)"

Best Practices

  1. Confirm Before Delete: Always confirm user intent before deleting

  2. Check Dependencies: Review customer's orders/data before deletion

  3. Audit Trail: Deletion is logged - ensure proper user context

  4. External Systems: Notify integrated systems (QuickBooks, Stripe, etc.) about deletion

  5. Recovery Plan: Have a process to restore accidentally deleted customers

  6. GDPR Compliance: If permanent deletion needed for compliance, additional steps required

  7. Batch Operations: For bulk deletions, consider creating a batch endpoint

Ready to run all of promo in one place?

See how MPower replaces your disconnected tools with one platform — from the first lead to the final shipment.

No credit card required.

Download

Never miss a beat. Download our app and work on the go with all the same features as our desktop application.

Powered by MPower PromoPlatform privacy