Skip to main content

Integration Guide — CRM Customer Workspace

Introduction

This guide describes read-only endpoints under /gateway/crm/customers/{keyId} that power the CRM customer card: entity header, contacts, extra addresses, and paginated sales and receipt history with aggregate totals.

For balance by overdue periods, receivable accounts, and receipt settlement, see the CRM Current Account guide.

The public prefix is /gateway.


Concepts

Customer (entityKeyId)

Text identifier of the customer (up to 25 characters). All routes in this guide use this value as keyId in the URL.

Document composite key

Sales and receipt documents in the CRM workspace are identified by documentTypeId, serieId, and number. Use these three route parameters to load payment details or sale body lines.


Endpoints

MethodURLDescription
GET/gateway/crm/customers/{keyId}Entity header, contacts, and extra addresses
GET/gateway/crm/customers/{keyId}/receiptsPaginated receipt headers and paymentsAmount aggregate
GET/gateway/crm/customers/{keyId}/receipts/{documentTypeId}/{serieId}/{number}/payment-detailsPayment lines grouped by payment type
GET/gateway/crm/customers/{keyId}/salesPaginated sale headers and salesTotal aggregate
GET/gateway/crm/customers/{keyId}/sales/{documentTypeId}/{serieId}/{number}/linesBody lines of a sale document

Route parameter: keyId — customer entityKeyId.

Sales and receipt tabs are loaded on demand: the workspace endpoint returns only the header, contacts, and addresses. Call /receipts or /sales when the user opens those tabs.

Workspace response (200 OK)

{
"entity": {
"keyId": "CLI001",
"name": "Example Customer Lda",
"balance": 1250.5,
"limitCredit": 5000,
"lastPurchase": "2026-05-20T00:00:00Z"
},
"contacts": [
{
"id": 1,
"name": "John Smith",
"email1": "john@example.com",
"mobilePhone1": "+351900000000"
}
],
"addresses": [
{
"id": 1,
"addressLine1": "Rua Example 1",
"city": "Lisbon",
"postalCode": "1000-001"
}
]
}

The entity object includes financial summary fields (balance, limitCredit, lastPurchase) alongside standard address and contact data.

Paginated sales and receipts

Both list endpoints accept optional query parameters:

ParameterTypeDescription
pageintPage number (1-based)
pageSizeintRecords per page

The response follows the paginated list structure plus an aggregate total:

EndpointAggregate fieldDescription
/receiptspaymentsAmountSum of receipt totals across all matching documents
/salessalesTotalSigned sum of sale totals (cashier flow applied)

Each data item includes documentTypeId, serieId, number, documentIdentifier, createDate, and totalAmount. Use the three-part key to open detail endpoints.

Receipt header fields (summary): otherValues, virtualTotalAmount, salesmanName, observation.

Sale header fields (summary): salesmanId, salesmanName, headerDiscountPercent, headerDiscountAmount, observation.

Receipt payment details

Returns an array of payment lines grouped by payment type:

FieldDescription
paymentTypeIdPayment type identifier
paymentTypeDescriptionPayment type label
netAmountNet amount for this payment type
paymentMechanismPayment mechanism code
currencyId, currencyRateCurrency and exchange rate
isChangeWhether the line represents change
bankDetailBank details when applicable (account, check, deferred date, …)

Sale body lines

Returns an array of document body lines:

FieldDescription
itemKeyIdItem identifier
descriptionLine description
quantityQuantity
taxIncludedPriceUnit price with tax
discountPercentLine discount percentage
lineTotalLine total

Paginated list structure

FieldTypeDescription
totalCountintTotal records
pageSizeintPage size
currentPageintCurrent page (1-based)
totalPagesintTotal pages
dataarrayDocuments on the page

/receipts and /sales responses also include paymentsAmount or salesTotal, respectively.


Examples

Customer workspace

GET /gateway/crm/customers/CLI001

See Gets the CRM workspace listing for the customer.

Paginated receipts

GET /gateway/crm/customers/CLI001/receipts?page=1&pageSize=20

See Gets paginated receipt document headers for the customer.

Receipt payment details

GET /gateway/crm/customers/CLI001/receipts/5/1/100/payment-details

See Gets payment details for a receipt document.

Paginated sales

GET /gateway/crm/customers/CLI001/sales?page=1&pageSize=20

See Gets paginated sale document headers for the customer.

Sale body lines

GET /gateway/crm/customers/CLI001/sales/2/1/250/lines

See Gets the body lines of a sale document.


  1. Identify the customer — obtain entityKeyId.
  2. Open CRM cardGET /gateway/crm/customers/{keyId} for header, contacts, and addresses.
  3. Sales or receipt historyGET .../sales or GET .../receipts when the user opens those tabs.
  4. Document detail — use documentTypeId, serieId, and number on line or payment endpoints.

For balance, open items, and settlement, follow the CRM Current Account guide.


Common errors

HTTP codeSituationSuggested action
401Missing or invalid tokenAuthenticate on the gateway
404Unknown keyId or document keyVerify identifiers

Conclusion

The CRM customer workspace exposes read access to the customer card and commercial history under /gateway/crm/customers/{keyId}. Load sales and receipts on demand and use the composite key to access body lines and payment details.


Last updated: 2 June 2026