> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sibipro.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create draft order

# `OrderingMutation.createDraftOrder()`

The Draft Order API allows you to create a draft order that can be used to validate an order and create a reference for the order that can later be used to place the order.

```graphql theme={null}
type OrderingMutation {
  createDraftOrder(input: OrderingCreateDraftOrderInput!): OrderingDraftOrder!
}
```

### `OrderingCreateDraftOrderInput`

The input is the same as the [`OrderingMutation.createOrder()`](/graphql/ordering/create-order) API except that the `paymentMethodId` is optional and it does not take an `idempotencyKey`.

```graphql theme={null}
input OrderingCreateDraftOrderInput @tag(name: "public") {
  manufacturer: String!
  address: OrderingAddressInput!
  products: [OrderingOrderProductInput!]!
  contactInfo: OrderingCustomerContactInfoInput!
  fulfillmentMethodId: String
  fulfillmentMethodType: OrderingFulfillmentMethodType
  shipToOfficePropertyId: String
  requestedDeliveryDate: String
  poNumber: String
  specialInstructions: String
  distributionCenterId: String
  paymentMethodId: String
  subscribers: [OrderingOrderSubscriberInput!]
}
```

### `manufacturer`

`string` - The manufacturer of the products in the order.

***

### `address`

[`OrderingAddressInput`](/graphql/ordering/ordering-address) - The address should correspond to a valid property in the system. If there is no matching property and the address is valid, a new property will be created. If the address is not valid, the mutation will fail with an error.

***

### `products`

[`OrderingOrderProductInput[]`](/graphql/ordering/ordering-order-product-input) - An array of order products. At least one product must be specified.

***

### `contactInfo`

[`OrderingCustomerContactInfoInput`](/graphql/ordering/ordering-customer-contact-info-input) - Information about how to contact the customer. This information is what the delivery agent will use to contact the customer if there is an issue with the order.

***

### `fulfillmentMethodId`

`string | null` - The ID of a specific fulfillment method to use. Pass the `id` from one of the `availableFulfillmentMethods` returned by [`reviewOrder`](/graphql/ordering/review-order). Cannot be specified together with `fulfillmentMethodType`.

When not provided, the API will automatically select a fulfillment method using this logic:

1. If the distributor has a configured default for the resolved type, that default is used.
2. Otherwise, the first available method for the resolved type is used.

We recommend calling [`reviewOrder`](/graphql/ordering/review-order) first to discover `availableFulfillmentMethods`, then passing the desired `id` explicitly.

***

### `fulfillmentMethodType`

`OrderingFulfillmentMethodType | null` - The type of fulfillment method to use. Defaults to `DELIVERY` if neither `fulfillmentMethodId` nor `fulfillmentMethodType` is provided. If the distributor only has pickup available, it will fall back to `PICKUP`. Cannot be specified together with `fulfillmentMethodId`.

***

### `shipToOfficePropertyId`

`string` - The property id of the office to ship the order to. Is only valid to be provied if the fulfillmentMethodId is `ship-to-office`. If the id is provided when the fulfillmentMethodId is not `ship-to-office`, the mutation will fail with an error. If the fulfillmentMethodId is `ship-to-office` and this value is not provided, the mutation will fail with an error.

***

### `requestedDeliveryDate`

`string` - The date the customer wants the order delivered. If not provided, defaults to the earliest available. If the provided date is not available, the mutation will fail with an error.

***

### `poNumber`

`string` - The purchase order number for the order. Can be anything you want. It doesn't even need to be a number.

***

### `specialInstructions`

`string` - The special instructions for fulfilling the order. E.g. "the lock code is 1234".

***

### `distributionCenterId`

`string` - The ID of the distribution center to place the order in. If not provided, the order will be placed in the closest distribution center to the provided address that has the product available.

***

### `paymentMethodId`

`string` - The ID of the payment method to use for the order. If not provided, defaults to the default first payment method for the user. If multiple payment methods are available, it is recommended to request the `paymentMethodId` in the response to the createDraftOrder mutation so that you can confirm the correct one was selected. If you need to see which payment methods are available, you can use the `availablePaymentMethods` field on the `OrderingDraftOrder` type. Note that you will need to create a new draft order to change the payment method.

***

### `subscribers`

`OrderingOrderSubscriberInput[]` - An optional list of subscribers to receive updates about the order in addition to the user account that placed the order. If the email is not formatted correctly, the mutation will fail with an error. If at least one subscriber is provided, then only email addresses specified in the subscribers will receive automatic email updates when the order created from this draft is updated. If no subscribers are provided, then the platform will send email updates to the user account that placed the order as well as the email addresses specified in the contactInfo field, but only if it doesn't match the email address of the primary resident at the property the order is placed for.

***

## Response

### `OrderingDraftOrder`

[`OrderingDraftOrder`](#orderingdraftorder) - The draft order that was created.

The `OrderingDraftOrder` type is the same as the `OrderingReviewOrderResponse` type, but with an additional `id` field that can be used to retrieve the draft order and to place an order based on it.

```graphql theme={null}
type OrderingDraftOrder {
  id: ID!
  address: OrderingAddress!
  manufacturer: String!
  createdAt: String!
  orderId: String
  orderInSibiStoreUrl: String
  products: [OrderingOrderProduct!]!
  contactInfo: OrderingCustomerContactInfo
  distributionCenter: OrderingDistributionCenter!
  taxCents: Int!
  subtotalCents: Int!
  totalPriceCents: Int!
  fees: [OrderingFee!]!
  discounts: [OrderingDiscount!]!
  poNumber: String
  specialInstructions: String
  fulfillmentMethod: OrderingFulfillmentMethod!
  requestedDeliveryDate: String!
  paymentMethodId: String!
  availablePaymentMethods: [OrderingPaymentMethod!]!
  availableFulfillmentMethods: [OrderingFulfillmentMethod!]!
  subscribers: [OrderingOrderSubscriber!]!
}
```

***

### `id`

`string` - The ID of the draft order. This ID can be used to retrieve the draft order and to place an order based on it.

***

### `address`

`OrderingAddress` - The property address associated with the order. If the fulfillmentMethod is `DELIVERY`, this is the address the order will be shipped to.

***

### `manufacturer`

`string` - The manufacturer associated with the draft order.

***

### `createdAt`

`string` - The timestamp when the draft order was created.

***

### `orderId`

`string | undefined` - The ID of the order that was created from this draft order, if one has been placed.

***

### `orderInSibiStoreUrl`

`string | undefined` - A URL to view the order in the SIBI store, if an order has been placed from this draft.

***

### `products`

[`OrderingOrderProduct[]`](/graphql/ordering/ordering-order-product) - An array of order products.

***

### `contactInfo`

`OrderingCustomerContactInfo | undefined` - The contact information that was passed in. Has all the same properties as [`OrderingCustomerContactInfoInput`](/graphql/ordering/ordering-customer-contact-info-input).

### `distributionCenter`

[`OrderingDistributionCenter`](#orderingdistributioncenter) - The distribution center where the order will be placed.

***

### `taxCents`

`number` - The total tax amount for the order, in cents.

***

### `subtotalCents`

`number` - The subtotal for the order, in cents.

***

### `totalPriceCents`

`number` - The total price for the order, in cents. This is the sum of the subtotal and tax.

***

### `fees`

[`OrderingFee[]`](/graphql/ordering/review-order#orderingfee) - An array of fees applied to the order.

***

### `discounts`

[`OrderingDiscount[]`](/graphql/ordering/review-order#orderingdiscount) - An array of discounts applied to the order.

***

### `poNumber`

`string | undefined` - The purchase order number that was passed in.

***

### `specialInstructions`

`string | undefined` - The special instructions that were passed in.

***

### `fulfillmentMethod`

`OrderingFulfillmentMethod` - One of `DELIVERY` or `PICKUP`. This is the fulfillment method that will be used for the order. Will always return a valid value for the order. If an invalid fulfillment method was passed to `reviewOrder()`, the query will fail with an error.

***

### `requestedDeliveryDate`

`string` - The requested delivery date for the order. The value returned will be a valid delivery date for the product & distribution center. If an invalid delivery date was passed to `revierOrder()`, the query will fail with an error.

***

### `availableDeliveryDates`

`string[]` - An array of available delivery dates for the order. The array will always contain at least one value. If there are no available delivery dates, the query will fail with an error.

***

### `paymentMethodId`

`string` - The ID of the payment method that will be used for the order. If no payment method was passed to `reviewOrder()`, the API will pick a value from \`availablePaymentMethods\`\` and return a sensible default.

***

### `availablePaymentMethods`

[`OrderingPaymentMethod[]`](#orderingpaymentmethod) - An array of available payment methods for the order. The array will always contain at least one value. If there are no available payment methods, the query will fail with an error.

***

### `availableFulfillmentMethods`

[`OrderingFulfillmentMethod[]`](#orderingfulfillmentmethod) - An array of available fulfillment methods for the order.

***

### `subscribers`

`OrderingOrderSubscriber[]` - An array of subscribers that will receive updates about the order.

***

## `OrderingOrderSubscriber`

```graphql theme={null}
type OrderingOrderSubscriber {
  email: String!
}
```

***

## `OrderingAddress`

```graphql theme={null}
type OrderingAddress {
  line1: String!
  line2: String
  city: String!
  stateOrProvince: String!
  postalCode: String!
  country: String
}
```

Both line2 and country are optional. All other fields are required. `reviewOrder` will only return a valid addresses for properties registered with SIBI. If an invalid address is passed to `reviewOrder()`, the query will fail with an error.

***

## `OrderingDistributionCenter`

```graphql theme={null}
type OrderingDistributionCenter {
  id: ID!
  name: String!
  latitude: Float
  longitude: Float
  address: OrderingAddress!
  imageUrl: String
  storeNumber: String!
}
```

### `id`

`string` - The distribution center's unique identifier. Use this when placing orders at a specific DC.

***

### `name`

`string` - The name of the distribution center.

***

### `latitude`

`number | undefined` - The latitude of the distribution center's location.

***

### `longitude`

`number | undefined` - The longitude of the distribution center's location.

***

### `address`

[`OrderingAddress`](#orderingaddress) - The address of the distribution center.

***

### `imageUrl`

`string | undefined` - The URL of the distribution center's logo.

***

### `storeNumber`

`string` - The store number of the distribution center. May not actually be numeric.

***

### `fulfillmentMethods`

[`OrderingFulfillmentMethod[]`](#orderingfulfillmentmethod) - An array of fulfillment methods that are available for the distribution center.

***

## `OrderingFulfillmentMethod`

```graphql theme={null}
type OrderingFulfillmentMethod {
  id: String!
  title: String!
  description: String
  type: OrderingFulfillmentMethodType!
  dates: [String!]!
}

enum OrderingFulfillmentMethodType {
  DELIVERY
  PICKUP
}
```

### `id`

`string` - The unique identifier for the fulfillment method. Use this when placing orders with a specific fulfillment method.

***

### `title`

`string` - The human-readable title of the fulfillment method.

***

### `description`

`string | undefined` - An optional description providing additional details about the fulfillment method.

***

### `type`

`OrderingFulfillmentMethodType` - The type of fulfillment method. Either `DELIVERY` or `PICKUP`.

***

### `dates`

`string[]` - An array of available dates for this fulfillment method.

***

## `OrderingPaymentMethod`

```graphql theme={null}
union OrderingPaymentMethod = OrderingPaymentMethodManufacturerCredit | OrderingPaymentMethodStripe

type OrderingPaymentMethodManufacturerCredit {
  id: String!
  description: String!
}

type OrderingPaymentMethodStripe {
  id: String!
  description: String!
  last4: String!
}
```

These are the two possible payment methods that can be returned by `reviewOrder()`. The `id` and `description` fields are always returned. The `last4` field is only returned for `OrderingPaymentMethodStripe`.

***

### `id`

`string` - The ID of the payment method.

***

### `description`

`string` - A human-readable description of the payment method.

***

### `last4`

`string` - The last 4 digits of the credit card number. Only returned for `OrderingPaymentMethodStripe`.
