Lanctot Integration API Documentation
This reference covers three integration surfaces: Invoice PDF endpoints for BC, Order ingest endpoints for Opal, and Morel Play order and return endpoints to BC.
Quick Start
Use this checklist to validate all three integration surfaces: BC Invoice, Opal ingest and Morel Play ingest.
Common Setup
- Set the Base URL to the endpoint provided by Lanctot.
- Use the correct x-api-key for each surface (Invoice, Opal and Morel keys can differ).
- Call GET /health, GET /opal/health and GET /morel/health to verify all surfaces are available.
BC Invoice Flow
- Send POST /api/pdf (or POST /v1/api/pdf) with invoice identifiers.
- If response mode is data, decode base64 using Decode Base64 To PDF.
- If response mode is url, open the returned PDF URL before token expiry.
Opal Ingest Flow
- Send POST /opal/v1/api/ingest with header + line payload.
- Confirm success response includes header_id, line_ids, and line_count.
- If external_document_no already exists, expect HTTP 409 and code DUPLICATE_EXTERNAL_DOCUMENT_NO.
Morel Play Ingest Flow
- Send POST /morel/v1/api/orders with the Morel order document.
- Send returns separately with POST /morel/v1/api/returns using the returns document.
- Confirm the response status is staged (HTTP 202), or a skipped status with the reason. The puller then posts the staged row to BC.
Invoice Consumer Contract
This section defines the API contract for BC invoice PDF integrations.
1) Endpoint
- Base URL: https://api.rlanctot.com
- Method: POST
- Path: /api/pdf
- Production URL: https://api.rlanctot.com/api/pdf
2) Authentication
- Mode: API key
- Required header: x-api-key: <shared-secret>
- BC backend sends this header on each request.
3) Supported Link Types
- invoiceExternalUrl
4) Request Contract
5) Response Contract
Current mode: data (base64 PDF)
6) Error Contract
7) Testing And Ops Notes
- Use only the production endpoint for integrations.
- No proxy is required while response mode is data.
- Lanctot will provide timeout expectations, support contact, and environment details.
Opal Invoice Ingest Contract
This section defines the API contract for Opal invoice staging integrations.
1) Endpoint
- Base URL: https://api.rlanctot.com
- Method: POST
- Path: /opal/v1/api/ingest
- Alias: /opal/api/ingest
2) Authentication
- Mode: API key
- Required header: x-api-key: <opal-shared-secret>
3) Request Contract
4) Line Number Rule
Line No. must match line position using this formula: Line No. = Line Position x 10,000.
| Position | BC Line No. |
|---|---|
| 1st line | 10000 |
| 2nd line | 20000 |
| 3rd line | 30000 |
| 4th line | 40000 |
5) Price And Discount Override
- unit_price and line_discount_pct are optional.
- Send these fields only when you need to override internal pricing or discount logic.
6) Mandatory Fields
| Field | Required | Notes |
|---|---|---|
| customer_no | yes | Header field, non-blank. |
| lines | yes | Must include at least one line object. |
| lines[].line_no | yes | Must follow position rule: 1st=10000, 2nd=20000, 3rd=30000, etc. |
| lines[].item_reference | yes | External item reference, non-blank and unique to the line. |
| lines[].quantity | yes | Must be non-zero. |
| line_comment | optional | Only included when needed for notes. |
7) Success Response
8) Duplicate Handling
- If external_document_no already exists, API returns HTTP 409.
- Error code: DUPLICATE_EXTERNAL_DOCUMENT_NO.
- Server sets line location_code to 19-DROP and ignores customer_name/bin_code from client payloads.
Morel Play Ingest Contract
This section defines the API contract for Morel Play order and return integrations. Every document is first written to the SQL staging table, then a puller posts staged rows to Business Central staging orders and records the outcome on the staging row.
1) Endpoints
- Base URL: https://api.rlanctot.com
- Orders: POST /morel/v1/api/orders (alias: /morel/api/orders)
- Returns: POST /morel/v1/api/returns (alias: /morel/api/returns)
- Health: GET /morel/health
- Staging table: dbo.staging_morel_order_import (Lanctot_BC SQL)
2) Authentication
- Mode: API key
- Required header: x-api-key: <morel-shared-secret>
3) Order Request Contract
4) Returns Request Contract
Returns are sent separately to the returns endpoint, using the returns document. The return reference is the document returnId.
5) Posting Rules
- Every received document is written to the SQL staging table dbo.staging_morel_order_import first, including skipped documents. A background puller posts rows in staged status to BC, in receive order, and records the final status on the row: posted, already_exists, or failed after retries.
- Only clients whose client.id starts with C0 are posted to BC. Any other client returns HTTP 200 with status skipped_non_bc_client and nothing is sent to BC.
- Orders post only when qtyTotal is above 0. Otherwise HTTP 200 with status skipped_no_order_quantity.
- Returns post only when qtyReturnTotal is below 0. Otherwise HTTP 200 with status skipped_no_return_quantity.
- The line sku is split at the first underscore: the part before it is the BC item number, the part after it is the variant code.
- Orders land in BC staging as document type Order, origin 102PLAY, freight collection 41MOREL. Returns land as Return Order with lines at location 13-RTN MTL.
- Sending the same document again returns HTTP 200 with status already_exists.
6) Mandatory Fields
| Field | Required | Notes |
|---|---|---|
| id (or _id) | yes | Document identifier. Used as the BC reference for orders. |
| client.id | yes | BC customer number, non-blank. Must start with C0 to post. |
| lines | yes | Must include at least one line object. |
| lines[].sku | yes | Item number and variant joined by an underscore, non-blank. |
| lines[].quantity | yes | Line quantity. |
| returnId | returns | Used as the BC reference for return orders. |
7) Success Responses
Accepted and staged in SQL (HTTP 202). The puller then posts the row to BC:
Skipped documents are also staged, with their skip status, and return HTTP 200:
Authentication
BC backend callers authenticate using the mode configured by Lanctot. The current integration mode is API key.
| Mode | Header | Value format |
|---|---|---|
| api_key | x-api-key | <shared secret> |
| bearer | Authorization | Bearer <token> |
| basic | Authorization | Basic <base64(user:pass)> |
GET /health
Health and runtime capabilities endpoint.
GET /opal/health
Health endpoint for Opal ingest surface.
GET /morel/health
Health endpoint for the Morel Play ingest surface.
POST /api/pdf
Primary endpoint BC calls to resolve invoice PDF content after user click actions.
Request body
| Field | Required | Type | Notes |
|---|---|---|---|
| account_number | yes | string | Customer account identifier |
| erp_order_number | yes | string | ERP order identifier |
| invoice_number | yes for invoiceExternalUrl | string | Invoice number or BC invoice GUID |
| format | yes | string | Must be pdf |
| link_type | yes | string | invoiceExternalUrl |
Example request
Success response (data mode)
Success response (url mode)
Error response
POST /v1/api/pdf
Versioned alias for /api/pdf. Uses the same request and response contract. Recommended for long-term client integrations.
POST /opal/v1/api/ingest
Stages Opal order header and line payloads in SQL. This endpoint stores payloads only and does not call Business Central.
POST /morel/v1/api/orders
Stages a Morel Play order document in the SQL staging table; the puller then posts it to Business Central staging as an Order. Alias: /morel/api/orders. See the Morel Play Ingest Contract for the payload and posting rules.
POST /morel/v1/api/returns
Stages a Morel Play returns document in the SQL staging table; the puller then posts it to Business Central staging as a Return Order. Alias: /morel/api/returns. Returns are sent separately from orders.
GET /pdf/{token}
Download endpoint used when response mode is url. Tokens expire according to PDF_URL_TTL_SECONDS.
Error Codes
Stable error codes for client handling. Human-readable messages may vary slightly; code semantics are stable.
| Code | HTTP | Typical Trigger | Example Message |
|---|---|---|---|
| BAD_REQUEST | 400 | Invalid payload, missing required fields, unsupported link type | invoice_number is required for invoiceExternalUrl |
| UNAUTHORIZED | 401 | Missing or invalid inbound credentials | Unauthorized: missing x-api-key header |
| INVOICE_NOT_FOUND | 404 | Invoice does not exist or has no PDF in BC routes | Invoice not found in Business Central |
| PDF_NOT_FOUND | 404 | Tokenized PDF download URL expired or missing | PDF not found or expired |
| BC_TIMEOUT | 504 | Business Central request timeout | Business Central request timed out |
| BC_HTTP_ERROR | 502 | Business Central returned non-success HTTP response | Business Central request failed (HTTP 400) |
| BC_REQUEST_FAILED | 502 | Business Central rejected the Morel staging post | Business Central request failed with status 400 |
| BC_DATA_ERROR | 502 | Unexpected BC payload shape | Business Central invoice record did not include id |
| INTERNAL_ERROR | 500 | Unexpected server configuration/runtime error | Internal server error |
| TOO_MANY_REQUESTS | 429 | Per-client request rate exceeded in 1-minute window | Rate limit exceeded: too many requests. Please retry in 1 minute. |
Invoice Test Console
Use this console to simulate invoice PDF backend requests from the browser.
Opal Test Console
Use this console to simulate Opal order ingest calls.
Morel Play Test Console
Use this console to simulate Morel Play order and return calls. A test document is staged in SQL and then posted to Business Central by the puller, so use a test client or a document you are ready to stage.