Create subscriptions orders - Fabric

Create subscriptions orders

cURL

curl --request POST \
  --url https://prod01-apigw.yourcompany.fabric.zone/api-order/subscriptions/orders \
  --header 'Content-Type: application/json' \
  --header 'x-site-context: <x-site-context>' \
  --data '
{
  "cartId": "5e4876e10cfe1d8902005d33",
  "channel": 11,
  "orderTotal": 125.99,
  "taxTotal": 5.23,
  "orderCurrency": "USD",
  "status": "ORDER_CREATED",
  "customerUserId": "5e3598e3007c5e00080d2bb8",
  "shipTo": [
    {
      "shipToId": 1000001,
      "shipToType": "SHIP_TO_ADDRESS",
      "price": 24.87,
      "currency": "USD",
      "estimatedTax": 10.25,
      "committedTax": 10.25,
      "promosApplied": [
        {}
      ],
      "total": 1,
      "taxCode": "FR020000",
      "shipmentCarrier": "Fedex",
      "shipmentMethod": "Express",
      "shipmentMethodId": "10000001",
      "promisedDeliveryDate": "2019-12-14",
      "shipmentInstructions": "Leave at back door",
      "shipmentStatus": "Delivered"
    }
  ],
  "orderReference": "<string>",
  "statusLog": "Order has been cancelled",
  "customerAccountId": "5e3598e3007c5e00080d2bb8",
  "customerEmail": "jsmith@example.com",
  "notes": "<string>",
  "tags": [
    "tag100",
    "tag101"
  ],
  "events": [
    {
      "status": "ORDER_CREATED",
      "data": {}
    }
  ]
}
' 

Python Example

import requests

url = "https://prod01-apigw.yourcompany.fabric.zone/api-order/subscriptions/orders"

payload = {
    "cartId": "5e4876e10cfe1d8902005d33",
    "channel": 11,
    "orderTotal": 125.99,
    "taxTotal": 5.23,
    "orderCurrency": "USD",
    "status": "ORDER_CREATED",
    "customerUserId": "5e3598e3007c5e00080d2bb8",
    "shipTo": [
        {
            "shipToId": 1000001,
            "shipToType": "SHIP_TO_ADDRESS",
            "price": 24.87,
            "currency": "USD",
            "estimatedTax": 10.25,
            "committedTax": 10.25,
            "promosApplied": [{}],
            "total": 1,
            "taxCode": "FR020000",
            "shipmentCarrier": "Fedex",
            "shipmentMethod": "Express",
            "shipmentMethodId": "10000001",
            "promisedDeliveryDate": "2019-12-14",
            "shipmentInstructions": "Leave at back door",
            "shipmentStatus": "Delivered"
        }
    ],
    "orderReference": "<string>",
    "statusLog": "Order has been cancelled",
    "customerAccountId": "5e3598e3007c5e00080d2bb8",
    "customerEmail": "jsmith@example.com",
    "notes": "<string>",
    "tags": ["tag100", "tag101"],
    "events": [
        {
            "status": "ORDER_CREATED",
            "data": {}
        }
    ]
}
headers = {
    "x-site-context": "<x-site-context>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

JavaScript Fetch Example

const options = {
  method: 'POST',
  headers: {'x-site-context': '<x-site-context>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    cartId: '5e4876e10cfe1d8902005d33',
    channel: 11,
    orderTotal: 125.99,
    taxTotal: 5.23,
    orderCurrency: 'USD',
    status: 'ORDER_CREATED',
    customerUserId: '5e3598e3007c5e00080d2bb8',
    shipTo: [
      {
        shipToId: 1000001,
        shipToType: 'SHIP_TO_ADDRESS',
        price: 24.87,
        currency: 'USD',
        estimatedTax: 10.25,
        committedTax: 10.25,
        promosApplied: [{}],
        total: 1,
        taxCode: 'FR020000',
        shipmentCarrier: 'Fedex',
        shipmentMethod: 'Express',
        shipmentMethodId: '10000001',
        promisedDeliveryDate: '2019-12-14',
        shipmentInstructions: 'Leave at back door',
        shipmentStatus: 'Delivered'
      }
    ],
    orderReference: '<string>',
    statusLog: 'Order has been cancelled',
    customerAccountId: '5e3598e3007c5e00080d2bb8',
    customerEmail: 'jsmith@example.com',
    notes: '<string>',
    tags: ['tag100', 'tag101'],
    events: [{status: 'ORDER_CREATED', data: {}}]
  })
};

fetch('https://prod01-apigw.yourcompany.fabric.zone/api-order/subscriptions/orders', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));