SwiftHub API

Created by Hoan Trần
Created time
Tags Guides

▶️ Inbound orders (B2B)

Get all inbound orders

  • Use this API to get all purchase orders. Filter by states and po_number. Available states are- 'PENDING', 'INPROCESS', 'COMPLETED', and 'CANCELLED’
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var requestOptions = {
       method: 'GET',
       headers: myHeaders,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/purchase_orders", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));
    QUERY PARAMETERS
    filter[search_pattern][0]
    string
    filter[search_pattern][1]
    string
    filter[state][0]
    string
    filter[state][1]
    string
    filter[supplier][0]
    string
    filter[supplier][1]
    string
    filter[created_at]
    string
    page[size]
    integer
    page[number]
    integer

Get an inbound order by ID

  • Used to get status of specific inbound orders.
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var requestOptions = {
       method: 'GET',
       headers: myHeaders,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/purchase_orders/{purchase_order_number}", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

Create an inbound order

  • Create an inbound order
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
       "purchase_order": {
          "order_type": "",
          "PO_number": "",
          "supplier_code": "",
          "receiving_date": "",
          "shipping_code": "",
          "shipping_address": "",
          "instruction": "",
          "creation_mode": "",
          "consignment_items_attributes": {
             "sku": "",
             "batch_number": "",
             "expiry_date": "",
             "stock": 0,
             "uom_code": "",
             "pack_size": 0,
             "quantity": 0,
             "unit_price": 0
          },
          "value_added_service_attributes": {
             "price_tag": 0,
             "security_tag": 0,
             "shrink_wrapping": 0,
             "price_tag_dimension": ""
          }
       }
    });
    
    var requestOptions = {
       method: 'POST',
       headers: myHeaders,
       body: raw,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/purchase_orders/create", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

▶️ Sales orders (B2B)

Get sales orders

  • Get all orders

    Fetch all orders and it's state

    
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var requestOptions = {
       method: 'GET',
       headers: myHeaders,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/orders", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

    filter[search_pattern][0]string

    filter[search_pattern][1]string

    filter[order_types][0]string

    filter[order_types][1]string

    filter[sources][0]string

    filter[sources][1]string

    filter[status][0]stringExample: NEW

    filter[status][1]stringExample: APPROVED

    filter[substatus][0]string
    substatus can be (created, picking, picked, packed, ready_to_ship, manifest_created, dispatched, in_Transit, Delivered, cancelled)

    filter[substatus][1] string

    filter[shipping_type][0]string, Example: E-PAQ Standard

    filter[type]string
    values may be draft, confirmed and marketplaces

    filter[created_at]string

    filter[problem_state]integer
    Used in problem order grid, enter 1 for SKU missing in Order, 2 for SKU not in Inventory and 3 for Out of Stock, and 4 for Multiple problems

    page[number]integer

    page[size]integer

    sortstring
    To sort by 'Order Number' use 'order_number' (ascending) or '-order_number' (descending), for 'Tracking ID' use 'tracking_number', for 'Carrier' use 'carrier', for 'Created On' use 'created_on', for 'Product Units' use 'product_units', for 'SLA' use 'sla' and for 'Source' use 'source' include '-'(minus sign) infront of particular field to sort in descending order.

  • Get the status of b2b order for given order id
    // /external-api/v1/orders/b2b/{order_id}
    
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var requestOptions = {
       method: 'GET',
       headers: myHeaders,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/orders/b2b/{order_id}", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

Create a sale order

  • Create a B2B sale order
    // /external-api/v1/orders/create/shipment
    
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
       "b2b_order": {
          "shipping_type": "",
          "carrier_name": "",
          "stock_condition": "",
          "order_number": "",
          "currency": "",
          "delivery_date": "",
          "instruction": "",
          "custom_duty": "",
          "adjustment_attributes": {
             "total_payble": 0,
             "shipping_cost": 0,
             "tax_amount": 0,
             "discount": 0,
             "sub_total": 0
          },
          "order_items_attributes": [
             {
                "sku": "",
                "unit_price": 0,
                "retail_price": 0,
                "selling_price": 0,
                "quantity": 0,
                "uom": "",
                "expiry_date": "",
                "batch_number": ""
             }
          ],
          "billing_address_attributes": {
             "first_name": "",
             "last_name": "",
             "business_name": "",
             "phone": "",
             "email": "",
             "address1": "",
             "address2": "",
             "address3": "",
             "country_iso3": "",
             "state": "",
             "city": "",
             "suburb": "",
             "zipcode": ""
          },
          "shipping_address_attributes": {
             "first_name": "",
             "last_name": "",
             "business_name": "",
             "phone": "",
             "email": "",
             "address1": "",
             "address2": "",
             "address3": "",
             "country_iso3": "",
             "state": "",
             "city": "",
             "suburb": "",
             "zipcode": ""
          },
          "value_added_services_attributes": {
             "price_tag": 0,
             "price_tag_dimension": ""
          }
       }
    });
    
    var requestOptions = {
       method: 'POST',
       headers: myHeaders,
       body: raw,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/orders/create/b2b", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

Update a sale order

  • Update an order by ID
    // /external-api/v1/orders/update/{order_id}/b2b
    
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
       "b2b_order": {
          "shipping_type": "",
          "carrier_name": "",
          "stock_condition": "",
          "order_number": "",
          "currency": "",
          "delivery_date": "",
          "instruction": "",
          "custom_duty": "",
          "adjustment_attributes": {
             "total_payble": 0,
             "shipping_cost": 0,
             "tax_amount": 0,
             "discount": 0,
             "sub_total": 0
          },
          "order_items_attributes": [
             {
                "sku": "",
                "unit_price": 0,
                "retail_price": 0,
                "selling_price": 0,
                "quantity": 0,
                "uom": "",
                "expiry_date": "",
                "batch_number": ""
             }
          ],
          "billing_address_attributes": {
             "first_name": "",
             "last_name": "",
             "business_name": "",
             "phone": "",
             "email": "",
             "address1": "",
             "address2": "",
             "address3": "",
             "country_iso3": "",
             "state": "",
             "city": "",
             "suburb": "",
             "zipcode": ""
          },
          "shipping_address_attributes": {
             "first_name": "",
             "last_name": "",
             "business_name": "",
             "phone": "",
             "email": "",
             "address1": "",
             "address2": "",
             "address3": "",
             "country_iso3": "",
             "state": "",
             "city": "",
             "suburb": "",
             "zipcode": ""
          },
          "value_added_services_attributes": {
             "price_tag": 0,
             "price_tag_dimension": ""
          }
       }
    });
    
    var requestOptions = {
       method: 'PUT',
       headers: myHeaders,
       body: raw,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/orders/update/{order_id}/b2b", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

Cancel an order

  • Cancel an order by ID
    // /external-api/v1/orders/{order_id}/cancel
    
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
       "body": "object"
    });
    
    var requestOptions = {
       method: 'PUT',
       headers: myHeaders,
       body: raw,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/orders/{order_id}/cancel", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

▶️ PRODUCT/ INVENTORY

Get product list

  • Fetch all products at the warehouse
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var requestOptions = {
       method: 'GET',
       headers: myHeaders,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/products/{type}/product", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

    Query parameters

    This api is useful to get Products with pagination and search capability. The parameter type can have values all/in-stock/low-in-stock/out-of-stock/deactivated/archived.

    Example call:

     - /external-api/v1/products/low-in-stock/product?filter[search_pattern][0]=headphone&page[number]=1&page[size]=10
    
    filter[search_pattern][0]
    string
    filter[search_pattern][1]
    string
    filter[categories][0]
    string
    filter[categories][1]
    string
    filter[storage_types][0]
    string
    filter[created_at]
    string
    filter[is_marketplace_product]
    string
    Example: yes/no
    filter[marketplaces][0]
    string
    filter[marketplaces][1]
    string
    page[number]
    integer
    page[size]
    integer

Create a product

  • Create a product
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
       "products": {
          "supplier_name": "",
          "sku": "",
          "brand_name": "",
          "product_name": "",
          "mfupc": "",
          "quantity": 0,
          "product_category_name": "",
          "storage_type_name": "",
          "temp_uom": "",
          "temp_value": "",
          "product_type": 0,
          "unique_serial_number": 0,
          "imei_number": 0,
          "batch_management": 0,
          "threshold": 0,
          "buffer_stock": 0,
          "dimension_type": "",
          "currency_name": "",
          "min_units": 0,
          "max_units": 0,
          "basic_price": 0,
          "retail_price": 0,
          "selling_price": 0,
          "langugae_name": "",
          "country_name": "",
          "local_name": "",
          "mark_as_default": 0,
          "sku_mapping": [
             {
                "uom": "",
                "upc_ean_mapping": 0,
                "no_of_units": 0,
                "length_cm": 0,
                "width_cm": 0,
                "height_cm": 0,
                "weight": 0,
                "barcode": 0
             }
          ],
          "tier_pricing": [
             {
                "tag": "",
                "min_units": 0,
                "max_units": 0,
                "unit_selling_price": 0
             }
          ],
          "expiry_management": [
             {
                "shelf_life": {
                   "product": 0,
                   "inbound": 0,
                   "outbound": 0
                },
                "stock_take_cycle": {
                   "days": 0
                }
             }
          ]
       }
    });
    
    var requestOptions = {
       method: 'POST',
       headers: myHeaders,
       body: raw,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/products/create_inventory", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

Get inventory stock

  • Get inventory stock details by SKU
    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var requestOptions = {
       method: 'GET',
       headers: myHeaders,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/products/{product_sku}/inventory_stock", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

▶️ SUPPLIERS

Create Supplier

  • This API is use for creation of supplier

    Request

    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var raw = JSON.stringify({
       "supplier": {
          "supplier_name": "",
          "supplier_code": "",
          "email_id": "",
          "contact_number": "",
          "contact_person": "",
          "address_1": "",
          "address_2": "",
          "address_3": "",
          "ISO3_country_code": "",
          "state_name": "",
          "city": "",
          "postal_code": 0
       }
    });
    
    var requestOptions = {
       method: 'POST',
       headers: myHeaders,
       body: raw,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/suppliers/create", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

    Response

    201: This response is use for successfuly creation of the supplier

    403: Not have permission to acces resource

    404: Not Found

    503: Service Unavailable

Get Suppliers

  • Get active/inactive/onboarded supplier list with pagination

    Request

    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json");
    
    var requestOptions = {
       method: 'GET',
       headers: myHeaders,
       redirect: 'follow'
    };
    
    fetch("/external-api/v1/suppliers/{state}/supplier", requestOptions)
       .then(response => response.text())
       .then(result => console.log(result))
       .catch(error => console.log('error', error));

    Response

    201: This response is use for successfuly creation of the supplier

    // Successfully getting supplier as per state 
    {
      "result": 0,
      "level": "",
      "message": "",
      "data": {},
      "meta": {}
    }

    403: Not have permission to acces resource

    404: Not Found

    503: Service Unavailable