Create shipping details for all items specific cart - Fabric
Create shipping details for all items specific cart
cURL
curl --request POST \
--url https://prod.cart.fabric.inc/v2/carts/{cartId}/shipping-details \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"shipToType": "SHIP_TO_ADDRESS",
"shipMethod": {
"shipMethodId": "1234",
"shipmentCarrier": "FedEx",
"shipmentMethod": "Next Day"
},
"address": {
"attention": "Billing manager",
"street1": "100 NE 100th St.",
"street2": "Suite 710",
"street3": "Seventh floor",
"street4": "Attention: Pat E. Kake",
"city": "Seattle",
"state": "Washington",
"country": "USA",
"zipCode": "98125",
"email": "test@mail.com",
"kind": "shipping",
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"phone": {
"number": "123-456-7899",
"kind": "MOBILE"
}
},
"taxCode": "FR1000",
"isPickup": true,
"altPickupPerson": {
"attention": "Billing manager",
"street1": "100 NE 100th St.",
"street2": "Suite 710",
"street3": "Seventh floor",
"street4": "Attention: Pat E. Kake",
"city": "Seattle",
"state": "Washington",
"country": "USA",
"zipCode": "98125",
"email": "test@mail.com",
"kind": "shipping",
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"phone": {
"number": "123-456-7899",
"kind": "MOBILE"
}
},
"pickupPerson": {
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"email": "test@mail.com"
},
"warehouseId": "XYZ-1234",
"storeId": "ABC-123",
"estimatedShipDate": "2022-02-18T15:12:40.974580",
"estimatedDeliveryDate": "2022-02-18T15:12:40.974580",
"shipmentInstructions": "Additional user instructions for shipping"
}
'
Python Example
import requests
url = "https://prod.cart.fabric.inc/v2/carts/{cartId}/shipping-details"
payload = {
"shipToType": "SHIP_TO_ADDRESS",
"shipMethod": {
"shipMethodId": "1234",
"shipmentCarrier": "FedEx",
"shipmentMethod": "Next Day"
},
"address": {
"attention": "Billing manager",
"street1": "100 NE 100th St.",
"street2": "Suite 710",
"street3": "Seventh floor",
"street4": "Attention: Pat E. Kake",
"city": "Seattle",
"state": "Washington",
"country": "USA",
"zipCode": "98125",
"email": "test@mail.com",
"kind": "shipping",
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"phone": {
"number": "123-456-7899",
"kind": "MOBILE"
}
},
"taxCode": "FR1000",
"isPickup": True,
"altPickupPerson": {
"attention": "Billing manager",
"street1": "100 NE 100th St.",
"street2": "Suite 710",
"street3": "Seventh floor",
"street4": "Attention: Pat E. Kake",
"city": "Seattle",
"state": "Washington",
"country": "USA",
"zipCode": "98125",
"email": "test@mail.com",
"kind": "shipping",
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"phone": {
"number": "123-456-7899",
"kind": "MOBILE"
}
},
"pickupPerson": {
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"email": "test@mail.com"
},
"warehouseId": "XYZ-1234",
"storeId": "ABC-123",
"estimatedShipDate": "2022-02-18T15:12:40.974580",
"estimatedDeliveryDate": "2022-02-18T15:12:40.974580",
"shipmentInstructions": "Additional user instructions for shipping"
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript Example
const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: '<authorization>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
shipToType: 'SHIP_TO_ADDRESS',
shipMethod: {shipMethodId: '1234', shipmentCarrier: 'FedEx', shipmentMethod: 'Next Day'},
address: {
attention: 'Billing manager',
street1: '100 NE 100th St.',
street2: 'Suite 710',
street3: 'Seventh floor',
street4: 'Attention: Pat E. Kake',
city: 'Seattle',
state: 'Washington',
country: 'USA',
zipCode: '98125',
email: 'test@mail.com',
kind: 'shipping',
name: {first: 'Pat', middle: 'E', last: 'Kake'},
phone: {number: '123-456-7899', kind: 'MOBILE'}
},
taxCode: 'FR1000',
isPickup: true,
altPickupPerson: {
attention: 'Billing manager',
street1: '100 NE 100th St.',
street2: 'Suite 710',
street3: 'Seventh floor',
street4: 'Attention: Pat E. Kake',
city: 'Seattle',
state: 'Washington',
country: 'USA',
zipCode: '98125',
email: 'test@mail.com',
kind: 'shipping',
name: {first: 'Pat', middle: 'E', last: 'Kake'},
phone: {number: '123-456-7899', kind: 'MOBILE'}
},
pickupPerson: {name: {first: 'Pat', middle: 'E', last: 'Kake'}, email: 'test@mail.com'},
warehouseId: 'XYZ-1234',
storeId: 'ABC-123',
estimatedShipDate: '2022-02-18T15:12:40.974580',
estimatedDeliveryDate: '2022-02-18T15:12:40.974580',
shipmentInstructions: 'Additional user instructions for shipping'
})
};
fetch('https://prod.cart.fabric.inc/v2/carts/{cartId}/shipping-details', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP Example
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://prod.cart.fabric.inc/v2/carts/{cartId}/shipping-details",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'shipToType' => 'SHIP_TO_ADDRESS',
'shipMethod' => [
'shipMethodId' => '1234',
'shipmentCarrier' => 'FedEx',
'shipmentMethod' => 'Next Day'
],
'address' => [
'attention' => 'Billing manager',
'street1' => '100 NE 100th St.',
'street2' => 'Suite 710',
'street3' => 'Seventh floor',
'street4' => 'Attention: Pat E. Kake',
'city' => 'Seattle',
'state' => 'Washington',
'country' => 'USA',
'zipCode' => '98125',
'email' => 'test@mail.com',
'kind' => 'shipping',
'name' => [
'first' => 'Pat',
'middle' => 'E',
'last' => 'Kake'
],
'phone' => [
'number' => '123-456-7899',
'kind' => 'MOBILE'
]
],
'taxCode' => 'FR1000',
'isPickup' => true,
'altPickupPerson' => [
'attention' => 'Billing manager',
'street1' => '100 NE 100th St.',
'street2' => 'Suite 710',
'street3' => 'Seventh floor',
'street4' => 'Attention: Pat E. Kake',
'city' => 'Seattle',
'state' => 'Washington',
'country' => 'USA',
'zipCode' => '98125',
'email' => 'test@mail.com',
'kind' => 'shipping',
'name' => [
'first' => 'Pat',
'middle' => 'E',
'last' => 'Kake'
],
'phone' => [
'number' => '123-456-7899',
'kind' => 'MOBILE'
]
],
'pickupPerson' => [
'name' => [
'first' => 'Pat',
'middle' => 'E',
'last' => 'Kake'
],
'email' => 'test@mail.com'
],
'warehouseId' => 'XYZ-1234',
'storeId' => 'ABC-123',
'estimatedShipDate' => '2022-02-18T15:12:40.974580',
'estimatedDeliveryDate' => '2022-02-18T15:12:40.974580',
'shipmentInstructions' => 'Additional user instructions for shipping'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Expected Response
{
"shipToId": "fef78121-bee3-4448-bf1c-d5b5461dbda2",
"cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
"createdAt": "2022-02-18T15:12:40.974580",
"updatedAt": "2022-02-18T15:12:40.974580",
"shipMethod": {
"cost": {
"amount": 10,
"currency": "USD",
"discount": 5
},
"shipMethodId": "1234",
"shipmentCarrier": "FedEx",
"shipmentMethod": "Next Day"
},
"address": {
"attention": "Billing manager",
"street1": "100 NE 100th St.",
"street2": "Suite 710",
"street3": "Seventh floor",
"street4": "Attention: Pat E. Kake",
"city": "Seattle",
"state": "Washington",
"country": "USA",
"zipCode": "98125",
"email": "test@mail.com",
"kind": "shipping",
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"phone": {
"number": "123-456-7899",
"kind": "MOBILE"
}
},
"shipToType": "SHIP_TO_ADDRESS",
"taxCode": "FR1000",
"isPickup": true,
"altPickupPerson": {
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"phone": {
"number": "123-456-7899",
"kind": "MOBILE"
},
"email": "test@mail.com"
},
"pickupPerson": {
"name": {
"first": "Pat",
"middle": "E",
"last": "Kake"
},
"phone": {
"number": "123-456-7899",
"kind": "MOBILE"
},
"email": "test@mail.com"
},
"warehouseId": "XYZ-1234",
"storeId": "ABC-123",
"estimatedShipDate": "2022-02-18T15:12:40.974580",
"estimatedDeliveryDate": "2022-02-18T15:12:40.974580",
"shipmentInstructions": "Additional user instructions for shipping"
}