# Orders

## &#x20; References:

{% file src="<https://1017827023-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9bxpKX5Ord5EtAqbHW-1655467746%2Fuploads%2Fiz7I9pLyPkC8s6Hlhl98%2FIntegraciones%20-%20Status%20Ventas.xlsx?alt=media&token=7e7e8930-359c-490f-a4da-0688dd418720>" %}
This file contains the statuses from the marketplaces in Ventiapp
{% endfile %}

## Get Orders

<mark style="color:blue;">`GET`</mark> `https://ventiapi.azurewebsites.net/api/orders/orders`

This method returns the sales of the different sales channels that were captured by Ventiapp. The order in which they are displayed is by creation date in decreasing order (the newest will be seen first). This API can consume a maximum of 1 occurrence per minute.

#### Query Parameters

| Name    | Type   | Description                                                                                 |
| ------- | ------ | ------------------------------------------------------------------------------------------- |
| channel | string | Canal para poder filtrar las ventas                                                         |
| date    | string | Fecha mínima de la cual se requieren las órdenes. formato MM/DD/YYYY ej: 06/30/2019         |
| to      | string | Fecha máxima de la cual se requieren las órdenes. formato MM\~\~/\~\~DD/YYYY ej: 06/30/2019 |
| offset  | number | Cantidad de órdenes salteadas, ejemplo offset = 50 nos traerá de la órden 51 a la 100       |
| paging  | number | Cantidad de items por página, máximo 50 items                                               |
| sort    | string | Tipo de ordenamiento van a tener las ordenes, mas detalle a continuación                    |

#### Headers

| Name          | Type   | Description   |
| ------------- | ------ | ------------- |
| Authorization | string | Bearer +token |

{% tabs %}
{% tab title="200 Ventas obtenidas" %}

```
{
  "paging": 50,
  "offset": 0,
  "total": 2,
  "sort": "added_desc",
  "results": [
    {
      "orderId": 1234,
      "channel": "meli",
      "dateAdded": "2018-10-29T00:00:00",
      "dateCreated":"2018-10-29T00:00:00",
      "dateModified": "2018-10-29T00:00:00",
      "externalId": "111444123",
      "total": 660.0,
      "currency": "MXN",
      "tax": 0.16,
      "comments": "Send it before tuesday",
      "itemsQuantity": 2,
      "title": "Order Title",
      "internalStatus": 1,
      "amazonFulfillment": "false",
      "cartId": "00000101110002",
      "externalNumber" : "12314512",
      "items": [
        {
          "itemExternalId": "MLM3312341",
          "title": "Item 1",
          "price": 460.0,
          "variationId": "13818313",
          "variationName": "Red",
          "itemQuantity": 1,
          "total": 460.0,
          "sku": "ITEM-RED001",
          "erpId": null
        },
        {
          "itemExternalId": "MLM3317841",
          "title": "Item 2",
          "price": 200.0,
          "variationId": null,
          "variationName": null,
          "itemQuantity": 1,
          "total": 200.0,
          "sku": "PLAINITEM001",
          "erpId": null
        }
      ],
      "buyer": {
        "name": "John",
        "lastname": "Doe",
        "email": "email@api.com",
        "state": "Distrito Federal",
        "address": "Street Address 123",
        "city": "Mexico City",
        "zipcode": "06700",
        "nickname": "JOHNDOEVENTI",
        "phone": "5584848152",
        "externalId": "551331413"
      },
      "shipping": {
        "sellerInfo": "MYSELLERNAME",
        "sellerId": null,
        "shipmentType": "me2",
        "shippingStatus": "shipped",
        "shippingCourier": "drop_off",
        "shippingId": "27586098188",
        "shippingType": "me2",
        "ventiShipping": false,
        "ventiCourierId": null,
        "shippingTrackingId": "10003313132",
        "shippingCourierExternal": "Fedex Express",
        "shippingCost": 120.0
      },
      "paymentMethods": [
                {
                    "externalId": "5531048951",
                    "paymentMethod": "oxxo"
                }
            ]
    },
    {
      "orderId": 1234,
      "channel": "meli",
      "dateAdded": "2018-10-29T00:00:00",
      "dateCreated":"2018-10-29T00:00:00",
      "dateModified": "2018-10-29T00:00:00",
      "externalId": "111444124",
      "total": 660.0,
      "currency": "MXN",
      "tax": 0.16,
      "comments": "Send it before tuesday",
      "itemsQuantity": 2,
      "title": "Order Title 2",
      "internalStatus": 1,
      "amazonFulfillment": "false",
      "cartId": "00000101110007",
      "items": [
        {
          "itemExternalId": "MLM3312341",
          "title": "Item 1",
          "price": 460.0,
          "variationId": "13818313",
          "variationName": "Red",
          "itemQuantity": 1,
          "total": 460.0,
          "sku": "ITEM-RED001",
          "erpId": null
        },
        {
          "itemExternalId": "MLM3317841",
          "title": "Item 2",
          "price": 200.0,
          "variationId": null,
          "variationName": null,
          "itemQuantity": 1,
          "total": 200.0,
          "sku": "PLAINITEM001",
          "erpId": null
        }
      ],
      "buyer": {
        "name": "John",
        "lastname": "Doe",
        "email": "email@api.com",
        "state": "Distrito Federal",
        "address": "Street Address 123",
        "city": "Mexico City",
        "zipcode": "06700",
        "nickname": "JOHNDOEVENTI",
        "phone": "5584848152",
        "externalId": "551331413"
      },
      "shipping": {
        "sellerInfo": "MYSELLERNAME",
        "sellerId": null,
        "shipmentType": "me2",
        "shippingStatus": "shipped",
        "shippingCourier": "drop_off",
        "shippingId": "27586098188",
        "shippingType": "me2",
        "ventiShipping": false,
        "ventiCourierId": null,
        "shippingTrackingId": "10003313132",
        "shippingCourierExternal": "Fedex Express",
        "shippingCost": 120.0
      },
      "paymentMethods": [
                {
                    "externalId": "5531048951",
                    "paymentMethod": "oxxo"
                }
            ]
    }
  ]
}

```

{% endtab %}
{% endtabs %}

Valid options for the sort parameter are:

* added\_desc : Fecha de Alta en VentiApp descendiente
* added\_asc: Fecha de Alta en VentiApp ascendiente
* created\_desc: Fecha de creación inicial de la compra descendiente
* created\_asc: Fecha de creación inicial de la compra ascendiente
* modified\_desc: Fecha de modificación de la compra descendiente
* modified\_asc: Fecha de modificación de la compra ascendiente

The valid options for the channel parameter are:

* "amazon" (Amazon)
* "claroshop" (Claroshop)
* "elektra" (Elektra)
* &#x20;"linio" (Linio)
* &#x20;"meli" (Mercado Libre)
* "mshops" (Mercado Shops)
* "prestashop" (Prestashop)
* "shopify" (Shopify)
* "venticommerce" (VentiCommerce)
* "vtex" (VTEX)
* "walmart" (Walmart)
* "wish" (Wish)
* "woocommerce" (WooCommerce)

## Find Order

<mark style="color:blue;">`GET`</mark> `https://ventiapi.azurewebsites.net/api/orders/findorder`

This method searches for a specific sale, or a cart with associated orders.

#### Query Parameters

| Name    | Type   | Description                                                                                                                                                      |
| ------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| orderid | string | ID Externo de la órden ó ID de carrito en caso de aplicar (ej: ID de MercadoLibre, se encuentra en número de órden y tiene un valor como el siguiente 111444123) |

{% tabs %}
{% tab title="200 Venta obtenida" %}

```
{
  "paging": 50,
  "offset": 0,
  "total": 1,
  "sort":null,
  "results": [
    {
      "orderId": 1234,
      "channel": "meli",
      "dateAdded": "2018-10-29T00:00:00",
      "dateModified": "2018-10-29T00:00:00",
      "externalId": "111444123",
      "total": 660.0,
      "currency": "MXN",
      "tax": 0.16,
      "comments": "Send it before tuesday",
      "itemsQuantity": 2,
      "title": "Order Title",
      "internalStatus": 1,
      "amazonFulfillment": "false",
      "cartId": "00000101110002",
      "externalNumber" : "12314512",
      "items": [
        {
          "itemExternalId": "MLM3312341",
          "title": "Item 1",
          "price": 460.0,
          "variationId": "13818313",
          "variationName": "Red",
          "itemQuantity": 1,
          "total": 460.0,
          "sku": "ITEM-RED001",
          "erpId": null
        },
        {
          "itemExternalId": "MLM3317841",
          "title": "Item 2",
          "price": 200.0,
          "variationId": null,
          "variationName": null,
          "itemQuantity": 1,
          "total": 200.0,
          "sku": "PLAINITEM001",
          "erpId": null
        }
      ],
      "buyer": {
        "name": "John",
        "lastname": "Doe",
        "email": "email@api.com",
        "state": "Distrito Federal",
        "address": "Street Address 123",
        "city": "Mexico City",
        "zipcode": "06700",
        "nickname": "JOHNDOEVENTI",
        "phone": "5584848152",
        "externalId": "551331413"
      },
      "shipping": {
        "sellerInfo": "MYSELLERNAME",
        "sellerId": null,
        "shipmentType": "me2",
        "shippingStatus": "shipped",
        "shippingCourier": "drop_off",
        "shippingId": "27586098188",
        "shippingType": "me2",
        "ventiShipping": false,
        "ventiCourierId": null,
        "shippingTrackingId": "10003313132",
        "shippingCourierExternal": "Fedex Express"
      }
    },
    {
      "channel": "meli",
      "dateAdded": "2018-10-29T00:00:00",
      "dateCreated":"2018-10-29T00:00:00",
      "dateModified": "2018-10-29T00:00:00",
      "externalId": "111444124",
      "total": 660.0,
      "currency": "MXN",
      "tax": 0.16,
      "comments": "Send it before tuesday",
      "itemsQuantity": 2,
      "title": "Order Title 2",
      "internalStatus": 1,
      "amazonFulfillment": "false",
      "cartId": "00000101110007",
      "items": [
        {
          "itemExternalId": "MLM3312341",
          "title": "Item 1",
          "price": 460.0,
          "variationId": "13818313",
          "variationName": "Red",
          "itemQuantity": 1,
          "total": 460.0,
          "sku": "ITEM-RED001",
          "erpId": null
        },
        {
          "itemExternalId": "MLM3317841",
          "title": "Item 2",
          "price": 200.0,
          "variationId": null,
          "variationName": null,
          "itemQuantity": 1,
          "total": 200.0,
          "sku": "PLAINITEM001",
          "erpId": null
        }
      ],
      "buyer": {
        "name": "John",
        "lastname": "Doe",
        "email": "email@api.com",
        "state": "Distrito Federal",
        "address": "Street Address 123",
        "city": "Mexico City",
        "zipcode": "06700",
        "nickname": "JOHNDOEVENTI",
        "phone": "5584848152",
        "externalId": "551331413"
      },
      "shipping": {
        "sellerInfo": "MYSELLERNAME",
        "sellerId": null,
        "shipmentType": "me2",
        "shippingStatus": "shipped",
        "shippingCourier": "drop_off",
        "shippingId": "27586098188",
        "shippingType": "me2",
        "ventiShipping": false,
        "ventiCourierId": null,
        "shippingTrackingId": "10003313132",
        "shippingCourierExternal": "Fedex Express"
      },
      "paymentMethods": [
                {
                    "externalId": "5531048951",
                    "paymentMethod": "oxxo"
                }
            ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Create Order

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/orders/createorder`

This method is used to insert an order in Ventiapp

{% tabs %}
{% tab title="200 " %}

```
{
	"message": "order created successfully",
	"order": {
		"orderId": 1234,
		"channel": "your_channel",
		"dateAdded": "2018-10-29T00:00:00",
		"dateModified": "2018-10-29T00:00:00",
		"externalId": "111444123",
		"total": 660.0,
		"currency": "MXN",
		"tax": 0.16,
		"comments": "Send it before tuesday",
		"itemsQuantity": 2,
		"title": "Order Title",
		"internalStatus": 1,
		"amazonFulfillment": "false",
		"cartId": "00000101110002",
		"externalNumber": "12314512",
		"items": [{
				"itemExternalId": "MLM3312341",
				"title": "Item 1",
				"price": 460.0,
				"variationId": "13818313",
				"variationName": "Red",
				"itemQuantity": 1,
				"total": 460.0,
				"sku": "ITEM-RED001",
				"erpId": null
			},
			{
				"itemExternalId": "MLM3317841",
				"title": "Item 2",
				"price": 200.0,
				"variationId": null,
				"variationName": null,
				"itemQuantity": 1,
				"total": 200.0,
				"sku": "PLAINITEM001",
				"erpId": null
			}
		],
		"buyer": {
			"name": "John",
			"lastname": "Doe",
			"email": "email@api.com",
			"state": "Distrito Federal",
			"address": "Street Address 123",
			"city": "Mexico City",
			"zipcode": "06700",
			"nickname": "JOHNDOEVENTI",
			"phone": "5584848152",
			"externalId": "551331413"
		},
		"shipping": {
			"sellerInfo": "MYSELLERNAME",
			"sellerId": null,
			"shipmentType": "me2",
			"shippingStatus": "shipped",
			"shippingCourier": "drop_off",
			"shippingId": "27586098188",
			"shippingType": "me2",
			"ventiShipping": false,
			"ventiCourierId": null,
			"shippingTrackingId": "10003313132",
			"shippingCourierExternal": "Fedex Express"
		}
	}
}
```

{% endtab %}
{% endtabs %}

Body de la llamada:

```
{
		
		"channel": "your_channel", 
		"externalId": "111444123", 
		"total": 660.0,
		"currency": "MXN",
		"tax": 0.16,
		"comments": "Send it before tuesday",
		"title": "Order Title",
		"cartId": "00000101110002",
		"externalNumber": "12314512",
		"items": [{
				"itemExternalId": "MLM3312341",
				"title": "Item 1",
				"price": 460.0,
				"itemQuantity": 1,
				"total": 460.0,
				"sku": "ITEM-RED001",
				"erpId": "ITEM-123"
			},
			{
				"itemExternalId": "MLM3317841",
				"title": "Item 2",
				"price": 200.0,
				"itemQuantity": 1,
				"total": 200.0,
				"sku": "PLAINITEM001",
				"erpId": "ITEM-456"
			}
		],
		"buyer": {
			"name": "John",
			"lastname": "Doe",
			"email": "email@api.com",
			"state": "Distrito Federal",
			"address": "Street Address 123",
			"city": "Mexico City",
			"zipcode": "06700",
			"nickname": "JOHNDOEVENTI",
			"phone": "5584848152",
			"externalId": "551331413"
		},
		"shipping": {
			"sellerInfo": "MYSELLERNAME",
			"sellerId": "MYSELLERID",
			"shipmentType": "Express",
			"shippingStatus": "shipped",
			"shippingCourier": "drop_off",
			"shippingId": "27586098188",
			"shippingTrackingId": "10003313132",
			"shippingCourierExternal": "Fedex Express",
      "shippingCost": 120.0
		}
```

## Update Order

<mark style="color:orange;">`PUT`</mark> `https://ventiapi.azurewebsites.net/api/orders/updateorder/`

This method is used to update an order in Ventiapp. The fields are optional, those that are not in the call will be ignored

#### Query Parameters

| Name    | Type   | Description |
| ------- | ------ | ----------- |
| orderId | string |             |

{% tabs %}
{% tab title="200 " %}

```
{
	"message": "order created successfully",
	"order": {
		"orderId": 1234,
		"channel": "your_channel",
		"dateAdded": "2018-10-29T00:00:00",
		"dateModified": "2018-10-29T00:00:00",
		"externalId": "111444123",
		"total": 660.0,
		"currency": "MXN",
		"tax": 0.16,
		"comments": "Send it before tuesday",
		"itemsQuantity": 2,
		"title": "Order Title",
		"internalStatus": 1,
		"amazonFulfillment": "false",
		"cartId": "00000101110002",
		"externalNumber": "12314512",
		"items": [{
				"itemExternalId": "MLM3312341",
				"title": "Item 1",
				"price": 460.0,
				"variationId": "13818313",
				"variationName": "Red",
				"itemQuantity": 1,
				"total": 460.0,
				"sku": "ITEM-RED001",
				"erpId": null
			},
			{
				"itemExternalId": "MLM3317841",
				"title": "Item 2",
				"price": 200.0,
				"variationId": null,
				"variationName": null,
				"itemQuantity": 1,
				"total": 200.0,
				"sku": "PLAINITEM001",
				"erpId": null
			}
		],
		"buyer": {
			"name": "John",
			"lastname": "Doe",
			"email": "email@api.com",
			"state": "Distrito Federal",
			"address": "Street Address 123",
			"city": "Mexico City",
			"zipcode": "06700",
			"nickname": "JOHNDOEVENTI",
			"phone": "5584848152",
			"externalId": "551331413"
		},
		"shipping": {
			"sellerInfo": "MYSELLERNAME",
			"sellerId": null,
			"shipmentType": "me2",
			"shippingStatus": "shipped",
			"shippingCourier": "drop_off",
			"shippingId": "27586098188",
			"shippingType": "me2",
			"ventiShipping": false,
			"ventiCourierId": null,
			"shippingTrackingId": "10003313132",
			"shippingCourierExternal": "Fedex Express"
		}
	}
}
```

{% endtab %}
{% endtabs %}

Example:

```
{
		
		"channel": "your_channel", 
		"externalId": "111444123", 
		"total": 660.0,
		"currency": "MXN",
		"tax": 0.16,
		"comments": "Send it before tuesday",
		"title": "Order Title",
		"cartId": "00000101110002",
		"externalNumber": "12314512",
		"items": [{
				"itemExternalId": "MLM3312341",
				"title": "Item 1",
				"price": 460.0,
				"itemQuantity": 1,
				"total": 460.0,
				"sku": "ITEM-RED001",
				"erpId": "ITEM-123"
			},
			{
				"itemExternalId": "MLM3317841",
				"title": "Item 2",
				"price": 200.0,
				"itemQuantity": 1,
				"total": 200.0,
				"sku": "PLAINITEM001",
				"erpId": "ITEM-456"
			}
		],
		"buyer": {
			"name": "John",
			"lastname": "Doe",
			"email": "email@api.com",
			"state": "Distrito Federal",
			"address": "Street Address 123",
			"city": "Mexico City",
			"zipcode": "06700",
			"nickname": "JOHNDOEVENTI",
			"phone": "5584848152",
			"externalId": "551331413"
		},
		"shipping": {
			"sellerInfo": "MYSELLERNAME",
			"sellerId": "MYSELLERID",
			"shipmentType": "Express",
			"shippingStatus": "shipped",
			"shippingCourier": "drop_off",
			"shippingId": "27586098188",
			"shippingTrackingId": "10003313132",
			"shippingCourierExternal": "Fedex Express"
		}
```

## Print Label (BETA)

<mark style="color:blue;">`GET`</mark> `https://ventiapi.azurewebsites.net/api/orders/printlabel/`

This method is used to print the guide associated with the sale. When the guide is printed for the first time, the associated marketplace will notify the client that the order is being processed automatically, that is why we recommend verifying this process before an implementation in an automated system.\
\
The **externalId**, or the **orderId** are mandatory, with one of the two the call is already valid\
\
The type field is optional, in this you have to indicate if it is zpl or pdf (Not all channels support ZPL, Ventiapp is working to perform the conversion). The default value is pdf\
\
**Channels:**\
\
\- Guías generadas desde Ventiapp (ej: EnviaYa, Skydropx o paquetería propia)\
\- Mercado Libre (BETA)\
\- Mercado Shops (BETA)\
\- Linio (BETA)\
\- Amazon (en desarrollo)\
\- Claroshop (en desarrollo)\
\- Walmart (en desarollo)<br>

#### Query Parameters

| Name       | Type    | Description                                                        |
| ---------- | ------- | ------------------------------------------------------------------ |
| externalId | string  | ID externo de la venta (del marketplace o plataforma de ecommerce) |
| type       | string  | Tipo de guía que se desea imprimir                                 |
| orderId    | integer | ID de Ventiapp                                                     |

{% tabs %}
{% tab title="200 Procede a la descarga del archivo en formato .zpl o .pdf" %}

```
```

{% endtab %}

{% tab title="409 Cuando el formato no es soportado por la orden. Ejemplo: El canal no genera guías, ó no genera en un formato específico" %}

```
{
    "message": "the format is not supported by the order"
}
```

{% endtab %}
{% endtabs %}
