π― Overview
Sterling Order Management System (OMS) provides powerful REST APIs that enable seamless integration with external systems, e-commerce platforms, and mobile applications. This comprehensive guide covers everything you need to know about developing robust REST APIs for Sterling OMS, including authentication, order management, inventory operations, and real-world examples.
π Secure Authentication
JWT tokens, OAuth 2.0, and API key management for secure access control.
π¦ Order Management
Create, update, track, and manage orders through comprehensive REST endpoints.
π Inventory Operations
Real-time inventory checks, updates, and availability management.
⚡ Performance Optimized
Caching strategies, pagination, and efficient data retrieval patterns.
π Authentication & Authorization
Description: Authenticate user and obtain JWT token for API access.
{
"loginId": "api_user",
"password": "secure_password",
"organizationCode": "DEFAULT"
}
✅ Success Response (200 OK):
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"tokenType": "Bearer",
"organizationCode": "DEFAULT"
}
π‘
Authentication Headers
Include the JWT token in all subsequent API calls:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
Accept: application/json
π¦ Order Management APIs
Description: Create a new order in Sterling OMS.
{
"Order": {
"CustomerEmailID": "customer@example.com",
"CustomerFirstName": "John",
"CustomerLastName": "Doe",
"CustomerPhoneNo": "+91-9876543210",
"EnterpriseCode": "DEFAULT",
"DocumentType": "0001",
"OrderDate": "2025-06-12T10:30:00.000Z",
"OrderLines": {
"OrderLine": [
{
"ItemID": "LAPTOP001",
"Quantity": 1,
"UnitPrice": 75000.00,
"PrimeLineNo": 1
}
]
},
"PersonInfoBillTo": {
"FirstName": "John",
"LastName": "Doe",
"AddressLine1": "123 Tech Street",
"City": "Bangalore",
"State": "Karnataka",
"ZipCode": "560001",
"Country": "IN"
}
}
}
✅ Success Response (201 Created):
{
"Order": {
"OrderNo": "ORD2025061200001",
"OrderHeaderKey": "20250612123456789",
"Status": "Created",
"TotalAmount": 75000.00,
"OrderDate": "2025-06-12T10:30:00.000Z"
}
}
Description: Retrieve order details by order number.
GET /yfs/resources/v1/orders/ORD2025061200001
Authorization: Bearer {jwt_token}
✅ Success Response (200 OK):
{
"Order": {
"OrderNo": "ORD2025061200001",
"Status": "In Progress",
"OrderDate": "2025-06-12T10:30:00.000Z",
"CustomerName": "John Doe",
"TotalAmount": 75000.00,
"OrderLines": {
"OrderLine": [
{
"ItemID": "LAPTOP001",
"ItemDesc": "Premium Laptop",
"Quantity": 1,
"Status": "Scheduled"
}
]
}
}
}
Description: Update order status or cancel order.
{
"Order": {
"Action": "CANCEL",
"ReasonCode": "CUST_REQ",
"ReasonText": "Customer requested cancellation"
}
}
π Inventory Management APIs
Description: Check real-time inventory availability for items.
GET /yfs/resources/v1/inventory/availability?ItemID=LAPTOP001&ShipNode=WAREHOUSE_BNG&UnitOfMeasure=EACH
✅ Success Response (200 OK):
{
"InventoryAvailability": {
"ItemID": "LAPTOP001",
"ShipNode": "WAREHOUSE_BNG",
"AvailableQuantity": 25,
"OnHandQuantity": 30,
"ReservedQuantity": 5,
"LastUpdated": "2025-06-12T15:30:00.000Z"
}
}
Description: Adjust inventory quantities for stock updates.
{
"InventoryAdjustment": {
"ItemID": "LAPTOP001",
"ShipNode": "WAREHOUSE_BNG",
"AdjustmentType": "INCREASE",
"Quantity": 10,
"ReasonCode": "STOCK_RECEIPT",
"ReasonText": "New stock received from supplier"
}
}
π ️ Real-World Integration Examples
π
E-commerce Platform Integration
Example integration flow for connecting an e-commerce website with Sterling OMS:
// Sterling OMS API Client
class SterlingOMSClient {
constructor(baseUrl, credentials) {
this.baseUrl = baseUrl;
this.credentials = credentials;
this.token = null;
}
async authenticate() {
const response = await fetch(`${this.baseUrl}/yfs/resources/v1/authenticate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(this.credentials)
});
const data = await response.json();
this.token = data.token;
return this.token;
}
async createOrder(orderData) {
if (!this.token) await this.authenticate();
const response = await fetch(`${this.baseUrl}/yfs/resources/v1/orders`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(orderData)
});
return await response.json();
}
async checkInventory(itemId, shipNode) {
if (!this.token) await this.authenticate();
const response = await fetch(
`${this.baseUrl}/yfs/resources/v1/inventory/availability?ItemID=${itemId}&ShipNode=${shipNode}`,
{
headers: { 'Authorization': `Bearer ${this.token}` }
}
);
return await response.json();
}
}
// Usage Example
const omsClient = new SterlingOMSClient('https://your-oms-server.com', {
loginId: 'api_user',
password: 'secure_password',
organizationCode: 'DEFAULT'
});
// Check inventory before order creation
const inventory = await omsClient.checkInventory('LAPTOP001', 'WAREHOUSE_BNG');
if (inventory.InventoryAvailability.AvailableQuantity > 0) {
const order = await omsClient.createOrder(orderPayload);
console.log('Order created:', order.Order.OrderNo);
}
π±
Mobile App Integration
Python example for mobile backend integration:
import requests
from flask import Flask, request, jsonify
app = Flask(__name__)
class SterlingOMSService:
def __init__(self, base_url, credentials):
self.base_url = base_url
self.credentials = credentials
self.token = None
def get_headers(self):
if not self.token:
self.authenticate()
return {
'Authorization': f'Bearer {self.token}',
'Content-Type': 'application/json'
}
def authenticate(self):
response = requests.post(
f'{self.base_url}/yfs/resources/v
No comments:
Post a Comment