### Overview

In order to create new purchase order, you can consume the endpoint presented in this article. In order to consume it, you must:

- Be authenticated user

For information on how you can authenticate, see: [Authentication](https://developer.sellercloud.com/dev-article/authentication/)

As soon as you do authentication and receive a valid token, it needs to be passed to the service call.

### Endpoint

Example for such endpoint for **TT** server is:

https://tt.api.sellercloud.com/rest/api/PurchaseOrders

For your server endpoint will be:

https://{your\_server\_id}.api.sellercloud.com/rest/api/PurchaseOrders

### Request

Information about expected request parameters can be found on swagger UI [https://tt/api.sellercloud.com/rest/swagger](https://tt/api.sellercloud.com/rest/swagger).

- Method Type: **HttpPost**
- Authorization: Use **Bearer Token** (where ‘Token’ is the token received from token authentication)
- Header info: **Content-Type: application/json**
- Request Body:

```
{
  "CompanyID": 0,
  "VendorID": 0,
  "POType": "PurchaseOrder",
  "CaseQtyMode": true,
  "DefaultWarehouseID": 0,
  "Description": "string",
  "VendorNote": "string",
  "PaymentTermID": 0,
  "ExpectedDeliveryDate": "2020-05-25T21:58:33.197Z",
  "Products": [
    {
      "ProductID": "string",
      "QtyUnitsOrdered": 0,
      "UnitPrice": 0,
      "QtyCasesOrdered": 0,
      "QtyUnitsPerCase": 0,
      "CasePrice": 0,
      "DiscountType": "FixedAmount",
      "DiscountValue": 0,
      "WarehouseID": 0,
      "ItemNotes": ""
    }
  ],
  "BillingAddress": {
    "FirstName": "string",
    "LastName": "string",
    "MiddleName": "string",
    "ZipCode": "string",
    "City": "string",
    "Country": "string",
    "Business": "string",
    "AddressLine1": "string",
    "AddressLine2": "string",
    "Fax": "string",
    "Region": "string",
    "State": "string",
    "Phone": "string"
  },
  "ShippingAddress": {
    "FirstName": "string",
    "LastName": "string",
    "MiddleName": "string",
    "ZipCode": "string",
    "City": "string",
    "Country": "string",
    "Business": "string",
    "AddressLine1": "string",
    "AddressLine2": "string",
    "Fax": "string",
    "Region": "string",
    "State": "string",
    "Phone": "string"
  }
}
```

|     |     |     |     |
| --- | --- | --- | --- |
| **Parameter** | **Data Type** | **Description** | **Is Required** |
| CompanyID | integer | PO company ID | true |
| VendorID | integer | PO vendor ID | true |
| POType | enum | PO type.<br>Possible values can be found [here.](https://developer.sellercloud.com/dev-article/po-type/) | true |
| CaseQtyMode | bool | PO case quantity mode. | true |
| DefaultWarehouseID | integer | PO warehouse ID.<br>If provided this warehouse will be set for the PO and for all PO products.<br>Set to null or omit in the request if not needed. | false |
| Description | string | PO description<br>Set to null or omit in the request if not needed. | false |
| VendorNote | string | PO vendor note<br>Set to null or omit in the request if not needed. | false |
| PaymentTermID | int | Payment term ID.<br>Possible values can be obtained using [this endpoint.](https://developer.sellercloud.com/dev-article/get-payment-terms/)<br>Set to null or omit in the request if not needed. | false |
| ExpectedDeliveryDate | date | PO expected delivery date. Should only be provided if client setting ‘Force user to enter Expected Delivery Date’ is enabled.<br>Set to null or omit in the request if not needed. | false |
| Products | List | List with PO product items | true |
| Product.ProductID | string | Product ID | true |
| Product.QtyUnitsOrdered | integer | Quantity of ordered units of this product.<br>Should only be set if case quantity mode is set to false.<br>Set to null or omit in the request if not needed.<br>Should be greater than 0. | false |
| Product.UnitPrice | decimal | Unit price.<br>Should only be set if case quantity mode is set to false.<br>Cannot be negative. | false |
| Product.QtyCasesOrdered | integer | Quantity of ordered cases with this product.<br>Should only be set if case quantity mode is set to true.<br>Set to null or omit in the request if not needed.<br>Should be greater than 0. | false |
| Product.QtyUnitsPerCase | integer | Quantity of unites per case for this product.<br>Should only be set if case quantity mode is set to true.<br>Set to null or omit in the request if not needed.<br>Should be greater than 0. | false |
| Product.CasePrice | decimal | Price per case for this product.<br>Should only be set if case quantity mode is set to true.<br>Set to null or omit in the request if not needed.<br>Cannot be negative. | false |
| Product.DiscountType | enum | Product discount type.<br>Possible values can be found [here.](https://developer.sellercloud.com/dev-article/discount-type/)<br>Can only be provided if client setting ‘Enable Multi Discount for Purchase Order’ is disabled.<br>Set to null or omit in the request if not needed. | false |
| Product.DiscountValue | decimal | Product discount value.<br>Can only be provided if client setting ‘Enable Multi Discount for Purchase Order’ is disabled.<br>Set to null or omit in the request if not needed. | false |
| Product.ItemNotes | string | Add item notes on PO Item level | false |
| Product.BillingAddress | Address | PO billing address.<br>Can only be provided if client setting ‘Enable BillTo address for Purchase Orders’ is enabled.<br>Set to null or omit in the request if not needed. | false |
| Product.ShippingAddress | Address | PO shipping address<br>Set to null or omit in the request if not needed. | false |
| Address.FirstName | string | First name | false |
| Address.LastName | string | Last name | false |
| Address.MiddleName | string | Middle name | false |
| Address.ZipCode | string | Zip code | false |
| Address.City | string | City | false |
| Address.Country | string | Two letter country code | true |
| Address.Business | string | Business name | false |
| Address.AddressLine1 | string | Address line 1 | false |
| Address.AddressLine2 | string | Address line 2 | false |
| Address.Fax | string | Fax | false |
| Address.Region | string | Region | false |
| Address.State | string | State | false |
| Adress.Phone | string | Phone | false |

### Response

- If user is authenticated and create purchase order is successful, then response will be **Status Code 200 => OK** and ID of the created purchase order is returned.
- If user is not authenticated, then response will be **Status Code 401 => Not Valid Token**
- In case of error, response will be **Status Code 500 => Internal Server Error**
