Send CMR document by email.
POST/company/cmr/send
Send the CMR document (Digital Consignment Note) associated with a transport service to one or more recipients via email. The PDF document is generated and sent as an attachment.
Objective
Allow companies to distribute the eCMR document to interested parties (customers, carriers, authorities) without the need for manual download. The ecmr_back service manages the asynchronous sending of emails.
Use Cases
- A company needs to send the CMR to its customer for accounting purposes
- The CMR needs to be sent to the carrier for their records
- Customs authorities request the CMR document via email
- The company needs to distribute the CMR to multiple internal departments
Payment Validation
Middleware: mPlan.isPaymentUpdate
This endpoint validates the company's payment status before processing the send:
- Verifies that the JWT token is valid
- Verifies that the company has updated payment permissions
- Rejects the request if the company does not have an active payment or valid subscription If payment validation fails, a 401/403 error will be returned before processing the send.
Behavior
- Validates the
service_codeandemailsparameters - Verifies the user is authenticated and has a valid company
- Validates the payment status (via
isPaymentUpdatemiddleware) - Forwards the request to the ecmr_back service
- ecmr_back generates the PDF and sends the emails
- Returns a send confirmation (not a delivery confirmation)
Notes:
- Email sending is asynchronous: confirmation indicates it was queued, not delivered
- Each recipient will receive the CMR as a PDF attachment
- Maximum of 10 email addresses per request
- No tracking of email opening or delivery is performed
- The service may take up to 10 seconds to respond
Preconditions
- User must be authenticated and exist in database
- User must belong to a valid company
- Company must have valid payment status (validated by isPaymentUpdate)
- A delivery with the given service_code must exist for the company
- The delivery must have an associated eCMR document
Error Codes
Validation Errors (400):
SERVICE_CODE_REQUIRED: Theservice_codeparameter is requiredEMAILS_REQUIRED: Theemailsparameter is required and cannot be empty
**Authentication Errors (401
Request
Responses
- 200
- 400
- 401
- 403
- 404
- 503
The CMR has been successfully sent to the specified recipients. The response confirms that the email was sent to the ecmr_back queue, but it does NOT confirm the effective delivery to the recipients.
Invalid Request - Missing or incorrect parameters. Error codes:
SERVICE_CODE_REQUIRED: Missingservice_codeparameterEMAILS_REQUIRED: Missingemailsparameter or it is empty (array with length 0)
Unauthorized - Authentication or payment issues. Error codes:
USER_NOT_FOUND: The authenticated user does not exist in the databaseAUTHORIZATION_TOKEN_REQUIRED: Missing token in the headers- Payment validation failed (middleware
isPaymentUpdate): The company does not have a valid payment status
Forbidden - The company does not have updated payment permissions.
The isPaymentUpdate middleware rejected the request due to lack of active payment.
Not found - Delivery does not exist for this company. Error codes:
NOT_FOUND: No delivery with thatservice_codeexists for this company
Service unavailable - Error communicating with the ecmr_back service or timeout during sending.
Possible causes:
- The ecmr_back service is unavailable
- Timeout waiting for email sending (maximum 10 seconds)
- Internal error in the ecmr_back service