This article lists the ToolWatch API request for inventory procurement: Create. Every request needs an authorization token. To get one, see ToolWatch API: Authorization.
Create
Request
URI
https://api.{cluster}.toolwatch.net/inventoryprocurementHttp Method
POST
Headers
Authorization: {token}
Request Body
Field | Type | Required | Description |
VendorId | guid | Yes | Vendor the purchase order is placed with. |
ShipToEntityId | guid | Yes | Entity the inventory ships to. Must be a stock location. |
ShippingCharges | decimal | No | Shipping charges for the purchase order. |
TaxCharges | decimal | No | Tax charges for the purchase order. |
PurchaseOrderNumber | string | No | Purchase order number. Optional for new procurements; either PurchaseOrderId or PurchaseOrderNumber is required when posting a correction. |
Correction | boolean | No | When true, creates negative-quantity correction receipts against an existing purchase order. |
PurchaseOrderId | guid | No | Existing purchase order id. Either PurchaseOrderId or PurchaseOrderNumber is required when posting a correction. |
InventoryProcured | array | Yes | One or more items to procure. See the InventoryProcured table below. |
Each InventoryProcured element:
Field | Type | Required | Description |
Quantity | integer | Yes | Quantity to receive. Positive for a procurement; must be negative for a correction. |
Cost | decimal | No | Unit cost of the item. |
ModelId | guid | No | Identifies the ToolWatch model by id. Provide exactly one of ModelId, ModelNumber, or (Category, ModelName, TrackingMethod). |
ModelNumber | string | No | Identifies the model by number (must be distinct in ToolWatch). Provide exactly one of ModelId, ModelNumber, or (Category, ModelName, TrackingMethod). Max 50 characters. |
Category | string | No | Category used with ModelName and TrackingMethod to match an existing model or lazily create a new one. Max 50 characters. |
ModelName | string | No | Model name used with Category and TrackingMethod to match an existing model or lazily create a new one. Max 50 characters. |
TrackingMethod | string | No | (T)ool, (Q)uantity, or (M)aterial. Required with (Category, ModelName); must be Q or M for a correction. |
ItemNumber | string | No | Item number. Required for a correction. |
Notes
The Inventory Procurement Create API creates a Purchase Order, a corresponding Receiving Ticket, and the associated Inventory Procured from the Receiving Ticket that enter ToolWatch as tools and/or materials.
Response
200 Ok
Response body contains the created procurement.
Field | Type | Description |
PurchaseOrderId | guid | Id of the created (or existing) purchase order. |
PurchaseOrderNumber | string | Purchase order number. |
ReceiptHeaderId | guid | Id of the created receiving ticket. |
VendorId | guid | Vendor id. |
ShipToEntityId | guid | Entity the inventory shipped to. |
InventoryProcured | array | The procured items. Each element contains ModelId (guid) and Quantity (integer). |
Example response body:
{
"PurchaseOrderId": "037c5467-206b-42a5-8afc-27276b29bc41",
"PurchaseOrderNumber": "1042",
"ReceiptHeaderId": "5310c037-7020-47e6-9f48-c731fdd35c3a",
"VendorId": "033ab474-8512-4b79-933c-0a5888e3df73",
"ShipToEntityId": "849197e3-6cc4-4150-ae71-3f2fc1fbc53d",
"InventoryProcured": [
{
"ModelId": "5310c037-7020-47e6-9f48-c731fdd35c3a",
"Quantity": 5
}
]
}400 Bad Request
Triggered when field level validation fails
Response body will contain error message
[
{
"Message": "Exactly one of ModelId, ModelNumber, or (Category, ModelName, TrackingMethod) must be provided."
}
]
[
{
"Message": "ShipToEntityId 37C5467E-206B-42A5-8AFC-27276B29BC41 is not a stock point."
}
]
[
{
"Message": "ModelNumber 7 does not uniquely identify the model."
}
]
[
{
"Message": "TrackingMethod X must be one of T, Q, or M."
}
]
[
{
"Message": "Quantity must be negative for a correction."
}
]
[
{
"Message": "TrackingMethod must be Q or M for a correction."
}
]
[
{
"Message": "ShipToEntityId and ItemNumber must be associated with an existing purchase order."
}
]
[
{
"Message": "Chosen quantity of X would lead to a negative total quantity received of Y for the associated purchase order."
}
]
[
{
"Message": "ShipToEntityId and ItemNumber must be associated with an existing receipt item."
}
]
[
{
"Message": "All corrections must be associated with the same purchase order."
}
]
