Warehouses API

The /api/warehouses endpoint exposes the Warehouse Model as a resource. Warehouses contain bin locations, which can in turn contain stock for individual products.

GET /api/warehouses

Query all warehouses or a subset of warehouses according to a set of criteria.

Query Parameters:
 
  • start (integer) – the starting offset into the result list (default: 0)
  • limit (integer) – the maximum number of results (default: 1000)
  • filter (object) – a search filter (see Filter and Sort Query Parameters), with property names prefixed by warehouse., for example warehouse.name
  • sort (object) – a sorting specification (see Filter and Sort Query Parameters), with property names prefixed by warehouse., for example warehouse.name
Response JSON Object:
 
  • success (boolean) – whether the operation was successful
  • total (integer) – the total number of warehouses which matched the query
  • data (array) – an array of warehouses, see the single-warehouse endpoint for a description of the resource properties

Example request:

http

GET /api/warehouses HTTP/1.1
Host: localhost
Accept: application/json

curl

curl -i https://localhost/api/warehouses -H 'Accept: application/json'

wget

wget -S -O- https://localhost/api/warehouses --header='Accept: application/json'

httpie

http https://localhost/api/warehouses Accept:application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "success": true,
    "total": 1,
    "data": [
        {
            "id": 1,
            "code": "MW",
            "name": "Main Warehouse",
            "stockAvailableForSale": true,
            "defaultWarehouse": true,
            "defaultReturnShipmentWarehouse": true,
            "nullBinLocationId": 12,
            "contact": "Jane Doe",
            "email": "jane.doe@pickware.com",
            "phone": "+1 93283 329493",
            "address": "3793 Blair Court, Rockville MO",
            "comment": "A comment",
            "binLocationFormatComponents": []
        }
    ]
}
GET /api/warehouses/{id}

Fetch a warehouse by its database ID.

Parameters:
  • id (integer) – the database ID of the warehouse to fetch
Response JSON Object:
 
  • success (boolean) – whether the operation was successful
  • data (object) – the warehouse with the given ID
  • data.id (integer) – the database ID of the warehouse
  • data.code (string) – the warehouses’s shorthand code
  • data.name (string) – the warehouse’s readable name
  • data.stockAvailableForSale (boolean) – whether the stock inside the warehouse should count towards the available stock of the online shop
  • data.defaultWarehouse (boolean) – whether this is the default warehouse
  • data.defaultReturnShipmentWarehouse (boolean) – whether this is the default warehouse for return shipments
  • data.nullBinLocationId (string) – database ID of the unknown bin location of this warehouse
  • data.contact (string) – the name of the person responsible for the warehouse
  • data.email (string) – the email address of the person responsible for the warehouse
  • data.phone (string) – the phone number of the person responsible for the warehouse
  • data.address (string) – the street address of the warehouse
  • data.comment (string) – an arbitrary comment for the warehouse
  • data.binLocationFormatComponents (array) – a specification of the format for bin location codes

Example request:

http

GET /api/warehouses/2 HTTP/1.1
Host: localhost
Accept: application/json

curl

curl -i https://localhost/api/warehouses/2 -H 'Accept: application/json'

wget

wget -S -O- https://localhost/api/warehouses/2 --header='Accept: application/json'

httpie

http https://localhost/api/warehouses/2 Accept:application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "success": true,
    "data": {
        "id": 2,
        "code": "SW",
        "name": "Secondary Warehouse",
        "stockAvailableForSale": false,
        "defaultWarehouse": false,
        "defaultReturnShipmentWarehouse": false,
        "nullBinLocationId": 23,
        "contact": "",
        "email": "",
        "phone": "",
        "address": "",
        "comment": "",
        "binLocationFormatComponents": []
    }
}
POST /api/warehouses

Create a new warehouse.

Request JSON Object:
 
  • code (string) – the warehouses’s shorthand code
  • name (string) – the warehouse’s readable name
  • stockAvailableForSale (boolean) – whether the stock inside the warehouse should count towards the available stock of the online shop
  • contact (string) – the name of the person responsible for the warehouse
  • email (string) – the email address of the person responsible for the warehouse
  • phone (string) – the phone number of the person responsible for the warehouse
  • address (string) – the street address of the warehouse
  • comment (string) – an arbitrary comment for the warehouse
  • binLocationFormatComponents (array) – a specification of the format for bin location codes

Example request:

http

POST /api/warehouses HTTP/1.1
Content-Type: application/json
Host: localhost

{
    "code": "W2",
    "name": "Second Warehouse",
    "stockAvailableForSale": false,
    "contact": "Jon Doe",
    "email": "jon.doe@pickware.com",
    "phone": "+1 93283 329493",
    "address": "3793 Blair Court, Rockville MO",
    "comment": "A comment"
}

curl

curl -i -X POST https://localhost/api/warehouses -H 'Content-Type: application/json' --data-raw '{"address": "3793 Blair Court, Rockville MO", "code": "W2", "comment": "A comment", "contact": "Jon Doe", "email": "jon.doe@pickware.com", "name": "Second Warehouse", "phone": "+1 93283 329493", "stockAvailableForSale": false}'

wget

wget -S -O- https://localhost/api/warehouses --header='Content-Type: application/json' --post-data='{"address": "3793 Blair Court, Rockville MO", "code": "W2", "comment": "A comment", "contact": "Jon Doe", "email": "jon.doe@pickware.com", "name": "Second Warehouse", "phone": "+1 93283 329493", "stockAvailableForSale": false}'

httpie

echo '{
  "address": "3793 Blair Court, Rockville MO",
  "code": "W2",
  "comment": "A comment",
  "contact": "Jon Doe",
  "email": "jon.doe@pickware.com",
  "name": "Second Warehouse",
  "phone": "+1 93283 329493",
  "stockAvailableForSale": false
}' | http POST https://localhost/api/warehouses Content-Type:application/json

Example response:

HTTP/1.1 201 Created
Content-Type: application/json

{
    "success": true,
    "data": [
        {
            "id": 3,
            "location": "https://localhost/api/warehouses/3"
        }
    ]
}
PUT /api/warehouses/{id}

Update the warehouse with the given database ID using the data in the request body.

Parameters:
  • id (integer) – the database ID of the warehouse to update
Request JSON Object:
 
  • code (string) – the warehouses’s shorthand code
  • name (string) – the warehouse’s readable name
  • stockAvailableForSale (boolean) – whether the stock inside the warehouse should count towards the available stock of the online shop
  • contact (string) – the name of the person responsible for the warehouse
  • email (string) – the email address of the person responsible for the warehouse
  • phone (string) – the phone number of the person responsible for the warehouse
  • address (string) – the street address of the warehouse
  • comment (string) – an arbitrary comment for the warehouse
  • binLocationFormatComponents (array) – a specification of the format for bin location codes

Example request:

http

PUT /api/warehouses/3 HTTP/1.1
Content-Type: application/json
Host: localhost

{
    "code": "RW",
    "name": "Return warehouse"
}

curl

curl -i -X PUT https://localhost/api/warehouses/3 -H 'Content-Type: application/json' --data-raw '{"code": "RW", "name": "Return warehouse"}'

wget

wget -S -O- --method=PUT https://localhost/api/warehouses/3 --header='Content-Type: application/json' --body-data='{"code": "RW", "name": "Return warehouse"}'

httpie

echo '{
  "code": "RW",
  "name": "Return warehouse"
}' | http PUT https://localhost/api/warehouses/3 Content-Type:application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "success": true
}
DELETE /api/warehouses/{id}

Delete the warehouse with the given database ID.

Parameters:
  • id (integer) – the database ID of the warehouse to delete
Status Codes:
  • 400 Bad Request – if the warehouse cannot be deleted because it is the default warehouse or the default return shipment warehouse, it still has bin locations or there’s still stock in the warehouse

Example request:

http

DELETE /api/warehouses/3 HTTP/1.1
Host: localhost

curl

curl -i -X DELETE https://localhost/api/warehouses/3

wget

wget -S -O- --method=DELETE https://localhost/api/warehouses/3

httpie

http DELETE https://localhost/api/warehouses/3

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "success": true
}