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

  1. Set the Base URL to the endpoint provided by Lanctot.
  2. Use the correct x-api-key for each surface (Invoice, Opal and Morel keys can differ).
  3. Call GET /health, GET /opal/health and GET /morel/health to verify all surfaces are available.

BC Invoice Flow

  1. Send POST /api/pdf (or POST /v1/api/pdf) with invoice identifiers.
  2. If response mode is data, decode base64 using Decode Base64 To PDF.
  3. If response mode is url, open the returned PDF URL before token expiry.

Opal Ingest Flow

  1. Send POST /opal/v1/api/ingest with header + line payload.
  2. Confirm success response includes header_id, line_ids, and line_count.
  3. If external_document_no already exists, expect HTTP 409 and code DUPLICATE_EXTERNAL_DOCUMENT_NO.

Morel Play Ingest Flow

  1. Send POST /morel/v1/api/orders with the Morel order document.
  2. Send returns separately with POST /morel/v1/api/returns using the returns document.
  3. Confirm the response status is staged (HTTP 202), or a skipped status with the reason. The puller then posts the staged row to BC.
Recommendation: Use versioned paths for long-term clients: /v1/api/pdf, /opal/v1/api/ingest and /morel/v1/api/orders.

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

{ "account_number": "C004380", "erp_order_number": "SO015557", "invoice_number": "PSINV000831", "format": "pdf", "link_type": "invoiceExternalUrl" }

5) Response Contract

Current mode: data (base64 PDF)

{ "success": true, "data": "JVBERi0xLjc...", "encoding": "base64" }

6) Error Contract

{ "errors": [ { "message": "Human readable message", "code": "ERROR_CODE" } ] }

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

{ "due_date": "2026-09-30", "customer_no": "C006374", "external_document_no": "OPAL-100012-Test1", "picking_notes": "Leave at dock 2", "shipping_agent_code": "UPS", "order_type": "15WARRANTY", "order_origin_code": "500OPAD", "package_tracking_no": "1Z999AA10123456784", "lines": [ { "line_no": 10000, "item_reference": "AMSGP2PRCM", "quantity": 2, "line_comment": "Priority", "unit_price": 12.5, "line_discount_pct": 0 } ] }

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

{ "success": true, "header_id": 1234, "line_ids": [5678], "line_count": 1 }

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

{ "id": "8100001867", "client": { "id": "C002336" }, "shippingAddress": { "name": "Oakley Optical Eyecare Centre Kenaston", "street1": "1570 Kenaston Blvd Unit 130", "city": "Winnipeg", "zipCode": "R3P 0Y4", "country": "CANADA", "countryCode": "CA" }, "createdDate": "2026-11-03T09:14:53-06:00", "deliveryDate": "2026-09-01", "properties": { "type": "20BOOKING", "billingTerm": "N30" }, "qtyTotal": 35, "qtyReturnTotal": -7, "returnId": "8100001868", "lines": [ { "sku": "MOCASE-01_OS", "quantity": 15, "unitPrice": 0, "discountPercent": 0 }, { "sku": "MORHORTEN2-NO05_52-18-145", "quantity": 1, "unitPrice": 0, "discountPercent": 0 } ] }

4) Returns Request Contract

Returns are sent separately to the returns endpoint, using the returns document. The return reference is the document returnId.

{ "id": "8100001905", "returnId": "8100001906", "client": { "id": "C001770" }, "createdDate": "2026-11-06T16:46:57-05:00", "properties": { "type": "10REPEAT", "billingTerm": "N30" }, "qtyTotal": 7, "qtyReturnTotal": -1, "lines": [ { "sku": "OG10198O-BM01_51-21-145", "quantity": 1, "unitPrice": 59.1, "discountPercent": 0 } ] }

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:

{ "success": true, "posted": false, "status": "staged", "staging_id": 123, "document_type": "Order", "reference_no": "8100001867", "line_count": 21 }

Skipped documents are also staged, with their skip status, and return HTTP 200:

{ "success": true, "posted": false, "status": "skipped_non_bc_client", "staging_id": 124, "document_type": "Order", "reference_no": "8100001867", "line_count": 21 }

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

GET/health

Health and runtime capabilities endpoint.

{ "status": "ok", "supported_link_types": ["invoiceExternalUrl"], "response_mode": "data", "timestamp": 1718550000 }

GET /opal/health

GET/opal/health

Health endpoint for Opal ingest surface.

{ "status": "ok", "service": "opal_ingest", "auth_mode": "api_key", "rate_limit_per_minute": 600 }

GET /morel/health

GET/morel/health

Health endpoint for the Morel Play ingest surface.

{ "status": "ok", "service": "morel_play_ingest", "auth_mode": "api_key", "rate_limit_per_minute": 600 }

POST /api/pdf

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

{ "account_number": "C004380", "erp_order_number": "SO015557", "invoice_number": "PSINV000831", "format": "pdf", "link_type": "invoiceExternalUrl" }

Success response (data mode)

{ "success": true, "data": "JVBERi0xLjc...", "encoding": "base64" }

Success response (url mode)

{ "success": true, "url": "https://api.rlanctot.com/pdf/abc123" }

Error response

{ "errors": [ { "message": "Human readable message", "code": "ERROR_CODE" } ] }

POST /v1/api/pdf

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

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

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

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}

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.

Response will appear here.
cURL preview will appear here.

Opal Test Console

Use this console to simulate Opal order ingest calls.

Opal response will appear here.
Opal cURL preview will appear here.

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.

Morel response will appear here.
Morel cURL preview will appear here.