Merchant API: create a failed shipment notification
About this article
This article explains how to use POST /v2/shipments/mark-import-as-failed to trigger a notification in ChannelEngine's notification center, alerting all users in your tenant that the shipments of a given order, exported by your merchant system, could not be imported into ChannelEngine.
Table of contents
Introduction
Your merchant system exports shipments to ChannelEngine via POST /v2/shipments. If ChannelEngine cannot import a shipment, the shipment does not appear on ChannelEngine. This can happen because of validation issues, for example when the sum of the shipment-line quantities exceeds the quantity of the corresponding order line. In that case, you can use POST /v2/shipments/mark-import-as-failed to send a notification through ChannelEngine's notification center.
Calling this endpoint triggers a notification that is visible to all users in your ChannelEngine tenant, alerting them that the shipments of one or more orders were not successfully imported into ChannelEngine. This gives your team visibility into the failure directly on ChannelEngine, without requiring them to check external logs or wait for someone to report the issue manually.
Use this endpoint as part of your error handling logic. Once the cause of the failure is resolved, export the corrected shipments again via POST /v2/shipments.
Users can also check the status of the import on ChannelEngine. In Settings, Scheduled tasks, the Import shipments from merchant task shows the status Failed.
Overview
Refer to the diagram below to visualize how a failed shipment import notification fits into the shipment export flow.
Requirements
Before making your first API call, you need the following:
- A ChannelEngine account with at least one channel connected.
- A Merchant API key generated on ChannelEngine at Settings, Merchant API keys.
-
Your base API URL constructed from your account subdomain:
https://{your-subdomain}.channelengine.net/api. -
One or more ChannelEngine order IDs for the orders whose shipments failed to import. These are returned in the response body of
GET /v2/orders/neworGET /v2/ordersas theIdfield on each order.
Authentication
Every request to the Merchant API must include your API key in the x-ce-key request header:
x-ce-key: your-api-key-here
Available API endpoints
This article covers the following endpoint:
-
Create a failed shipment import notification:
POST /v2/shipments/mark-import-as-failed
Triggers a notification in ChannelEngine's notification center for all users in your tenant, indicating that the shipments of the specified orders, exported by your merchant system, could not be imported into ChannelEngine.
Endpoint: create a failed shipment import notification
POST /v2/shipments/mark-import-as-failed sends a notification via ChannelEngine's notification center to all users in your tenant. The notification identifies the affected orders and signals that the import of their shipments into ChannelEngine did not succeed. It does not create the shipment and does not affect the marketplace.
Request body
The request body is a JSON object containing the identifier type and an array of order objects. Each object in the array identifies one order for which a notification should be sent.
| Field | Type | Required | Description |
IdentifierType |
enum | Required | The type of identifier used to specify the orders. Always set to ORDER_ID. |
Models[].Identifier |
integer | Required | The ChannelEngine internal order ID. This is the Id field returned by GET /v2/orders/new or GET /v2/orders. |
Models[].FailExportMessage |
string | Required | A short description of why the shipment could not be imported into ChannelEngine. Included in the notification text visible to users in the notification center. |
FailExportMessage is required for every order in your request. The reason is shown in the notification, so a descriptive message helps your team understand and act on the failure without needing to check external logs. For validation failures, include the values that caused the failure, e.g.: the order line ID, the expected quantity, and the actual quantity.
Response body
| Field | Type | Description |
StatusCode |
integer | The HTTP status code of the response. |
Success |
boolean | Indicates whether the notification was sent. Always check this field, not just the HTTP status code. |
Message |
string | A short description of the result, e.g.: Item successfully updated. |
ValidationErrors |
object | Details of any validation errors in your request. Empty when the request is valid. |
ExceptionType |
string | The type of exception, if an error occurred. Otherwise null. |
RequestId and LogId
|
string | Identifiers of the request in ChannelEngine's logs. These can be null on a successful call. Log them when they are present and include them when contacting ChannelEngine Support. |
Response codes
| Status | Meaning |
200 OK |
The notification was sent successfully. Check the Success field in the response body, because a 200 HTTP status does not guarantee all orders were processed without issue. |
400 Bad Request |
The request body is malformed or a required field, such as Identifier or FailExportMessage, is missing. |
401 Unauthorized |
The API key is missing, invalid, or does not have access to the requested account. |
429 Too Many Requests |
The rate limit for this endpoint has been exceeded. Wait for the rate limit window to reset before retrying. |
500 Internal Server Error |
An unexpected error occurred on ChannelEngine's side. Log the RequestId and LogId from the response, when present, and include them when contacting ChannelEngine Support. |
Example request
The example below sends a failed shipment import notification for two orders. The first order failed because the shipment line quantities exceed the order line quantity, and the second because a tracking number is too long. Replace the Identifier values with the actual order IDs from your order retrieval response.
POST https://{your-subdomain}.channelengine.net/api/v2/shipments/mark-import-as-failed
x-ce-key: your-api-key-here
Content-Type: application/json
{
"IdentifierType": "ORDER_ID",
"Models": [
{
"Identifier": 63,
"FailExportMessage": "Sum of shipment line quantities exceeds order line quantity. OrderLineId: 63, expected: 1, actual: 2"
},
{
"Identifier": 64,
"FailExportMessage": "Tracking number exceeds the maximum length of 50 characters"
}
]
}A successful response looks like this:
{
"StatusCode": 200,
"RequestId": null,
"LogId": null,
"Success": true,
"Message": "Item successfully updated",
"ExceptionType": null,
"ValidationErrors": {}
}After a successful call, all users in your ChannelEngine tenant see a notification in the Notification center indicating that the shipments of the specified orders were not imported into ChannelEngine. The Import shipments from merchant task in Settings, Scheduled tasks also shows the status Failed.
Success in the response body, not just the HTTP status code. A 200 response with "Success": false indicates that ChannelEngine accepted the request but could not send the notification for one or more of the supplied orders. Log RequestId and LogId on every response, when present, for troubleshooting.
Common issues
| Issue | Likely cause | Fix |
400 Bad Request |
The request body is malformed, IdentifierType is missing or set to an invalid value, or Identifier or FailExportMessage is missing from one or more objects in the Models array. |
Validate your request body before sending. Ensure IdentifierType is set to ORDER_ID and each object in Models includes Identifier as an integer and a FailExportMessage. |
200 OK with "Success": false
|
One or more Identifier values do not match an order in ChannelEngine, or the order is in a state that does not support this notification. |
Confirm the Identifier values match the Id field returned by GET /v2/orders/new or GET /v2/orders. Check Message and ValidationErrors in the response, and contact ChannelEngine Support if the issue persists. |
| The shipment does not appear on ChannelEngine after the notification is sent | This is expected behavior. Sending the notification does not import the shipment or fix the underlying validation issue. | Fix the underlying issue in your merchant system, e.g.: correct the shipment line quantities, then export the shipment again via POST /v2/shipments. |
| The Import shipments from merchant task has the status Failed | ChannelEngine did not successfully import one or more shipments from your merchant system. | Check the notification in the Notification center for the reason, correct the data in your merchant system, and export the shipment again. |
429 Too Many Requests |
The rate limit for this endpoint has been exceeded. | Check the rate limit headers on the response and wait for the window to reset. Batch multiple order IDs into a single request rather than making one call per order. |
| Users are not seeing the notification | The notification was sent but may not be visible if the user has dismissed it or notifications are filtered in their view. | Confirm the response returned "Success": true. Ask affected users to check their Notification center on ChannelEngine. |
Next steps
- After resolving the issue, export the corrected shipments again via
POST /v2/shipments. - To send the equivalent notification for orders, check out Merchant API: create a failed order export notification.
- For guidance on handling API errors and response codes more broadly, check out Merchant API: errors and response codes.
- For best practices on building resilient integrations, including retry logic and error classification, check out Merchant API: best practices.
- For the full shipment workflow, including creating shipments, retrieving labels, and updating tracking details, check out Merchant API: shipments.
- Include the
RequestIdandLogIdvalues from any response, when present, when contacting ChannelEngine Support about a specific API call.
Comments
0 comments
Article is closed for comments.