API Documentation
This document describes the REST API query objects exposed by the Texas Star Nuts extension for external system integration.
Overview
The extension includes 54 API query objects that expose Business Central data via OData REST APIs. These APIs enable:
- Third-party system integration
- Custom reporting tools
- Mobile applications
- Data warehouse/BI tools
- External dashboards
All APIs follow OData v4 protocol and support standard operations:
- GET - Retrieve data
- $filter - Filter results
- $select - Choose specific fields
- $expand - Include related data
- $top - Limit result count
- $skip - Pagination
API Categories
1. Master Data APIs
- Items
- Customers
- Vendors
- Locations
- Bins
2. Transaction APIs
- Sales Orders & Lines
- Purchase Orders & Lines
- Transfer Orders
- Warehouse Documents
3. Inventory APIs
- Bin Content
- Item Ledger Entries
- Warehouse Entries
- Lot Information
4. Production APIs
- Production Orders
- BOMs (Bill of Materials)
- Routings
- Work Centers
5. Ledger APIs
- Item Ledger Entries
- General Ledger Entries
- Capacity Ledger Entries
Master Data APIs
TSN API Items (Query 50000)
Endpoint: /api/v1/tsnApiItems
Purpose: Retrieve item master data with Texas Star custom fields
Key Fields:
- No: Item number
- Description
- Base_Unit_of_Measure
- Unit_Cost
- Unit_Price
- Inventory: On-hand quantity
- TSN_Global_Group_1 through TSN_Global_Group_5
- TSN_Brand_Code
- Country_of_Origin_Code
- Net_Weight
- Cubage
Use Cases:
- Item catalog synchronization
- Pricing updates to eCommerce
- Inventory status for external systems
- Product information for mobile apps
Example Request:
GET /api/v1/tsnApiItems?$filter=TSN_Brand_Code eq 'PRIVATE'&$select=No,Description,Unit_Price
Code Reference: TSNAPIItems.Query.al
TSN API Customers (Query 50001)
Endpoint: /api/v1/tsnApiCustomers
Purpose: Retrieve customer master data
Key Fields:
- No: Customer number
- Name
- Address, City, State, Post_Code
- Phone_No, Email
- Credit_Limit
- Balance
- Shipping_Instructions_1, Shipping_Instructions_2
- Pallet_Code
- Shelf_Life_Requirement (custom field)
Use Cases:
- Customer portal integration
- Shipping requirement synchronization
- Credit limit monitoring
- CRM integration
Example Request:
GET /api/v1/tsnApiCustomers?$filter=Balance gt 0
Code Reference: TSNAPICustomers.Query.al
TSN API Vendors (Query 50002)
Endpoint: /api/v1/tsnApiVendors
Purpose: Retrieve vendor/supplier master data
Key Fields:
- No: Vendor number
- Name
- Address, City, State, Post_Code
- Phone_No, Email
- Balance
- Special_Instructions
- Shipping_Instructions
Use Cases:
- Procurement system integration
- Vendor portal
- Payment processing systems
- Supplier performance tracking
Code Reference: TSNAPIVendors.Query.al
TSN API Locations (Query 50003)
Endpoint: /api/v1/tsnApiLocations
Purpose: Retrieve warehouse location data
Key Fields:
- Code: Location code
- Name
- Address, City, State, Post_Code
- Use_As_In_Transit
- Require_Pick, Require_Put_Away, Require_Receive, Require_Shipment
Use Cases:
- Warehouse management system integration
- Multi-location inventory visibility
- Shipping system integration
Code Reference: TSNAPILocations.Query.al
TSN API Bins (Query 50004)
Endpoint: /api/v1/tsnApiBins
Purpose: Retrieve bin/location detail data
Key Fields:
- Location_Code
- Code: Bin code
- Zone_Code
- Bin_Type_Code
- Warehouse_Class_Code
- Block_Movement
- TSN_Exclude_from_Planning (custom field)
Use Cases:
- Warehouse Insight integration
- Bin-level inventory tracking
- Pick path optimization
- Warehouse layout management
Code Reference: TSNAPIBins.Query.al
Transaction APIs
Endpoint: /api/v1/tsnApiSalesHeaders
Purpose: Retrieve sales order headers
Key Fields:
- Document_Type
- No: Order number
- Sell_to_Customer_No
- Sell_to_Customer_Name
- Order_Date
- Shipment_Date
- Status
- Amount_Including_VAT
- Shipping_Instructions_1, Shipping_Instructions_2
- Pallet_Code
- TRC_ASN_Type (custom field)
Use Cases:
- Order management system integration
- Customer portal order status
- Shipping system integration
- Order analytics
Example Request:
GET /api/v1/tsnApiSalesHeaders?$filter=Status eq 'Released' and Shipment_Date eq 2026-01-13
Code Reference: TSNAPISalesHeaders.Query.al
TSN API Sales Lines (Query 50011)
Endpoint: /api/v1/tsnApiSalesLines
Purpose: Retrieve sales order line details
Key Fields:
- Document_Type
- Document_No
- Line_No
- Type (Item, G/L Account, etc.)
- No: Item number
- Description
- Quantity
- Unit_Price
- Amount
- Location_Code
- Shipment_Date
- Outstanding_Quantity
Use Cases:
- Order detail retrieval
- Line-item integration with WMS
- Picking system integration
- Order fulfillment tracking
Example Request:
GET /api/v1/tsnApiSalesLines?$filter=Document_No eq 'SO-12345'&$expand=Item
Code Reference: TSNAPISalesLines.Query.al
Endpoint: /api/v1/tsnApiPurchaseHeaders
Purpose: Retrieve purchase order headers
Key Fields:
- Document_Type
- No: PO number
- Buy_from_Vendor_No
- Buy_from_Vendor_Name
- Order_Date
- Expected_Receipt_Date
- Status
- Amount_Including_VAT
- Special_Instructions
Use Cases:
- Procurement system integration
- Vendor portal integration
- Receipt planning
- AP (Accounts Payable) integration
Code Reference: TSNAPIPurchaseHeaders.Query.al
TSN API Purchase Lines (Query 50013)
Endpoint: /api/v1/tsnApiPurchaseLines
Purpose: Retrieve purchase order line details
Key Fields:
- Document_Type
- Document_No
- Line_No
- Type
- No: Item number
- Description
- Quantity
- Unit_Cost
- Amount
- Location_Code
- Expected_Receipt_Date
- Outstanding_Quantity
- Alternate_Lot_No (custom)
- Country_of_Origin (custom)
Use Cases:
- Receiving system integration
- PO detail for warehouse
- ASN (Advanced Shipping Notice) matching
- Inventory planning
Code Reference: TSNAPIPurchaseLines.Query.al
TSN API Transfer Orders (Query 50014)
Endpoint: /api/v1/tsnApiTransferOrders
Purpose: Retrieve inter-location transfer orders
Key Fields:
- No: Transfer order number
- Transfer_from_Code
- Transfer_to_Code
- Shipment_Date
- Receipt_Date
- Status
Use Cases:
- Multi-location inventory transfer tracking
- Inter-warehouse shipment coordination
- Inventory rebalancing systems
Code Reference: TSNAPITransferOrders.Query.al
Warehouse APIs
Endpoint: /api/v1/tsnApiWarehouseShipmentHeaders
Purpose: Retrieve warehouse shipment documents
Key Fields:
- No: Shipment number
- Location_Code
- Assigned_User_ID
- Shipment_Date
- Bill_of_Lading_No (custom)
- Seal_No (custom)
- Trailer_Reference (custom)
- Shipping_Agent_Code (custom)
- Manual_Pallets (custom)
Use Cases:
- WMS integration
- Shipping system integration
- BOL tracking
- Carrier integration
Example Request:
GET /api/v1/tsnApiWarehouseShipmentHeaders?$filter=Shipment_Date eq 2026-01-13&$select=No,Bill_of_Lading_No,Seal_No
Code Reference: TSNAPIWarehouseShipmentHeaders.Query.al
TSN API Warehouse Shipment Lines (Query 50021)
Endpoint: /api/v1/tsnApiWarehouseShipmentLines
Purpose: Retrieve warehouse shipment line details
Key Fields:
- No: Shipment number
- Line_No
- Item_No
- Description
- Quantity
- Qty_Outstanding
- Qty_to_Ship
- Location_Code
- Zone_Code
- Bin_Code
- Lot_No
- TRCUDF6 (weight - custom)
- TRCUDF7 (volume - custom)
Use Cases:
- Pick list generation
- Lot tracking integration
- Weight/volume calculation for freight
- Line-item ASN data
Code Reference: TSNAPIWarehouseShipmentLines.Query.al
Endpoint: /api/v1/tsnApiWarehouseReceiptHeaders
Purpose: Retrieve warehouse receipt documents
Key Fields:
- No: Receipt number
- Location_Code
- Assigned_User_ID
- Expected_Receipt_Date
- PO_Number (custom)
- Delivery_Appointment_Date (custom)
- Delivery_Appointment_Time (custom)
Use Cases:
- Receiving system integration
- Dock scheduling
- Appointment management
- ASN matching
Code Reference: TSNAPIWarehouseReceiptHeaders.Query.al
TSN API Warehouse Receipt Lines (Query 50023)
Endpoint: /api/v1/tsnApiWarehouseReceiptLines
Purpose: Retrieve warehouse receipt line details
Key Fields:
- No: Receipt number
- Line_No
- Item_No
- Description
- Quantity
- Qty_Outstanding
- Qty_to_Receive
- Location_Code
- Zone_Code
- Bin_Code
Use Cases:
- Receiving instruction for warehouse
- Put-away list generation
- ASN line matching
Code Reference: TSNAPIWarehouseReceiptLines.Query.al
Inventory APIs
TSN API Bin Content (Query 50030)
Endpoint: /api/v1/tsnApiBinContent
Purpose: Real-time inventory by bin and lot
Key Fields:
- Location_Code
- Zone_Code
- Bin_Code
- Item_No
- Variant_Code
- Lot_No
- Quantity
- Quantity_Base
Use Cases:
- Real-time inventory queries
- Bin-level stock lookup
- WMS synchronization
- Cycle counting
Example Request:
GET /api/v1/tsnApiBinContent?$filter=Location_Code eq 'MAIN' and Item_No eq 'NUT-001'
Code Reference: TSNAPIBinContent.Query.al
TSN API Item Ledger Entries (Query 50031)
Endpoint: /api/v1/tsnApiItemLedgerEntries
Purpose: Item transaction history
Key Fields:
- Entry_No
- Item_No
- Posting_Date
- Entry_Type (Purchase, Sale, Transfer, etc.)
- Location_Code
- Quantity
- Remaining_Quantity
- Lot_No
- Serial_No
- Alternate_Lot_No (custom)
- Country_of_Origin (custom)
- Net_Weight (custom)
Use Cases:
- Transaction history
- Lot traceability
- Inventory reconciliation
- Analytics and reporting
Example Request:
GET /api/v1/tsnApiItemLedgerEntries?$filter=Item_No eq 'NUT-001' and Lot_No eq 'LOT-12345'
Code Reference: TSNAPIItemLedgerEntries.Query.al
TSN API Warehouse Entries (Query 50032)
Endpoint: /api/v1/tsnApiWarehouseEntries
Purpose: Warehouse movement transaction history
Key Fields:
- Entry_No
- Item_No
- Location_Code
- Zone_Code
- Bin_Code
- Quantity
- Lot_No
- Serial_No
- Entry_Type
- Registering_Date
Use Cases:
- Warehouse transaction audit
- Movement tracking
- Bin history
- WMS reconciliation
Code Reference: TSNAPIWarehouseEntries.Query.al
Endpoint: /api/v1/tsnApiLotNoInformation
Purpose: Lot master data with expiration and traceability
Key Fields:
- Item_No
- Variant_Code
- Lot_No
- Description
- Expiration_Date
- Warranty_Date
- Alternate_Lot_No (custom flow field)
- Country_of_Origin (custom flow field)
Use Cases:
- Lot expiration monitoring
- FEFO (First Expiry First Out) systems
- Traceability queries
- Quality management
Example Request:
GET /api/v1/tsnApiLotNoInformation?$filter=Expiration_Date lt 2026-02-01
Code Reference: TSNAPILotNoInformation.Query.al
Production APIs
TSN API Production Orders (Query 50040)
Endpoint: /api/v1/tsnApiProductionOrders
Purpose: Manufacturing order headers
Key Fields:
- Status (Planned, Released, Finished)
- No: Production order number
- Source_Type
- Source_No: Item being produced
- Description
- Quantity
- Finished_Quantity
- Remaining_Quantity
- Due_Date
- Starting_Date_Time
- Ending_Date_Time
- Location_Code
Use Cases:
- MES (Manufacturing Execution System) integration
- Production scheduling systems
- Shop floor tablets/displays
- Production analytics
Code Reference: TSNAPIProductionOrders.Query.al
TSN API Prod Order Components (Query 50041)
Endpoint: /api/v1/tsnApiProdOrderComponents
Purpose: Manufacturing order component/material requirements
Key Fields:
- Status
- Prod_Order_No
- Prod_Order_Line_No
- Line_No
- Item_No
- Description
- Quantity_per
- Expected_Quantity
- Remaining_Quantity
- Flushing_Method
- Location_Code
- Bin_Code
Use Cases:
- Material picking for production
- Component availability checking
- Backflushing integration
- Material consumption tracking
Code Reference: TSNAPIProdOrderComponents.Query.al
TSN API Prod Order Routing Lines (Query 50042)
Endpoint: /api/v1/tsnApiProdOrderRoutingLines
Purpose: Manufacturing routing steps/operations
Key Fields:
- Status
- Prod_Order_No
- Routing_No
- Operation_No
- Type (Work Center, Machine Center)
- No: Work/Machine center code
- Description
- Setup_Time
- Run_Time
- Expected_Capacity_Need
Use Cases:
- Routing sheet generation
- Labor tracking
- Capacity planning
- Shop floor routing displays
Code Reference: TSNAPIProdOrderRoutingLines.Query.al
TSN API BOMs (Query 50043)
Endpoint: /api/v1/tsnApiBOMs
Purpose: Bill of Materials structure
Key Fields:
- Production_BOM_No
- Version_Code
- Line_No
- Type
- No: Component item number
- Description
- Quantity_per
- Unit_of_Measure_Code
- Scrap_Percent
Use Cases:
- BOM synchronization to external systems
- Product configurators
- Engineering change management
- Cost rollup calculations
Code Reference: TSNAPIBOMs.Query.al
TSN API Work Centers (Query 50044)
Endpoint: /api/v1/tsnApiWorkCenters
Purpose: Work center/production resource data
Key Fields:
- No: Work center code
- Name
- Work_Center_Group_Code
- Capacity
- Efficiency
- Unit_Cost
- Direct_Unit_Cost
Use Cases:
- Capacity planning systems
- Shop floor management
- Costing systems
Code Reference: TSNAPIWorkCenters.Query.al
Ledger APIs
TSN API GL Entries (Query 50050)
Endpoint: /api/v1/tsnApiGLEntries
Purpose: General ledger transaction detail
Key Fields:
- Entry_No
- G_L_Account_No
- Posting_Date
- Document_Type
- Document_No
- Description
- Amount
- Debit_Amount
- Credit_Amount
- Source_Code
Use Cases:
- Financial reporting systems
- Data warehouse/BI
- Audit systems
- GL reconciliation
Code Reference: TSNAPIGLEntries.Query.al
TSN API Capacity Ledger Entries (Query 50051)
Endpoint: /api/v1/tsnApiCapacityLedgerEntries
Purpose: Labor/machine time tracking entries
Key Fields:
- Entry_No
- Posting_Date
- Type (Work Center, Machine Center)
- No: Work/Machine center code
- Prod_Order_No
- Operation_No
- Quantity
- Setup_Time
- Run_Time
- Cap_Unit_of_Measure_Code
- TSN_Headcount (custom)
Use Cases:
- Labor reporting
- Production efficiency analysis
- Actual vs. standard time analysis
- Headcount tracking
Code Reference: TSNAPICapacityLedgerEntries.Query.al
Authentication & Security
OAuth 2.0 Authentication
Business Central OData APIs use OAuth 2.0 for authentication:
- Register Application in Azure AD
- Grant Permissions to Business Central APIs
- Obtain Access Token using client credentials or authorization code flow
- Include Token in API requests
Example Authorization Header:
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc...
Permissions
- API access requires Business Central user license
- User must have permissions to underlying BC objects
- APIs respect standard BC security model
- Row-level security applies (company, location, etc.)
API Usage Examples
Example 1: Get Today’s Shipments
Request:
GET /api/v1/tsnApiWarehouseShipmentHeaders?$filter=Shipment_Date eq 2026-01-13
Response:
{
"value": [
{
"No": "SHIP-001",
"Location_Code": "MAIN",
"Shipment_Date": "2026-01-13",
"Bill_of_Lading_No": "BOL-12345",
"Seal_No": "SEAL-9876",
"Trailer_Reference": "TRLR-5555",
"Manual_Pallets": 5
}
]
}
Example 2: Get Item Inventory by Location
Request:
GET /api/v1/tsnApiBinContent?$filter=Item_No eq 'NUT-ALMOND-1000' and Quantity gt 0&$select=Location_Code,Bin_Code,Lot_No,Quantity
Response:
{
"value": [
{
"Location_Code": "MAIN",
"Bin_Code": "A-01-01",
"Lot_No": "PO-12345-10",
"Quantity": 100
},
{
"Location_Code": "MAIN",
"Bin_Code": "A-01-02",
"Lot_No": "PO-12345-20",
"Quantity": 150
}
]
}
Example 3: Get Lots Expiring Soon
Request:
GET /api/v1/tsnApiLotNoInformation?$filter=Expiration_Date le 2026-02-01 and Expiration_Date gt 2026-01-13&$orderby=Expiration_Date asc
Response:
{
"value": [
{
"Item_No": "NUT-CASHEW-500",
"Lot_No": "PO-11111-10",
"Expiration_Date": "2026-01-20",
"Alternate_Lot_No": "VENDOR-LOT-ABC",
"Country_of_Origin": "VN"
}
]
}
Example 4: Get Open Sales Orders by Customer
Request:
GET /api/v1/tsnApiSalesHeaders?$filter=Sell_to_Customer_No eq 'CUST-001' and Status eq 'Released'&$expand=Lines
Response:
{
"value": [
{
"No": "SO-12345",
"Sell_to_Customer_No": "CUST-001",
"Sell_to_Customer_Name": "ABC Grocery",
"Order_Date": "2026-01-10",
"Shipment_Date": "2026-01-15",
"Status": "Released",
"Amount_Including_VAT": 5250.00,
"Lines": [
{
"Line_No": 10000,
"Item_No": "NUT-ALMOND-1000",
"Description": "Almonds 1000g",
"Quantity": 50,
"Unit_Price": 10.00,
"Amount": 500.00
}
]
}
]
}
Best Practices
- Use Filters: Always filter data to reduce payload size
?$filter=Posting_Date ge 2026-01-01
- Select Specific Fields: Only retrieve fields you need
?$select=No,Description,Quantity
- Pagination: Use $top and $skip for large datasets
- Indexing: Filters on indexed fields perform better
- Primary keys (No, Entry_No, etc.)
- Posting dates
- Status fields
- Caching: Cache master data (items, customers) locally
- Reduces API calls
- Improves response time
- Use webhooks for change notifications (if available)
Rate Limiting
- Business Central enforces API rate limits
- Varies by license type and tenant
- Implement exponential backoff for retries
- Monitor 429 (Too Many Requests) responses
Error Handling
Common HTTP Status Codes
| Code |
Meaning |
Action |
| 200 |
Success |
Process response |
| 400 |
Bad Request |
Check query syntax |
| 401 |
Unauthorized |
Refresh access token |
| 403 |
Forbidden |
Check permissions |
| 404 |
Not Found |
Verify endpoint URL |
| 429 |
Too Many Requests |
Implement retry with backoff |
| 500 |
Server Error |
Log and retry |
Error Response Example
{
"error": {
"code": "BadRequest",
"message": "The query parameter $filter has an invalid value."
}
}
Integration Scenarios
Scenario 1: eCommerce Inventory Sync
Flow:
- eCommerce system queries available inventory every 15 minutes
- GET
/api/v1/tsnApiBinContent?$filter=Quantity gt 0
- Calculate ATP (Available to Promise) by item
- Update eCommerce inventory levels
Benefits:
- Real-time inventory visibility on website
- Prevent overselling
- Accurate product availability
Scenario 2: WMS Integration
Flow:
- WMS queries warehouse shipments due today
- GET
/api/v1/tsnApiWarehouseShipmentHeaders?$filter=Shipment_Date eq {today}
- For each shipment, get lines with lots
- Generate pick lists in WMS
- Update pick status back to BC (via BC standard APIs)
Benefits:
- Seamless WMS integration
- Lot-level picking
- Real-time status updates
Scenario 3: BI/Analytics Dashboard
Flow:
- Nightly ETL job extracts data
- GET item ledger entries for date range
- GET sales orders and lines
- GET production orders
- Load into data warehouse
- Build dashboards/reports
Benefits:
- Comprehensive analytics
- Historical trending
- Custom KPIs
Scenario 4: Mobile Receiving App
Flow:
- Warehouse receiver scans PO barcode
- App queries: GET
/api/v1/tsnApiPurchaseLines?$filter=Document_No eq {PO}
- Display expected items
- Receiver confirms quantities, enters lot/expiration
- App posts receipt via BC standard API
Benefits:
- Mobile receiving
- Barcode scanning
- Real-time PO matching
Summary
The API layer provides:
- Comprehensive Access: 54 query objects covering all major data areas
- Standard Protocol: OData v4 with full filtering, selection, expansion
- Real-Time Data: Direct queries to live BC database
- Secure: OAuth 2.0 with BC permission enforcement
- Integration Ready: Enables WMS, eCommerce, BI, mobile apps
- Custom Fields: Exposes TSN custom fields for specialized data
Key API Groups
- Master Data: Items, Customers, Vendors, Locations, Bins
- Transactions: Sales, Purchase, Transfer, Warehouse documents
- Inventory: Bin content, ledger entries, lot information
- Production: Orders, components, routings, BOMs
- Ledgers: GL, item, capacity entries
See Also: