# Order Resource

Order resources are read-only by default.

### Attention

Order resources are read-only by default. Please contact us for access.

## Order Statuses

| Order Status  | English  | German  |
|---|---|---|
| open  | new order  | Neue Bestellung  |
| in_progress  | in progress, started processing  | Bearbeitung begonnen  |
| cancelled  | order was cancelled  | Bestellung storniert  |
| closed  | order is sent and paid  | Versendet und bezahlt  |
| returned  | order was returned to seller  | Bestellung retourniert  |

---

## Get Orders

GET /api/orders.json

- **GET /api/orders.json** will return the first 150 (default limit) orders. You can increase the limit to a maximum of 250 orders. See the [Filter Orders](#filter-orders) endpoint for more info.

**Example:**

```bash
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X GET \Status: 200 OK
https://shop_subdomain.versacommerce.de/api/orders.json
```

```
Status: 200 OK
[
  {
    "order": {
      "bank_account_bank_code": null,
      "bank_account_bank_name": null,
      "bank_account_name": null,
      "bank_account_number": null,
      "checkout_locale": "de",
      "code": "196-083-565",
      "coupon_code": null,
      "coupon_value": "0.0",
      "created_at": "2013-03-19T12 =>39 =>51+01 =>00",
      "currency": "€",
      "customer_email": "max.mustermann@example.com",
      "customer_id": 1000,
      "discount_total": "0.0",
      "external_invoicing_id": null,
      "id": 100,
      "item_total": "8.49",
      "items_count": 1,
      "items_status": "undelivered",
      "note": "Lorem ipsum dolor sit amet...",
      "payment_cost": "2.5",
      "payment_status": "not_paid",
      "payment_tax_rate": 19,
      "payment_type": "cod",
      "payments_count": 0,
      "prices_include_tax": true,
      "reduced_tax_amount": "0.0",
      "reduced_tax_rate": 7,
      "reduced_tax_total": "0.0",
      "referrer": "/",
      "shipments_count": 0,
      "shipping_cost": "4.95",
      "shop_id": 953,
      "source": null,
      "standard_tax_amount": "2.55",
      "standard_tax_rate": 19,
      "standard_tax_total": "15.94",
      "status": "canceled",
      "subtotal": "15.94",
      "total": "15.94",
      "weight_total": 0,
      "shipping_address": {
        "category": "shipping",
        "city": "Musterstadt",
        "company": "Musterfirma GmbH",
        "country": "DE",
        "customer_id": 1000,
        "email": "max.mustermann@example.com",
        "extension": "",
        "firstname": "Max",
        "id": 10000,
        "lastname": "Mustermann",
        "locked": true,
        "option_01": "",
        "option_02": "",
        "option_03": "",
        "order_id": 100,
        "phone": "+49 123 4567890",
        "state": "unbekannt",
        "street": "Musterstraße",
        "streetnumber": "1a",
        "title": "Herr",
        "zipcode": "12345"
      },
      "billing_address": {
        "category": "billing",
        "city": "Musterstadt",
        "company": "Musterfirma GmbH",
        "country": "DE",
        "customer_id": 1000,
        "email": "max.mustermann@example.com",
        "extension": "",
        "firstname": "Max",
        "id": 10001,
        "lastname": "Mustermann",
        "locked": true,
        "option_01": "",
        "option_02": "",
        "option_03": "",
        "order_id": 100,
        "phone": "+49 123 4567890",
        "state": "unbekannt",
        "street": "Musterstraße",
        "streetnumber": "1a",
        "title": "Herr",
        "zipcode": "12345"
      },
      "customer": {
        "accepts_newsletter": false,
        "account_confirmation_sent": false,
        "active": true,
        "birthday": null,
        "created_on": "2012-11-09",
        "email": "max.mustermann@example.com",
        "id": 1000,
        "note": null,
        "option_01": "",
        "option_02": "",
        "option_03": "",
        "option_04": "",
        "registered": true,
        "shop_id": 953,
        "updated_on": "2012-11-09"
      }
    }
  },
  {
    "order": {
      "bank_account_bank_code": null,
      "bank_account_bank_name": null,
      "bank_account_name": null,
      "bank_account_number": null,
      "checkout_locale": "de",
      "code": "196-083-545",
      "coupon_code": null,
      "coupon_value": "0.0",
      "created_at": "2013-03-19T12 =>41 =>47+01 =>00",
      "currency": "€",
      "customer_email": "max.mustermann@example.com",
      "customer_id": 11461,
      "discount_total": "0.0",
      "external_invoicing_id": null,
      "id": 101,
      "item_total": "90.0",
      "items_count": 1,
      "items_status": "undelivered",
      "note": "Lorem ipsum dolor sit amet...",
      "payment_cost": "2.5",
      "payment_status": "not_paid",
      "payment_tax_rate": 19,
      "payment_type": "cod",
      "payments_count": 0,
      "prices_include_tax": true,
      "reduced_tax_amount": "0.0",
      "reduced_tax_rate": 7,
      "reduced_tax_total": "0.0",
      "referrer": "/",
      "shipments_count": 0,
      "shipping_cost": "4.95",
      "shop_id": 953,
      "source": null,
      "standard_tax_amount": "15.56",
      "standard_tax_rate": 19,
      "standard_tax_total": "97.45",
      "status": "canceled",
      "subtotal": "97.45",
      "total": "97.45",
      "weight_total": 0,
      "shipping_address": {
        "category": "shipping",
        "city": "Musterstadt",
        "company": "Musterfirma GmbH",
        "country": "DE",
        "customer_id": 1000,
        "email": "max.mustermann@example.com",
        "extension": "",
        "firstname": "Max",
        "id": 10002,
        "lastname": "Mustermann",
        "locked": true,
        "option_01": "",
        "option_02": "",
        "option_03": "",
        "order_id": 101,
        "phone": "+49 123 4567890",
        "state": "unbekannt",
        "street": "Musterstraße",
        "streetnumber": "1a",
        "title": "Herr",
        "zipcode": "12345"
      },
      "billing_address": {
        "category": "billing",
        "city": "Musterstadt",
        "company": "Musterfirma GmbH",
        "country": "DE",
        "customer_id": 1000,
        "email": "max.mustermann@example.com",
        "extension": "",
        "firstname": "Max",
        "id": 10003,
        "lastname": "Mustermann",
        "locked": true,
        "option_01": "",
        "option_02": "",
        "option_03": "",
        "order_id": 101,
        "phone": "+49 123 4567890",
        "state": "unbekannt",
        "street": "Musterstraße",
        "streetnumber": "1a",
        "title": "Herr",
        "zipcode": "12345"
      },
      "customer": {
        "accepts_newsletter": false,
        "account_confirmation_sent": false,
        "active": true,
        "birthday": null,
        "created_on": "2012-11-09",
        "email": "max.mustermann@example.com",
        "id": 1000,
        "note": null,
        "option_01": "",
        "option_02": "",
        "option_03": "",
        "option_04": "",
        "registered": true,
        "shop_id": 953,
        "updated_on": "2012-11-09"
      }
    }
  }
]
```

---

## Get Order

GET /api/orders/:order_id.json

- **GET /api/orders/:order_id.json** will return the specified order.

**Example:**

```bash
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X GET \
https://shop_subdomain.versacommerce.de/api/orders/:order_id.json
```

```
Status: 200 OK

{
  "order": {
    "bank_account_bank_code": null,
    "bank_account_bank_name": null,
    "bank_account_name": null,
    "bank_account_number": null,
    "checkout_locale": "de",
    "code": "196-083-565",
    "coupon_code": null,
    "coupon_value": "0.0",
    "created_at": "2013-03-19T12 =>39 =>51+01 =>00",
    "currency": "€",
    "customer_email": "max.mustermann@example.com",
    "customer_id": 1000,
    "discount_total": "0.0",
    "external_invoicing_id": null,
    "id": 100,
    "item_total": "8.49",
    "items_count": 1,
    "items_status": "undelivered",
    "note": "Lorem ipsum dolor sit amet...",
    "payment_cost": "2.5",
    "payment_status": "not_paid",
    "payment_tax_rate": 19,
    "payment_type": "cod",
    "payments_count": 0,
    "prices_include_tax": true,
    "reduced_tax_amount": "0.0",
    "reduced_tax_rate": 7,
    "reduced_tax_total": "0.0",
    "referrer": "/",
    "shipments_count": 0,
    "shipping_cost": "4.95",
    "shop_id": 953,
    "source": null,
    "standard_tax_amount": "2.55",
    "standard_tax_rate": 19,
    "standard_tax_total": "15.94",
    "status": "canceled",
    "subtotal": "15.94",
    "total": "15.94",
    "weight_total": 0,
    "shipping_address": {
      "category": "shipping",
      "city": "Musterstadt",
      "company": "Musterfirma GmbH",
      "country": "DE",
      "customer_id": 1000,
      "email": "max.mustermann@example.com",
      "extension": "",
      "firstname": "Max",
      "id": 10000,
      "lastname": "Mustermann",
      "locked": true,
      "option_01": "",
      "option_02": "",
      "option_03": "",
      "order_id": 100,
      "phone": "+49 123 4567890",
      "state": "unbekannt",
      "street": "Musterstraße",
      "streetnumber": "1a",
      "title": "Herr",
      "zipcode": "12345"
    },
    "billing_address": {
      "category": "billing",
      "city": "Musterstadt",
      "company": "Musterfirma GmbH",
      "country": "DE",
      "customer_id": 1000,
      "email": "max.mustermann@example.com",
      "extension": "",
      "firstname": "Max",
      "id": 10001,
      "lastname": "Mustermann",
      "locked": true,
      "option_01": "",
      "option_02": "",
      "option_03": "",
      "order_id": 100,
      "phone": "+49 123 4567890",
      "state": "unbekannt",
      "street": "Musterstraße",
      "streetnumber": "1a",
      "title": "Herr",
      "zipcode": "12345"
    },
    "customer": {
      "accepts_newsletter": false,
      "account_confirmation_sent": false,
      "active": true,
      "birthday": null,
      "created_on": "2012-11-09",
      "email": "max.mustermann@example.com",
      "id": 1000,
      "note": null,
      "option_01": "",
      "option_02": "",
      "option_03": "",
      "option_04": "",
      "registered": true,
      "shop_id": 953,
      "updated_on": "2012-11-09"
    }
  }
}
```

---

## Get Orders Count

GET /api/orders/count.json

- GET /api/orders/count.json will return the orders count.

**Example:**

```bash
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X GET \
https://shop_subdomain.versacommerce.de/api/orders/count.json
```

```
Status: 200 OK

{
  "count": 117
}
```

---

## Filter Orders

GET /api/orders.json?filter_name1=filter_value1&filter_name2=filter_value2

- **GET /api/orders.json?filter_name_1=filter_value_1&filter_name_2=filter_value_2** will return a filtered list of orders. See the [Get Orders](#get-orders) endpoint for more info about the output.

**Available Filters and Options**

| Filter-/Optionname | Description | Type | Parameter |
|---|---|---|---|
| limit | The amount of results, defaults to 150, maximum are 250 | Integer | limit=10 |
| offset | The amount of results to omit | Integer | offset=10 |
| include | Include one or more order associations (format: items, shipments, payments, histories, …) | String | include=items |
| coupon_value | Filter by coupon_value | String | coupon_value=10.0 |
| code | Filter by order number (Order number is unique, so the result is always a single order) | String | code=012-345-678 |
| items_status | Filter by items_status | String | items_status=undelivered |
| status | Filter by order status | String | status=open |
| payment_status | Filter by payment_status | String | payment_status=not_paid |
| payment_type | Filter by payment_type | String | payment_type=cod |
| shipping_type | Filter by shipping_type | String | shipping_type= shipping_type |
| external_invoicing_id | Filter by external_invoicing_id | String | external_invoicing_id=q1 |
| note | Filter by note | String | note=content |
| subtotal | Filter by subtotal | BigDecimal | subtotal=100.0 |
| total | Filter by total | BigDecimal | total=100.0 |
| id_min | Filter orders by the minimum id | Integer | id_min=10 |
| id_max | Filter orders by the maximum id | Integer | id_max=10 |
| total_min | Filter orders by the minimum total | BigDecimal | total_min=100.0 |
| total_max | Filter orders by the maximum total | BigDecimal | total_max=100.0 |
| coupon_value_min | Filter orders by the minimum coupon value | BigDecimal | coupon_value_min=10.0 |
| coupon_value_max | Filter orders by the maximum coupon value | BigDecimal | coupon_value_max=10.0 |
| created_at_min | Filter to show orders created after date | DateTime | created_at_min= 2019-12-31 |
| created_at_max | Filter to show orders created before date | DateTime | created_at_max= 2019-12-31 |

- **GET /api/orders.json?include=items** will return all orders and order items (nested). See the [Get Orders](https://developer.versacommerce.de/articles/order-resource) endpoint for more info about the output.

Example:

```
Example:
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X GET \
https://shop_subdomain.versacommerce.de/api/orders.json?include=items
```

```
Status: 200 OK

[
  {
    "order": {
      "code": "199-187-329",
      "id": 100,
      "items_count": 2,
      ...
      "items": [{
          "id": 1000,
          "order_id": 100,
          "product_id": 10000,
          "quantity": 5,
          ...
        },
        {
          "id": 1001,
          "order_id": 100,
          "product_id": 10001,
          "quantity": 1,
          ...
        }
      ],
      ...
    }
  }, {
    "order": {
      "code": "199-267-382",
      "id": 101,
      "items_count": 2,
      ...
      "items": [{
          "id": 1002,
          "order_id": 101,
          "product_id": 10002,
          "quantity": 2,
          ...
        },
        {
          "id": 1003,
          "order_id": 101,
          "product_id": 10003,
          "quantity": 7,
          ...
        },
        {
          "id": 1004,
          "order_id": 101,
          "product_id": 10004,
          "quantity": 1,
          ...
        }
      ],
      ...
    }
  },
  ...
]
```

---

## Create Order

POST /api/orders.json

- **POST /api/orders.json** will create a new Order from the parameters passed.

Example:

```bash
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X POST \
-d \
'{
"order": {
"payment_type": "misc",
"payment_cost": 0.0,
"item_total": 0.0,
"total": 0.0,
"subtotal": 0.0,
"weight_total": 1.0,
"shipping_cost": 1.0,
"items": [{
"product_id": 1,
"quantity": 1,
}],
"billing_address": {
"firstname": "my firstname",
"lastname": "my lastname",
"street": "my street",
"streetnumber": 1,
"zipcode": 12345,
"city": "Musterstadt"},
"shipping_address": {
"firstname": "my firstname",
"lastname": "my lastname",
"street": "mystreet",
"streetnumber": 1,
"zipcode": 12345,
"city": "Musterstadt" }}}
' \
https://shop_subdomain.versacommerce.de/api/orders.json
```

```
Status: 201 Created

{
  "payment_type": "misc",
  "payment_cost": 0.0,
  "item_total": 0.0,
  "total": 0.0,
  "subtotal": 0.0,
  "weight_total": 1.0,
  "shipping_cost": 1.0,
  "items": [{
    "product_id": 1,
    "code": 1,
    "quantity": 1,
    "title": "my order",
    "price": 1,
    "status": "shipped",
    "weight": 1,
    "tax_rate": 1,
    "origin_id": 1
  }]
}
```

### **Possible Parameter for POST /api/orders.json**

**# Required attributes:**

```
order[payment_type]         = 'misc' # Payment type (via the API usually 'misc') (required)
order[payment_cost]         = 0.00   # Payment cost (required, can be 0.0)
order[item_total]           = 0.00   # Total value of the items
order[total]                = 0.00   # Total price
order[subtotal]             = 0.00   # Subtotal
order[weight_total]         = 0.00   # Total weight
order[shipping_cost]        = 0.00   # Shipping cost
```

**# An Order must at least contain one item with the following attributes:**

```
order[items][][product_id]    = 12345 # Item: VersaCommerce Product ID
order[items][][quantity]      = 3     # Item: quantity
```

**# An Order must contain a billing address with the following attributes:**

```
order[shipping_address][firstname]    = '...' # Shipping address: first name
order[shipping_address][lastname]     = '...' # Shipping address: last name
order[shipping_address][street]       = '...' # Shipping address: street
order[shipping_address][streetnumber] = '...' # Shipping address: house number
order[shipping_address][zipcode]      = '...' # Shipping address: postal code
order[shipping_address][city]         = '...' # Shipping address: city

order[billing_address][firstname]    = '...' # Billing address: first name
order[billing_address][lastname]     = '...' # Billing address: last name
order[billing_address][street]       = '...' # Billing address: street
order[billing_address][streetnumber] = '...' # Billing address: house number
order[billing_address][zipcode]      = '...' # Billing address: postal code
order[billing_address][city]         = '...' # Billing address: city
```

**# Optional attributes (everything from here on is optional):**

```
order[coupon_code]          = '...'  # Coupon- / Gutschein-Code
order[coupon_value]         = 0.0    # Coupon value
order[standard_tax_total]   = 15.99  # Tax total, standard rate (items, shipping cost split, etc.)
order[standard_tax_amount]  = 12.99  # Tax total, standard rate (items)
order[reduced_tax_total]    = 15.99  # Tax total, reduced rate (items, shipping cost split, etc.)
order[reduced_tax_amount]   = 12.99  # Tax total, reduced rate (items)
order[note]                 = '...'  # Note (e.g. from the cart)
order[source]               = '...'  # Affiliate
order[referrer]             = '...'  #
order[origin_name]          = '...'  # Name of the order source (e.g. amazon)
order[origin_id]            = '...'  # ID in the order source ('1234-123435-124243')
order[customer_id]          = 123    # VersaCommerce customers ID
order[created_at]           = '2016-09-09 12:32' # Order date
```

**# Optional attributes from the order source:**

```
order[origin_custom_fields][my_custom_attrib_1] = 'Lorem ipsum ...'
order[origin_custom_fields][my_custom_attrib_2] = 'dolor sit ...'
...

order[items][][code]          = '...' # Item: SKU / EAN
order[items][][subtitle]      = '...' # Item: subtitle
order[items][][title]         = '...' # Item: title
order[items][][weight]        = 0.0   # Item: weight in kg
order[items][][price]         = 10.99 # Item: unit price
order[items][][status]        = '...' # Item: Status ('backorder', 'canceled', 'delivered', 'packing', 'partial_delivery', 'partial_packing', 'returned', 'shipped', 'undelivered')
order[items][][length]        = 0.0   # Item: length in cm
order[items][][width]         = 0.0   # Item: width in cm
order[items][][height]        = 0.0   # Item: height in cm
order[items][][extra_price]   = 0.0   # Item: extra price for this item
order[items][][category]      = '...' # Item: category
order[items][][tax_rate]      = 19.0  # Item: tax rate
order[items][][tax_category]  = '...' # Item: tax type ('standard' / 'reduced')
order[items][][discount_type] = '...' # Item: discount type ('money' / 'percent')
order[items][][discount]      = 0.0   # Item: discount (amount or percentage)
order[items][][vendor]        = '...' # Item: vendor
order[items][][options]       = {}    # Item: optional attributes
order[items][][origin_id]     = '...' # Item: original ID (source system)
order[items][][asin]          = '...' # Item: Amazon Standard Identification Number
```

**# Zahlungen als Array:**

```
order[payments][][category] = 'misc'         # Payments: via the API usually 'misc'
order[payments][][amount]   = 123.45         # Payments: amount
order[payments][][currency] = 'EUR'          # Payments: currency (ISO 4217)
order[payments][][comment]  = 'Free text ...' # Payments: comment
order[payments][][trans_id] = ''             # Payments: transaction ID (if available)
```

**# Bestellhistories als Array:**

```
order[histories][] = 'Notiz 1'
order[histories][] = 'Notiz 2'
```

**# Address and customer data are optional (#POS), but should be filled in.**

```
order[customer][email]              = '...'        # Customer: email address
order[customer][birthday]           = '1970-01-01' # Customer: date of birth
order[customer][active]             = true         # Customer: active (true/false)
order[customer][accepts_newsletter] = true         # Customer: newsletter consent (true/false)
order[customer][wants_account]      = true         # Customer: create customer account (true/false)
order[customer][note]               = '...'        # Customer: note
order[customer][option_01]          = '...'        # Customer: additional field
order[customer][option_02]          = '...'        # Customer: additional field
order[customer][option_03]          = '...'        # Customer: additional field
order[customer][option_04]          = '...'        # Customer: additional field

order[billing_address][title]        = '...' # Billing address: title
order[billing_address][extension]    = '...' # Billing address: address addition
order[billing_address][state]        = '...' # Billing address: state or province
order[billing_address][country]      = '...' # Billing address: country (ISO 3166-1 alpha-2)
order[billing_address][company]      = '...' # Billing address: company
order[billing_address][phone]        = '...' # Billing address: phone number
order[billing_address][option_01]    = '...' # Billing address: additional field
order[billing_address][option_02]    = '...' # Billing address: additional field
order[billing_address][option_03]    = '...' # Billing address: additional field

order[shipping_address][title]        = '...' # Shipping address: title
order[shipping_address][extension]    = '...' # Shipping address: address addition
order[shipping_address][state]        = '...' # Shipping address: state or province
order[shipping_address][country]      = '...' # Shipping address: country (ISO 3166-1 alpha-2)
order[shipping_address][company]      = '...' # Shipping address: company
order[shipping_address][phone]        = '...' # Shipping address: phone number
order[shipping_address][option_01]    = '...' # Shipping address: additional field
order[shipping_address][option_02]    = '...' # Shipping address: additional field
order[shipping_address][option_03]    = '...' # Shipping address: additional field

order[new_status]         = '...' # Order status ('canceled', 'closed', 'in_progress', 'open', 'open_or_in_progress', 'returned')
order[new_payment_status] = '...' # Payment status ('capture_error', 'captured', 'declined', 'not_paid', 'overpaid', 'paid', 'partial_payment', 'reserved')
order[items_status]       = '...' # Itemsstatus ('backorder', 'canceled', 'delivered', 'packing', 'partial_delivery', 'partial_packing', 'returned', 'shipped', 'undelivered')
```
