# Creating Orders

To create, list, modify or delete orders you have to use the following endpoints:

Endpoint Description
GET /orders (opens new window) Returns all of your orders
GET /orders/{order_id} (opens new window) Returns the order with the provided order_id
POST /orders (opens new window) Creates a new order
PATCH /orders/{order_id} (opens new window) Modifies the order with the provided order_id.

Orders can only be modified before placing the order.
DELETE /orders/{order_id} (opens new window) Deletes the order with the provided order_id.

Orders can only be deleted when they are still in draft state

# Order Attributes

Attribute Required Description
contract_id This is the only required field.

You need to provide the contract_id belonging to the contract with the Supplier you want to order from.
exclusive_sales_group_id If you want to order from a exclusive sales group, you need to provide the respective id of the SalesGroup here.

By default the order will use all available non-exclusive SalesGroups that the Supplier assigned to your Organization.
delivery_mode Either complete or splitted.

Default value: complete
references If you want, you can add additional references here, e.g. an internal order number.

By default it will include the Zaikio Procurement OrderId as the first element.
state_event By default an order will be created within the draft state. If you want to create and place an order at the same time, you need to provide this attributes with a value of place.
deliveries_attributes Here you can already provide delivery information if known and they will be added to the order.

You can also add these later unless you also want to place the order at creation time.

By default no delivery will be added automatically.
order_line_items_attributes Same as with the deliveries_attributes, you can already add OrderLineItems if known.

You can also add these later unless you also want to place the order at creation time.

By default no order line items will be added automatically.

# Best practices

  • By default we suggest to first create a draft order and fill it with the desired OrderLineItems as well as adding necessary Deliveries. Before actually placing the order you should double check the order values and prices as they might be dependent on factors like the delivery location or order quantities.

# Example

The following request will create a draft order with the following criteria:

  • Supplier should be Smith Papers, contract_id: ed2631a2-630c-563a-b433-c51faa3ac016
  • Delivery address is: Print Street 1, 55155 Print-Town
  • Desired delivery date is: 2021-05-10
  • We want to order 15 times the SKU with the id 7eae8749-6945-5095-9fe9-40ca1f6d9524

# Request

POST /orders

Body:
{
  "order": {
    "contract_id": "ed2631a2-630c-563a-b433-c51faa3ac016",
    "delivery_mode": "complete",
    "deliveries_attributes": [
      {
        "address_addressee": "Test Printery",
        "address_text": "Print Street 1, 55155 Print-Town",
        "desired_delivery_date": "2021-05-10"
      }
    ],
    "order_line_items_attributes": [
      {
        "sku_id": "7eae8749-6945-5095-9fe9-40ca1f6d9524",
        "amount": 15
      }
    ]
  }
}

# Response

{
  "id": "87c96a58-ebe3-409a-bbc1-4e0c464213a6",
  "canceled_by_consumer_at": null,
  "canceled_by_supplier_at": null,
  "cancelation_requested_at": null,
  "confirmed_at": null,
  "currency": "EUR",
  "delivery_mode": "complete",
  "gross_total": "0.0",
  "net_handling_fee": null,
  "net_shipping_fee": null,
  "net_total": "6445.3",
  "partially_shipped_at": null,
  "partially_shipped_remainder_canceled_at": null,
  "placed_at": "2021-04-14T13:38:25.024Z",
  "producing_at": null,
  "references": [
    "CO/S33EMV"
  ],
  "shipped_at": null,
  "state": "draft",
  "state_reason": null,
  "taxes": "0.0",
  "taxes_on_fees": null,
  "transfer_failed_at": null,
  "transferred_at": null,
  "created_at": "2021-04-14T13:38:25.074Z",
  "updated_at": "2021-04-14T13:38:25.074Z",
  "contract_id": "ed2631a2-630c-563a-b433-c51faa3ac016",
  "contract": {
    "id": "ed2631a2-630c-563a-b433-c51faa3ac016",
    "customer_number": "DPS-12345",
    "references": [
      "CR/131DER"
    ],
    "links": [
      {
        "rel": "self",
        "href": "/consumers/api/v1/contracts/ed2631a2-630c-563a-b433-c51faa3ac016"
      }
    ]
  },
  "exclusive_sales_group_id": "ea237884-228a-5311-8b35-d3666cc44b3b",
  "exclusive_sales_group": {
    "id": "ea237884-228a-5311-8b35-d3666cc44b3b",
    "name": "Smith Papers Exclusive Catalog",
    "links": [
      {
        "rel": "self",
        "href": "/consumers/api/v1/sales_groups/ea237884-228a-5311-8b35-d3666cc44b3b"
      }
    ]
  },
  "person_id": null,
  "person": {
    "id": null,
    "display_name": null,
    "links": [
      {
        "rel": "self",
        "href": null
      }
    ]
  },
  "order_line_items": [
    {
      "id": "e015885a-b2bc-4ea5-b38a-faa5f69afc88",
      "order_id": "87c96a58-ebe3-409a-bbc1-4e0c464213a6",
      "sku_id": "7eae8749-6945-5095-9fe9-40ca1f6d9524",
      "references": [
        "COL/QSZT83"
      ],
      "amount": 15,
      "amount_in_base_unit": 127500,
      "base_unit": "sheet",
      "confirmed_delivery_at": null,
      "description": "SMITH VOLUME PAPER – PS1 - Premium Coated, 920 × 650 mm, 115 g/㎡, short – 1 pallet, 584.545 kg",
      "order_number": "MAGVOL|115|92.0|65.0|0250|008500||S|PL||v1",
      "tax_rate": null,
      "taxes": null,
      "total_gross_price": null,
      "total_net_price": "6045.3",
      "unit": "pallet",
      "created_at": "2021-04-14T13:38:25.103Z",
      "updated_at": "2021-04-14T13:38:25.103Z",
      "catalog_price": "403.02",
      "confirmed_price": null,
      "order": {
        "id": "87c96a58-ebe3-409a-bbc1-4e0c464213a6",
        "references": [
          "CO/S33EMV"
        ],
        "links": [
          {
            "rel": "self",
            "href": "/consumers/api/v1/orders/87c96a58-ebe3-409a-bbc1-4e0c464213a6"
          }
        ]
      },
      "sku": {
        "id": "7eae8749-6945-5095-9fe9-40ca1f6d9524",
        "order_number": "MAGVOL|115|92.0|65.0|0250|008500||S|PL||v1",
        "links": [
          {
            "rel": "self",
            "href": "/consumers/api/v1/skus/7eae8749-6945-5095-9fe9-40ca1f6d9524"
          }
        ]
      }
    }
  ]
}