Create Order with one Parcel
The scenario
Mr John Doe has just bought an Awesome product from your eshop, he chose cash on delivery and home delivery to Sesame street 11b, MyCoolCity, Michigan US. He filled in billing details of his company. The order contains one product and shipping costs. Let's create an order for him and then add a Parcel to it.
Are you using shopify/shoptet/upgates? You don't need this guide! We offer prebuilt zero-effort modules that can be integrated into your e-commerce solution in just a few clicks. Check here.
To begin, the most basic illustration involves the creation of a fresh order. Subsequently, a create parcel endpoint will be used to create a Parcel for that specific order. Once Foxdeli system has required tracking data it will initiate parcel tracking via the carrier's API.
1. Obtain API key via AUTH API
To obtain access to Foxdeli API, you will first need to create API credentials in Foxdeli Settings. Use these crentials in Authorize endpoint to obtain access token.
curl -L -X POST 'https://api.foxdeli.com/customer/api/v1/token/authorize' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
--data-raw '{
"email": "myuser@coolmail.com",
"password": "supersecretpwd"
}'
After making a request, the response will comprise an access token, which remains valid for 10 minutes, and a refresh token, which remains valid for 24 hours. The refresh token can be employed to obtain a new access token by using the refresh endpoint. In order to make API requests, use the access token within the X-API-Key header.
2. Create order
Make use of the Create new Order endpoint to initiate the creation of a new Order.
curl -L -X POST 'https://api.foxdeli.com/tracking/api/v1/order' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-API-Key: <ACCESS_TOKEN_VALUE>' \
--data-raw '{
"eshopId": "12345678-1234-1234-1234-1234567890ab",
"marketId": "12345678-1234-1234-1234-1234567890ab",
"platform": "custom",
"externalCreated": "2012-12-31T23:59:59Z",
"orderNumber": "A123456789",
"externalIdentifier": "ORD123456789",
"price": {
"amount": 99.96,
"currency": "CZK"
},
"cashOnDelivery": {
"amount": 99.96,
"currency": "CZK"
},
"additionalCosts": [
{
"type": "SHIPPING",
"price": {
"amount": 19.96,
"currency": "CZK"
},
"name": "Home delivery"
}
],
"payment": {
"paid": false,
"method": "CASH_ON_DELIVERY",
"service": "PAYPAL",
"link": "https://pay.me/order/A123456789"
},
"customer": {
"name": "John Doe",
"email": "iboughtsomething@customer.com",
"phone": "+420 123 456 789"
},
"destination": {
"type": "HOUSE_ADDRESS",
"address": {
"line1": "Sesame street",
"line2": "11b",
"city": "MyCoolCity",
"postalCode": "48228",
"countryCode": "US",
"state": "Michigan",
"region": "Michigan"
}
},
"products": [
{
"type": "PRODUCT",
"sku": "A1234",
"name": "Awesome product",
"description": "So awesome you must have it!",
"url": "https://mycoolshop.com/product/A1234",
"image": "https://mycoolshop.com/img/product/A1234.png",
"price": {
"amount": 80.00,
"currency": "CZK"
},
"vat": 0.0,
"quantity": 1
}
],
"billingDetails": {
"name": "John Doe",
"companyName": "Does company Ltd",
"billingAddress": {
"line1": "Sesame street",
"line2": "11b",
"city": "MyCoolCity",
"postalCode": "48228",
"countryCode": "US",
"state": "Michigan",
"region": "Michigan",
"longitude": 50.0933864,
"latitude": 14.4542789
},
"crn": "12345678",
"vatId": "CZ12345678",
"email": "johndoe@mail.com",
"phone": "+420 123 456 789"
},
"language": "cs"
}'
Now the order has been created in Foxdeli system and the response will contain order data and most importantly ID that you will need for subsequent calls.
3. Create parcel for order
Make use of Create Parcel endpoint to create a Parcel for previously created Order using ID from previous response.
curl -L -X POST 'https://api.foxdeli.com/tracking/api/v1/order/<ORDER_ID_FROM_PREVIOUS_RESPONSE>/parcel' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-API-Key: <ACCESS_TOKEN_VALUE>' \
--data-raw '{
"products": [
"A1234"
],
"tracking": [
{
"carrier": "GLS",
"number": "1234567890"
}
]
}'
This will create a Parcel for Order carried by GLS. Now you can check it in Foxdeli app.