The Enterprise API add-on license is required to have access to the APIs.
API documentation: APIs: Details - CRIBWISE API Management - Developer portal
Steps to create a purchase order
We will create an order and add items to it. We'll then set the order to active to send it to the vendor and make it available on the SFI for restocking.
APIs that will be used are as follows:
Primary key and subscription keys
To be able to access the API you need a Primary Key (primary_key) and an API Key (api_key).
The Primary key is a global account key that will be provided by SECO, ask your customer success manager to help you with retrieving it.
The API key is created in the Admin Portal. Go to Administrations > Integration > API keys > Create a new key. It should have the structure of APShortname_Secret.
Authentication
Authentication is by bearer token and it's valid for 1h. To retrieve the Bearer Token use
POST https://app.cribwise.com/adminportalidentity/connect/token
Headers:
- client_id: erp_client
- client_secret: api_key
- grant_type: client_credentials
- scope: erp_api
Example in PostMan:
Create purchase order
API: POST https://api.cribwise.com/integration/v1/integrationapi/PurchaseOrders
Note! Orders are per Stock, Vendor, and Device in that exact order. e.g. An item will have one order per device, per vendor, per stock. If an item belongs to two Devices you need to have two separate orders.
Use the Bearer Token as authorization:
Set header to ' x-cribwise-subscription-key' with the primary_key
The Body or payload has to contain these fields as a minimum:
- stockId: "Default.Stock.StockX"
- vendorId: "MasterData.VendorX"
- deviceId: "Stock.DeviceX",
- status: "New"
If the call is successful the status code will be 200 and the API will return a header of location. The location will have a unique purchase order number. In this example its Purchase.Order362017.
That purchase order number will be used to add data to that specific purchase order in the coming steps.
Note! To get the different values:
Default.Stock.StockX: GET https://api.cribwise.com/integration/v1/integrationapi/Devices[?Name]
MasterData.VendorX: GET https://api.cribwise.com/integration/v1/integrationapi/Vendors[?LastModified][&VendorId][&Name]
OR
Use GEThttps://api.cribwise.com/integration/v1/integrationapi/Items[?Name] if you know the Item already.
Stock.DeviceX: GET https://api.cribwise.com/integration/v1/integrationapi/Devices or go to the AP > Data management > Devices > Open Device.
Search options are used like: .../Items?Name=item%20name
Create purchase order items
API: POST https://api.cribwise.com/integration/v1/integrationapi/PurchaseOrderItems
When the order is created and you receive the unique order number back from the call, it's time to add the items to the order.
The body or payload has to contain these fields as a minimum:
- orderId: "Purchase.Order362017",
- deviceId: "Stock.DeviceX",
- itemId: "Stock.ItemX",
- totalQuantity: 2
If the call was successful the status code will be 200 and the API will return a header of location. The location will have a unique purchase order item number. In this example its Purchase.PurchaseOrderItem1181064.
Note! To verify the order and that it looks correct, you can use the
GET https://api.cribwise.com/integration/v1/integrationapi/PurchaseOrders to receive all purchase orders or, GET https://api.cribwise.com/integration/v1/integrationapi/PurchaseOrders/Purchase.OrderX to receive the specific purchase order.
Update a purchase order
API: PATCH https://api.cribwise.com/integration/v1/integrationapi/PurchaseOrders/Purchase.OrderX
The body or payload has to contain these fields as a minimum:
- version: X,
- status: "Active"
The version has to correlate to the current version of the purchase order. It keeps track of which version you want to update. When the status is set to Active the order will be sent to the vendor and it will become available on the SFI to be restocked.
Note! It's only possible to set the status to Active if the order contains items.
Comments
0 comments
Please sign in to leave a comment.