Shiplee API Documentation

Welcome to the Shiplee API, a robust platform for integrating logistics and order management. This API enables sellers to authenticate securely, create orders with flexible billing options, manage warehouses, and handle shipments efficiently.

Base URL: https://apiv1.shiplee.app

Key Features:

Authentication

The Shiplee API uses JSON Web Tokens (JWT) for secure authentication. Follow these steps to access protected endpoints:

  1. Obtain API Credentials:
  2. Whitelist IP and Domain:
    • Add your server’s IP (e.g., 106.51.205.161) and domain (e.g., localhost) in the API Settings.
  3. Authenticate:
    • Send a POST request to /login with username (email or shiplee_id) and apikey.
    • Receive a JWT token valid for 1 hour.
  4. Use JWT Token:
    • Include the token in the Authorization: Bearer header for subsequent requests.
Ensure your IP and domain are whitelisted to avoid 403 Forbidden errors.

Login Endpoint

POST /login

Authenticates a user and returns a JWT token for accessing protected endpoints.

Request

Headers:

  • Content-Type: application/json
  • Origin: (optional, must be whitelisted, e.g., localhost)
  • X-Forwarded-For: (optional, must be whitelisted, e.g., 106.51.205.161)

Body:


{
    "username": "demo@shiplee.in",
    "apikey": "your-api-key"
}
                    

Examples


curl -X POST https://apiv1.shiplee.app/login \
-H "Content-Type: application/json" \
-H "Origin: http://localhost" \
-H "X-Forwarded-For: 106.51.205.161" \
-d '{"username": "demo@shiplee.in", "apikey": "your-api-key"}'
                            

$body = @{
    username = "demo@shiplee.in"
    apikey = "your-api-key"
} | ConvertTo-Json
$headers = @{
    "Content-Type" = "application/json"
    "Origin" = "http://localhost"
    "X-Forwarded-For" = "106.51.205.161"
}
$response = Invoke-RestMethod -Uri "https://apiv1.shiplee.app/login" -Method Post -Body $body -Headers $headers
Write-Host "Token: $($response.token)"
                            

Token:                             

import requests

url = 'https://apiv1.shiplee.app/login'
headers = {
    'Content-Type': 'application/json',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
}
data = {
    'username': 'demo@shiplee.in',
    'apikey': 'your-api-key'
}
response = requests.post(url, json=data, headers=headers)
print('Token:', response.json()['token'])
                            

const axios = require('axios');

const url = 'https://apiv1.shiplee.app/login';
const headers = {
    'Content-Type': 'application/json',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
};
const data = {
    username: 'demo@shiplee.in',
    apikey: 'your-api-key'
};

axios.post(url, data, { headers })
    .then(response => console.log('Token:', response.data.token))
    .catch(error => console.error('Error:', error.response.data));
                            

Response

Success (200):


{
    "token": "eyJ...",
    "user": {
        "id": 62,
        "email": "demo@shiplee.in",
        "shiplee_id": "d10701280b9798033c6917e9415b03c3"
    }
}
                    

Error Responses:

  • 400 Bad Request: {"error": "Invalid or missing username/apikey"}
  • 401 Unauthorized: {"error": "Invalid credentials or user not active"}
  • 403 Forbidden: {"error": "The IP 'x.x.x.x' is not whitelisted"} or {"error": "The domain 'example.com' is not whitelisted"}
  • 429 Too Many Requests: {"error": "Too many login attempts"}
  • 500 Server Error: {"error": "Server error: "}

Add Order Endpoint

POST /order

Creates a new order with customer, billing, product, and parcel details, supporting same or different billing and shipping addresses.

Request

Headers:

  • Content-Type: application/json
  • Authorization: Bearer (JWT from /login)
  • Origin: (optional, must be whitelisted, e.g., localhost)
  • X-Forwarded-For: (optional, must be whitelisted, e.g., 106.51.205.161)

Body (Same Billing and Shipping Address):


{
    "pincode": "560098",
    "city": "Bangalore",
    "state": "Karnataka",
    "name": "John Doe",
    "companyName": "Sample Inc",
    "email": "demo@shiplee.in",
    "mobileNumber": "9000000001",
    "altMobileNumber": "9000000002",
    "addressLine1": "123 Sample Street, Apt 4B",
    "addressLine2": "Near Sample Park",
    "sameAddressCheckbox": 1,
    "orderID": "ORD126",
    "suborderID": "SUB126",
    "pickupType": "express",
    "shipmentType": "forward",
    "paymentType": "prepaid",
    "resellerName": "Sample Reseller",
    "gstinNumber": "27AABCU9603R1ZM",
    "products": [
        {
            "productName": "Sample Product",
            "quantity": 2,
            "productPrice": 50.00,
            "sku": "SKU123"
        }
    ],
    "parcels": [
        {
            "length": 10,
            "breadth": 10,
            "height": 10,
            "physicalWeight": 1.5
        }
    ]
}
                    

Body (Different Billing Address):


{
    "pincode": "560098",
    "city": "Bangalore",
    "state": "Karnataka",
    "name": "John Doe",
    "companyName": "Sample Inc",
    "email": "demo@shiplee.in",
    "mobileNumber": "9000000001",
    "altMobileNumber": "9000000002",
    "addressLine1": "123 Sample Street, Apt 4B",
    "addressLine2": "Near Sample Park",
    "sameAddressCheckbox": 0,
    "billingPincode": "400001",
    "billingCity": "Mumbai",
    "billingState": "Maharashtra",
    "billingName": "Jane Smith",
    "billingCompanyName": "Billing Corp",
    "billingEmail": "billing@shiplee.in",
    "billingMobileNumber": "9000000003",
    "billingAltMobileNumber": "9000000004",
    "billingAddressLine1": "456 Billing Avenue, Suite 5C",
    "billingAddressLine2": "Near Billing Plaza",
    "orderID": "ORD127",
    "suborderID": "SUB127",
    "pickupType": "express",
    "shipmentType": "forward",
    "paymentType": "prepaid",
    "resellerName": "Sample Reseller",
    "gstinNumber": "27AABCU9603R1ZM",
    "products": [
        {
            "productName": "Sample Product",
            "quantity": 2,
            "productPrice": 50.00,
            "sku": "SKU124"
        }
    ],
    "parcels": [
        {
            "length": 10,
            "breadth": 10,
            "height": 10,
            "physicalWeight": 1.5
        }
    ]
}
                    

Notes:

  • pincode, billingPincode: Must be a 6-digit number (e.g., 560098).
  • mobileNumber, billingMobileNumber: Must be a 10-digit Indian number (e.g., 9000000001).
  • addressLine1, addressLine2, billingAddressLine1, billingAddressLine2: Maximum 40 words.
  • paymentType: Accepts cod, prepaid, or paid. Stored as cod or prd.
  • parcels: Volumetric weight is calculated internally as (length * breadth * height) / 5000.
  • sameAddressCheckbox: Set to 0 to specify different billing address details; required fields include billingPincode, billingCity, etc.
  • pickupType: Accepts express or standard, but is overridden based on shipmentType. For shipmentType: forward or express, stored as fwd (forward shipment). For shipmentType: reverse, stored as rvs (reverse shipment).
  • shipmentType: Optional, defaults to forward. Must be forward, express, or reverse.

Examples


curl -X POST https://apiv1.shiplee.app/order \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ..." \
-H "Origin: http://localhost" \
-H "X-Forwarded-For: 106.51.205.161" \
-d '{
    "pincode": "560098",
    "city": "Bangalore",
    "state": "Karnataka",
    "name": "John Doe",
    "email": "demo@shiplee.in",
    "mobileNumber": "9000000001",
    "addressLine1": "123 Sample Street, Apt 4B",
    "orderID": "ORD126",
    "pickupType": "express",
    "shipmentType": "forward",
    "paymentType": "prepaid",
    "products": [
        {
            "productName": "Sample Product",
            "quantity": 2,
            "productPrice": 50.00,
            "sku": "SKU123"
        }
    ],
    "parcels": [
        {
            "length": 10,
            "breadth": 10,
            "height": 10,
            "physicalWeight": 1.5
        }
    ],
    "sameAddressCheckbox": 1
}'
                            

$token = "eyJ..."
$body = @{
    pincode = "560098"
    city = "Bangalore"
    state = "Karnataka"
    name = "John Doe"
    email = "demo@shiplee.in"
    mobileNumber = "9000000001"
    addressLine1 = "123 Sample Street, Apt 4B"
    orderID = "ORD126"
    pickupType = "express"
    shipmentType = "forward"
    paymentType = "prepaid"
    products = @(
        @{
            productName = "Sample Product"
            quantity = 2
            productPrice = 50.00
            sku = "SKU123"
        }
    )
    parcels = @(
        @{
            length = 10
            breadth = 10
            height = 10
            physicalWeight = 1.5
        }
    )
    sameAddressCheckbox = 1
} | ConvertTo-Json -Depth 10
$headers = @{
    "Content-Type" = "application/json"
    "Authorization" = "Bearer $token"
    "Origin" = "http://localhost"
    "X-Forwarded-For" = "106.51.205.161"
}
$response = Invoke-RestMethod -Uri "https://apiv1.shiplee.app/order" -Method Post -Body $body -Headers $headers
Write-Host "Order ID: $($response.order_id)"
                            

Order ID:                             

import requests

url = 'https://apiv1.shiplee.app/order'
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
}
data = {
    'pincode': '560098',
    'city': 'Bangalore',
    'state': 'Karnataka',
    'name': 'John Doe',
    'email': 'demo@shiplee.in',
    'mobileNumber': '9000000001',
    'addressLine1': '123 Sample Street, Apt 4B',
    'orderID': 'ORD126',
    'pickupType': 'express',
    'shipmentType': 'forward',
    'paymentType': 'prepaid',
    'products': [
        {
            'productName': 'Sample Product',
            'quantity': 2,
            'productPrice': 50.00,
            'sku': 'SKU123'
        }
    ],
    'parcels': [
        {
            'length': 10,
            'breadth': 10,
            'height': 10,
            'physicalWeight': 1.5
        }
    ],
    'sameAddressCheckbox': 1
}
response = requests.post(url, json=data, headers=headers)
print('Order ID:', response.json()['order_id'])
                            

const axios = require('axios');

const url = 'https://apiv1.shiplee.app/order';
const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
};
const data = {
    pincode: '560098',
    city: 'Bangalore',
    state: 'Karnataka',
    name: 'John Doe',
    email: 'demo@shiplee.in',
    mobileNumber: '9000000001',
    addressLine1: '123 Sample Street, Apt 4B',
    orderID: 'ORD126',
    pickupType: 'express',
    shipmentType: 'forward',
    paymentType: 'prepaid',
    products: [
        {
            productName: 'Sample Product',
            quantity: 2,
            productPrice: 50.00,
            sku: 'SKU123'
        }
    ],
    parcels: [
        {
            length: 10,
            breadth: 10,
            height: 10,
            physicalWeight: 1.5
        }
    ],
    sameAddressCheckbox: 1
};

axios.post(url, data, { headers })
    .then(response => console.log('Order ID:', response.data.order_id))
    .catch(error => console.error('Error:', error.response.data));
                            

Response

Success (201):


{
    "success": true,
    "message": "Order added successfully",
    "order_id": 484900
}
                    

Error Responses:

  • 400 Bad Request: {"success": false, "message": "Missing required field: "} or {"success": false, "message": "Failed to add order: "}
  • 401 Unauthorized: {"success": false, "message": "Missing or invalid Authorization header"} or {"success": false, "message": "Invalid JWT token"}
  • 403 Forbidden: {"success": false, "message": "The IP 'x.x.x.x' is not whitelisted"} or {"success": false, "message": "The domain 'example.com' is not whitelisted"}
  • 429 Too Many Requests: {"success": false, "message": "Too many order attempts"}
  • 405 Method Not Allowed: {"success": false, "message": "Method not allowed"}

Create Shipment Endpoint

POST /create_shipment

Fetches courier rates or books a shipment for an existing order, supporting multiple couriers (XpressBees, Blue Dart, Delhivery, Amazon, Ekart).

Request

Headers:

  • Content-Type: application/json
  • Authorization: Bearer (JWT from /login)
  • Origin: (optional, must be whitelisted, e.g., localhost)
  • X-Forwarded-For: (optional, must be whitelisted, e.g., 106.51.205.161)

Body (Fetch Rates):


{
    "orderId": 484900,
    "warehouseId": 2147483833,
    "action": "fetch_rates",
    "shipmentType": "forward"
}
                    

Body (Book Shipment):


{
    "orderId": 484900,
    "warehouseId": 2147483833,
    "action": "book_shipment",
    "carrierId": "12298",
    "carrierName": "Xpressbees 1 K.G",
    "shipmentType": "forward"
}
                    

Notes:

  • orderId: Must match an existing order ID from /order (e.g., 484900).
  • warehouseId: Must match a valid warehouse ID from /get_warehouses (e.g., 2147483833).
  • action: Either fetch_rates or book_shipment.
  • carrierId, carrierName: Required for book_shipment, must match a valid courier from fetch_rates (e.g., 12298, Xpressbees 1 K.G).
  • shipmentType: Optional, defaults to forward. Sets pickup_type to fwd for forward or express, and rvs for reverse.
  • Rates include freight and COD charges, adjusted by seller’s plan markup.
  • Booking requires sufficient wallet balance (≥ ₹500).

Examples


curl -X POST https://apiv1.shiplee.app/create_shipment \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ..." \
-H "Origin: http://localhost" \
-H "X-Forwarded-For: 106.51.205.161" \
-d '{
    "orderId": 484900,
    "warehouseId": 2147483833,
    "action": "fetch_rates",
    "shipmentType": "forward"
}'
                            

$token = "eyJ..."
$body = @{
    orderId = 484900
    warehouseId = 2147483833
    action = "fetch_rates"
    shipmentType = "forward"
} | ConvertTo-Json
$headers = @{
    "Content-Type" = "application/json"
    "Authorization" = "Bearer $token"
    "Origin" = "http://localhost"
    "X-Forwarded-For" = "106.51.205.161"
}
$response = Invoke-RestMethod -Uri "https://apiv1.shiplee.app/create_shipment" -Method Post -Body $body -Headers $headers
Write-Host "Rates: $($response.data.carrier_info | ConvertTo-Json -Depth 5)"
                            

null                            

import requests
import json

url = 'https://apiv1.shiplee.app/create_shipment'
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
}
data = {
    'orderId': 484900,
    'warehouseId': 2147483833,
    'action': 'fetch_rates',
    'shipmentType': 'forward'
}
response = requests.post(url, json=data, headers=headers)
print(json.dumps(response.json()['data']['carrier_info'], indent=4))
                            

const axios = require('axios');

const url = 'https://apiv1.shiplee.app/create_sh
ipment';
const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
};
const data = {
    orderId: 484900,
    warehouseId: 2147483833,
    action: 'fetch_rates',
    shipmentType: 'forward'
};

axios.post(url, data, { headers })
    .then(response => console.log(JSON.stringify(response.data.data.carrier_info, null, 4)))
    .catch(error => console.error('Error:', error.response.data));
                            

Response (Fetch Rates)

Success (200):


{
    "success": true,
    "message": "Rates fetched successfully",
    "data": {
        "carrier_info": [
            {
                "carrier_id": "2",
                "carrier_name": "Xpressbees 2 K.G",
                "cost": 138,
                "freight_charges": 138,
                "cod_charges": 0
            },
            {
                "carrier_id": "3",
                "carrier_name": "Xpressbees 5 K.G",
                "cost": 254,
                "freight_charges": 254,
                "cod_charges": 0
            },
            {
                "carrier_id": "4",
                "carrier_name": "Xpressbees 10 K.G",
                "cost": 319,
                "freight_charges": 319,
                "cod_charges": 0
            },
            {
                "carrier_id": "1",
                "carrier_name": "Surface Xpressbees 0.5 K.G",
                "cost": 112,
                "freight_charges": 112,
                "cod_charges": 0
            },
            {
                "carrier_id": "6",
                "carrier_name": "Air Xpressbees 0.5 K.G",
                "cost": 179,
                "freight_charges": 179,
                "cod_charges": 0
            },
            {
                "carrier_id": "12298",
                "carrier_name": "Xpressbees 1 K.G",
                "cost": 138,
                "freight_charges": 138,
                "cod_charges": 0
            },
            {
                "carrier_id": "279",
                "carrier_name": "Bluedart- Surface",
                "cost": 190,
                "freight_charges": 190,
                "cod_charges": 0
            },
            {
                "carrier_id": "282",
                "carrier_name": "Blue Dart- Apex",
                "cost": 285,
                "freight_charges": 285,
                "cod_charges": 0
            },
            {
                "carrier_id": "delhivery_e_prepaid",
                "carrier_name": "Delhivery Express",
                "cost": 269,
                "freight_charges": 269,
                "cod_charges": 0
            },
            {
                "carrier_id": "delhivery_s_prepaid",
                "carrier_name": "Delhivery Surface",
                "cost": 152,
                "freight_charges": 152,
                "cod_charges": 0
            },
            {
                "carrier_id": "amazon_amazon_0.5_kg",
                "carrier_name": "Amazon (AMAZON 0.5 KG)",
                "cost": 168,
                "freight_charges": 168,
                "cod_charges": 0
            },
            {
                "carrier_id": "amazon_amazon_2kg",
                "carrier_name": "Amazon (AMAZON 2KG)",
                "cost": 156,
                "freight_charges": 156,
                "cod_charges": 0
            },
            {
                "carrier_id": "ekart_surface",
                "carrier_name": "Ekart Surface 2 kg",
                "cost": 138,
                "freight_charges": 138,
                "cod_charges": 0
            }
        ]
    }
}
                    

Response (Book Shipment)

Success (201):


{
    "success": true,
    "message": "Shipment booked",
    "awb_number": "1234567890",
    "shipment_id": "SHPL123"
}
                    

Error Responses:

  • 400 Bad Request: {"success": false, "message": "Missing required field: "} or {"success": false, "message": "Failed to process shipment: "}
  • 401 Unauthorized: {"success": false, "message": "Missing or invalid Authorization header"} or {"success": false, "message": "Invalid JWT token"}
  • 403 Forbidden: {"success": false, "message": "The IP 'x.x.x.x' is not whitelisted"} or {"success": false, "message": "The domain 'example.com' is not whitelisted"}
  • 429 Too Many Requests: {"success": false, "message": "Too many shipment attempts"}
  • 405 Method Not Allowed: {"success": false, "message": "Method not allowed"}

Rates Endpoint

POST /rates

Fetches courier rates for an existing order, supporting multiple couriers (XpressBees, Blue Dart, Delhivery, Amazon, Ekart).

Request

Headers:

  • Content-Type: application/json
  • Authorization: Bearer (JWT from /login)
  • Origin: (optional, must be whitelisted, e.g., localhost)
  • X-Forwarded-For: (optional, must be whitelisted, e.g., 106.51.205.161)

Body:


{
    "orderId": 484900,
    "warehouseId": 2147483833,
    "shipmentType": "forward"
}
                    

Notes:

  • orderId: Must match an existing order ID from /order (e.g., 484900).
  • warehouseId: Must match a valid warehouse ID from /get_warehouses (e.g., 2147483833).
  • shipmentType: Optional, defaults to forward. Must be forward, express, or reverse.
  • Use the returned carrier_id and carrier_name for booking a shipment via /create_shipment.

Examples


curl -X POST https://apiv1.shiplee.app/rates \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ..." \
-H "Origin: http://localhost" \
-H "X-Forwarded-For: 106.51.205.161" \
-d '{
    "orderId": 484900,
    "warehouseId": 2147483833,
    "shipmentType": "forward"
}'
                            

$token = "eyJ..."
$body = @{
    orderId = 484900
    warehouseId = 2147483833
    shipmentType = "forward"
} | ConvertTo-Json
$headers = @{
    "Content-Type" = "application/json"
    "Authorization" = "Bearer $token"
    "Origin" = "http://localhost"
    "X-Forwarded-For" = "106.51.205.161"
}
$response = Invoke-RestMethod -Uri "https://apiv1.shiplee.app/rates" -Method Post -Body $body -Headers $headers
Write-Host "Rates: $($response.data.carrier_info | ConvertTo-Json -Depth 5)"
                            

null                            

import requests
import json

url = 'https://apiv1.shiplee.app/rates'
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
}
data = {
    'orderId': 484900,
    'warehouseId': 2147483833,
    'shipmentType': 'forward'
}
response = requests.post(url, json=data, headers=headers)
print(json.dumps(response.json()['data']['carrier_info'], indent=4))
                            

const axios = require('axios');

const url = 'https://apiv1.shiplee.app/rates';
const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
};
const data = {
    orderId: 484900,
    warehouseId: 2147483833,
    shipmentType: 'forward'
};

axios.post(url, data, { headers })
    .then(response => console.log(JSON.stringify(response.data.data.carrier_info, null, 4)))
    .catch(error => console.error('Error:', error.response.data));
                            

Response

Success (200):


{
    "success": true,
    "message": "Rates fetched successfully",
    "data": {
        "carrier_info": [
            {
                "carrier_id": "2",
                "carrier_name": "Xpressbees 2 K.G",
                "cost": 138,
                "freight_charges": 138,
                "cod_charges": 0
            },
            {
                "carrier_id": "3",
                "carrier_name": "Xpressbees 5 K.G",
                "cost": 254,
                "freight_charges": 254,
                "cod_charges": 0
            },
            {
                "carrier_id": "4",
                "carrier_name": "Xpressbees 10 K.G",
                "cost": 319,
                "freight_charges": 319,
                "cod_charges": 0
            },
            {
                "carrier_id": "1",
                "carrier_name": "Surface Xpressbees 0.5 K.G",
                "cost": 112,
                "freight_charges": 112,
                "cod_charges": 0
            },
            {
                "carrier_id": "6",
                "carrier_name": "Air Xpressbees 0.5 K.G",
                "cost": 179,
                "freight_charges": 179,
                "cod_charges": 0
            },
            {
                "carrier_id": "12298",
                "carrier_name": "Xpressbees 1 K.G",
                "cost": 138,
                "freight_charges": 138,
                "cod_charges": 0
            },
            {
                "carrier_id": "279",
                "carrier_name": "Bluedart- Surface",
                "cost": 190,
                "freight_charges": 190,
                "cod_charges": 0
            },
            {
                "carrier_id": "282",
                "carrier_name": "Blue Dart- Apex",
                "cost": 285,
                "freight_charges": 285,
                "cod_charges": 0
            },
            {
                "carrier_id": "delhivery_e_prepaid",
                "carrier_name": "Delhivery Express",
                "cost": 269,
                "freight_charges": 269,
                "cod_charges": 0
            },
            {
                "carrier_id": "delhivery_s_prepaid",
                "carrier_name": "Delhivery Surface",
                "cost": 152,
                "freight_charges": 152,
                "cod_charges": 0
            },
            {
                "carrier_id": "amazon_amazon_0.5_kg",
                "carrier_name": "Amazon (AMAZON 0.5 KG)",
                "cost": 168,
                "freight_charges": 168,
                "cod_charges": 0
            },
            {
                "carrier_id": "amazon_amazon_2kg",
                "carrier_name": "Amazon (AMAZON 2KG)",
                "cost": 156,
                "freight_charges": 156,
                "cod_charges": 0
            },
            {
                "carrier_id": "ekart_surface",
                "carrier_name": "Ekart Surface 2 kg",
                "cost": 138,
                "freight_charges": 138,
                "cod_charges": 0
            }
        ]
    }
}
                    

Error Responses:

  • 400 Bad Request: {"success": false, "message": "Missing required field: "} or {"success": false, "message": "Failed to fetch rates: "}
  • 401 Unauthorized: {"success": false, "message": "Missing or invalid Authorization header"} or {"success": false, "message": "Invalid JWT token"}
  • 403 Forbidden: {"success": false, "message": "The IP 'x.x.x.x' is not whitelisted"} or {"success": false, "message": "The domain 'example.com' is not whitelisted"}
  • 429 Too Many Requests: {"success": false, "message": "Too many rate requests"}
  • 405 Method Not Allowed: {"success": false, "message": "Method not allowed"}

Warehouse Endpoints

Manage pickup locations for shipments by adding new warehouses or retrieving existing ones.

Add Warehouse Endpoint

POST /add_warehouse

Adds a new warehouse for a seller, specifying pickup location details.

Request

Headers:

  • Content-Type: application/json
  • Authorization: Bearer (JWT from /login)
  • Origin: (optional, must be whitelisted, e.g., localhost)
  • X-Forwarded-For: (optional, must be whitelisted, e.g., 106.51.205.161)

Body:


{
    "nickname": "Main Warehouse",
    "mobileNumber": "9000000001",
    "address1": "123 Logistics Road",
    "address2": "Near Industrial Park",
    "pincode": "123456",
    "state": "Sample State",
    "city": "Sample City",
    "addressType": "primary"
}
                    

Notes:

  • nickname: Unique name for the warehouse (max 100 characters).
  • mobileNumber: 10-digit Indian mobile number (e.g., 9000000001).
  • address1: Primary address line (max 40 words).
  • address2: Optional secondary address line (max 40 words, defaults to Shiplee-partner).
  • pincode: 6-digit number starting with 1-9 (e.g., 123456).
  • state, city: Location details (max 100 characters each).
  • addressType: Optional, primary or secondary. If primary, existing primary warehouses for the seller are set to secondary. Defaults to primary if no primary exists, else secondary.
  • Duplicate warehouses (same mobileNumber, pincode, address1, address2, city, state) are rejected.

Examples


curl -X POST https://apiv1.shiplee.app/add_warehouse \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ..." \
-H "Origin: http://localhost" \
-H "X-Forwarded-For: 106.51.205.161" \
-d '{
    "nickname": "Main Warehouse",
    "mobileNumber": "9000000001",
    "address1": "123 Logistics Road",
    "address2": "Near Industrial Park",
    "pincode": "123456",
    "state": "Sample State",
    "city": "Sample City",
    "addressType": "primary"
}'
                            

$token = "eyJ..."
$body = @{
    nickname = "Main Warehouse"
    mobileNumber = "9000000001"
    address1 = "123 Logistics Road"
    address2 = "Near Industrial Park"
    pincode = "123456"
    state = "Sample State"
    city = "Sample City"
    addressType = "primary"
} | ConvertTo-Json
$headers = @{
    "Content-Type" = "application/json"
    "Authorization" = "Bearer $token"
    "Origin" = "http://localhost"
    "X-Forwarded-For" = "106.51.205.161"
}
$response = Invoke-RestMethod -Uri "https://apiv1.shiplee.app/add_warehouse" -Method Post -Body $body -Headers $headers
Write-Host "Warehouse ID: $($response.warehouseId)"
                            

Warehouse ID:                             

import requests

url = 'https://apiv1.shiplee.app/add_warehouse'
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
}
data = {
    'nickname': 'Main Warehouse',
    'mobileNumber': '9000000001',
    'address1': '123 Logistics Road',
    'address2': 'Near Industrial Park',
    'pincode': '123456',
    'state': 'Sample State',
    'city': 'Sample City',
    'addressType': 'primary'
}
response = requests.post(url, json=data, headers=headers)
print('Warehouse ID:', response.json()['warehouseId'])
                            

const axios = require('axios');

const url = 'https://apiv1.shiplee.app/add_warehouse';
const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
};
const data = {
    nickname: 'Main Warehouse',
    mobileNumber: '9000000001',
    address1: '123 Logistics Road',
    address2: 'Near Industrial Park',
    pincode: '123456',
    state: 'Sample State',
    city: 'Sample City',
    addressType: 'primary'
};

axios.post(url, data, { headers })
    .then(response => console.log('Warehouse ID:', response.data.warehouseId))
    .catch(error => console.error('Error:', error.response.data));
                            

Response

Success (201):


{
    "success": true,
    "message": "Warehouse added successfully",
    "warehouseId": 2147483833
}
                    

Error Responses:

  • 400 Bad Request: {"success": false, "message": "Missing required field: "} or {"success": false, "message": "Failed to add warehouse due to invalid details"} or {"success": false, "message": "Warehouse already exists with identical details", "warehouseId": }
  • 401 Unauthorized: {"success": false, "message": "Missing or invalid Authorization header"} or {"success": false, "message": "Invalid JWT token"}
  • 403 Forbidden: {"success": false, "message": "The IP 'x.x.x.x' is not whitelisted"} or {"success": false, "message": "The domain 'example.com' is not whitelisted"}
  • 429 Too Many Requests: {"success": false, "message": "Too many warehouse attempts"}
  • 405 Method Not Allowed: {"success": false, "message": "Method not allowed"}

Get Warehouses Endpoint

GET /get_warehouses

Retrieves a list of all non-deleted warehouses for the authenticated seller.

Request

Headers:

  • Content-Type: application/json
  • Authorization: Bearer (JWT from /login)
  • Origin: (optional, must be whitelisted, e.g., localhost)
  • X-Forwarded-For: (optional, must be whitelisted, e.g., 106.51.205.161)

Body: None

Notes:

  • Returns all warehouses with is_deleted = 0 for the seller’s sid.
  • Only one warehouse can be addressType: primary at a time.
  • Use the id as warehouseId in /create_shipment or /rates.

Examples


curl -X GET https://apiv1.shiplee.app/get_warehouses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ..." \
-H "Origin: http://localhost" \
-H "X-Forwarded-For: 106.51.205.161"
                            

$token = "eyJ..."
$headers = @{
    "Content-Type" = "application/json"
    "Authorization" = "Bearer $token"
    "Origin" = "http://localhost"
    "X-Forwarded-For" = "106.51.205.161"
}
$response = Invoke-RestMethod -Uri "https://apiv1.shiplee.app/get_warehouses" -Method Get -Headers $headers
Write-Host "Warehouses: $($response.data | ConvertTo-Json -Depth 5)"
                            

null                            

import requests
import json

url = 'https://apiv1.shiplee.app/get_warehouses'
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
}
response = requests.get(url, headers=headers)
print(json.dumps(response.json()['data'], indent=4))
                            

const axios = require('axios');

const url = 'https://apiv1.shiplee.app/get_warehouses';
const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJ...',
    'Origin': 'http://localhost',
    'X-Forwarded-For': '106.51.205.161'
};

axios.get(url, { headers })
    .then(response => console.log(JSON.stringify(response.data.data, null, 4)))
    .catch(error => console.error('Error:', error.response.data));
                            

Response

Success (200):


{
    "success": true,
    "message": "Warehouses retrieved successfully",
    "data": [
        {
            "id": 2147483833,
            "nickname": "Test Warehouse 7",
            "address1": "123 Logistics Road",
            "address2": "Near Industrial Park",
            "pincode": "123456",
            "state": "Sample State",
            "city": "Sample City",
            "address_type": "primary",
            "mobile_number": "9000000001",
            "addressType": "primary"
        },
        {
            "id": 2,
            "nickname": "Secondary Warehouse",
            "address1": "456 Business Avenue",
            "address2": "Near Business Hub",
            "pincode": "654321",
            "state": "Another State",
            "city": "Another City",
            "address_type": "secondary",
            "mobile_number": "9000000002",
            "addressType": "secondary"
        }
    ]
}
                    

Error Responses:

  • 401 Unauthorized: {"success": false, "message": "Missing or invalid Authorization header"} or {"success": false, "message": "Invalid JWT token"}
  • 403 Forbidden: {"success": false, "message": "The IP 'x.x.x.x' is not whitelisted"} or {"success": false, "message": "The domain 'example.com' is not whitelisted"}
  • 429 Too Many Requests: {"success": false, "message": "Too many warehouse attempts"}
  • 405 Method Not Allowed: {"success": false, "message": "Method not allowed"}

Support

For assistance, contact our support team: