NAV Navbar
cURL PHP

Overview

Content-Type and Accept Headers

curl http://api.lengow.io/v3.0/orders/ -X OPTIONS --header "Accept: application/json"
<?php
$response = $sdk->get('/orders/', [], [], $accessToken);
?>

If you want to change the returned data format, you can set the Accept header. The server will response you with the given format and change the Content-Type header.

By default, the format is “application/json”.

To get all accepted format, you can use the OPTIONS method.

Dates and Times

All date/time values are specified in ISO 8601.

Prices, Currencies and Countries

All monetary amounts like prices are specified as decimal number.

All currencies are specified as three characters (ISO 4217).

Depending on ressource, countries are specified as two (ISO 3166-2) or three characters.

HTTP Response Codes

Below is a non-exhaustive list of HTTP response codes used by the API. For more information, see the List of HTTP code status.

Code Text Description
200 OK Success
201 Created The request has been fulfilled, a new ressource has been created.
400 Bad Request The request has not been processed because of a client error (bad request syntax, invalid arguments…). See accompanying message for more information.
401 Access not granted Authentication is required for this request and has failed.
403 Forbidden User is not allowed to access this ressource.
404 Not Found The request resource could not be found.
429 Request limitation reached Too many requests have been made in a too short amount of time.
530 Logical Error The request has failed probably due to bad input parameters (catalog that does not exist, invalid search rules…). See accompanying message for more information.
540 Technical Error The request has failed due to an internal error. See accompanying message for more information.

Authentication

You need to authenticate yourself before making any request on the Lengow API.

Get a token

curl "http://api.lengow.io/access/get_token" --data "access_token=&secret="

{"token": "6b7280eb-e7d4-4b94-a829-7b3853a20126", "user_id": "1", "account_id": 1}
<?php
// Token handler get access token from API and create User object containing
// this access token and other data (Lengow use id, user_token...)
$accessTokenHelper = $sdk->getAccessTokenHandler();
$user = $accessTokenHelper->getUser($userToken);
$accessToken = $user->getAccessToken();
?>

First, you’ll need to get a token. Each token has a lifetime of 3600 seconds.

POST http://api.lengow.io/access/get_token

Parameter Requirement Description
access_token Required Access token of the application
secret Required Secret of the application

Make a request

curl http://api.lengow.io/v3.0/account/show?account_id=1 --header "Authorization: 6b7280eb-e7d4-4b94-a829-7b3853a20126"
<?php
$response = $sdk->get('/v3.0/account/show?account_id=1', [], [], $accessToken);
?>

Once you have your token, all your API request will need a Authorization header.

Orders

Orders Status

Each marketplaces have their own status. In Lengow, all these status are transformed in a Lengow status.

List of all Lengow status :

Status Allowed action Description
new None Order was created but no action are available for now.
waiting_acceptance accept,refuse The merchant have to accept the order.
refused None The order was refused by the merchant.
accepted None The order has been accepted by the merchant and waiting the marketplace authorization for shipping.
waiting_shipment ship The merchant have to ship the order.
shipped None The order is waiting the final marketplace validation for closing.
closed None The order is closed, no more action are available.
canceled refund The order was canceled. Depending on marketplace, you can refund the order.
refunding None The refund demand is waiting the marketplace validation.
refunded None Like closed status, the order is closed and no more action are available.

Get orders

Simple call :

curl http://api.lengow.io/v3.0/orders/?account_id=1
<?php
$response = $sdk->get('/orders/?account_id=1', [], [], $accessToken);
?>

GET http://api.lengow.io/v3.0/orders/

This API allows you to retrieve your orders.

Pagination

With pagination :

curl http://api.lengow.io/v3.0/orders/?account_id=1&page=5&page_size=50
<?php
$response = $sdk->get('/orders/?account_id=1&page=5&page_size=50', [], [], $accessToken);
?>

The result is paginated and differents arguments can be provide to manage this pagination.

Field Type Default Description
page Integer 1 The page number
page_size String 100 Maximum 100. Number of results by page

Ordering

With ordering :

curl http://api.lengow.io/v3.0/orders/?account_id=1&ordering=marketplace,-updated_at
<?php
$response = $sdk->get('/orders/?account_id=1&ordering=marketplace,-updated_at', [], [], $accessToken);
?>

You can control the ordering of results with the ordering parameter. For reversing the ordering, your can prefix your field by -.

The default ordering is marketplace,-marketplace_order_date,-imported_at.

List of supported ordering fields:

Argument Type
marketplace String
marketplace_order_id String
merchant_order_id String
lengow_status String
marketplace_status String
marketplace_order_date Date (ISO 8601)
imported_at Date (ISO 8601)
updated_at Date (ISO 8601)

Filtering

With filtering :

curl http://api.lengow.io/v3.0/orders/?account_id=1&marketplace=menlook
<?php
$response = $sdk->get('/orders/?account_id=1&marketplace=menlook', [], [], $accessToken);
?>

You can filter the result with differents filters. account_id is a mandatory filter.

By default, the marketplace_order_date_from filter is setted to current day - 7 days.

You can search a specific order by its marketplace_order_id by providing couple of filters (marketplace_order_id - marketplace). This couple is mandatory, in other case the API will use its befault behaviour (current day - 7 days).

List of supported fields:

Filter Type
account_id Integer
marketplace String
marketplace_order_id String
merchant_order_id String
lengow_status String
marketplace_status String
marketplace_order_date Date (ISO 8601)
marketplace_order_date_from Date (ISO 8601)
marketplace_order_date_to Date (ISO 8601)
imported_at Date (ISO 8601)
imported_from Date (ISO 8601)
imported_to Date (ISO 8601)
updated_at Date (ISO 8601)
updated_from Date (ISO 8601)
updated_to Date (ISO 8601)

Changing the currency

curl http://api.lengow.io/v3.0/orders/?account_id=1&set_currency=USD

By default, all money fields are returned on your account’s currency.

If you want to change the currency, you can use the set_currency parameter. The value must be specified as three characters (ISO 4217).

An example of returned orders :

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "marketplace": "ebay_fr",
      "account_id": 1,
      "marketplace_country_iso2": "FR",
      "marketplace_order_id": "111999905477-1481259994000",
      "merchant_order_id": null,
      "marketplace_status": "Completed",
      "lengow_status": "closed",
      "workflow_rank": 10,
      "marketplace_order_date": "2015-12-01T11:13:25Z",
      "total_order": "35.00",
      "total_tax": "7.00",
      "commission": "0.00",
      "processing_fee": null,
      "shipping": 10.00,
      "discount": 10.00,
      "currency": {
        "iso_a3": "EUR",
        "symbol": "€",
        "name": "Euro"
      },
      "comments": null,
      "invoice_number": null,
      "invoice_url": null,
      "payments": [
        {
          "id": 1913,
          "checkout": null,
          "status": null,
          "type": "PayPal",
          "settled_at": null,
          "channel_order_marketplace": 1277
        }
      ],
      "packages": [
        {
          "cart": [
            {
              "marketplace_order_line_id": "111999905477-1481259994000",
              "marketplace_product_id": "111999905477",
              "merchant_product_id": {
                "field": "sku",
                "id": "1234"
              },
              "marketplace_package_id": null,
              "marketplace_status": "Completed",
              "lengow_status": "closed",
              "title": "Drap-housse Uni",
              "category": null,
              "url_product": null,
              "url_image": null,
              "amount": "35.00",
              "tax": "7.00",
              "discount": null,
              "shipping": "10.00",
              "quantity": 1,
              "created_at": "2015-12-01T11:20:25Z",
              "updated_at": "2015-12-02T10:35:14Z"
            }
          ],
          "delivery": {
            "id": 9552,
            "type": "delivery",
            "company": null,
            "civility": null,
            "first_name": "sebastien",
            "last_name": "Blue",
            "first_line": "6 rue réné Viviani",
            "second_line": null,
            "complement": null,
            "zipcode": "44200",
            "city": "Nantes",
            "phone_home": null,
            "phone_office": null,
            "phone_mobile": "0611111111",
            "full_address": null,
            "email": null,
            "common_country_iso_a2": "FR",
            "trackings": [
              {
                "number": "6C04444552244",
                "method": null,
                "carrier": "colissimo",
                "url": null,
                "is_delivered_by_marketplace": false,
                "parcel_weight": null,
                "shipped_at": "2015-12-01T16:48:23",
                "relay": {
                  "name": null,
                  "id": null
                },
                "marketplace_order_line_ids": [
                  "111999905477-1481259994000"
                ]
              }
            ]
          }
        }
      ],
      "billing_address": {
        "id": 9553,
        "type": "billing",
        "company": null,
        "civility": null,
        "first_name": "sebastien",
        "last_name": "Blue",
        "first_line": "6 rue réné Viviani",
        "second_line": null,
        "complement": null,
        "zipcode": "44200",
        "city": "Nantes",
        "phone_home": null,
        "phone_office": null,
        "phone_mobile": "0611111111",
        "full_address": null,
        "email": null,
        "common_country_iso_a2": "FR"
      },
      "contact_address": null,
      "imported_at": "2015-12-01T11:20:25Z",
      "updated_at": "2015-12-02T10:35:14Z"
    }
  ]
}

Results

Field Type Description
count Integer Number of orders
next String Link to the next page
previous String Link to the previous page
results Array List of orders

Order object

Field Type Description
marketplace String Marketplace code
account_id Integer Account ID
marketplace_order_date Date (ISO 8601) Order date
marketplace_country_iso2 Country (ISO 3166-2) Marketplace country.
marketplace_order_id String Marketplace identifier of the order
lengow_status Lengow status Lengow status
marketplace_status String Marketplace status. Can be the same value than lengow_status.
total_order Decimal Order price (shipping price and taxes included)
commission Decimal Marketplace commission
processing_fee Decimal Processing fees paid by the buyer
shipping Decimal Total shipping amount paid by the buyer.
Order shipping fees + Sum of order lines shipping fees.
discount Decimal Total discount amount on this order.
Order discount fees + Sum of order lines discount fees.
currency Currency (ISO 4217) Currency
comments String Comments of the buyer
invoice_number String Invoice number
invoice_url String Invoice URL
billing_address Address Billing address
contact_address Address Contact address
payments Payment Informations about payments
packages Array List of the order packages

Package object

A package group all line of an order by delivery address.

Field Type Description
cart Array List of ordered products
delivery Address Marketplace product identifier

Ordered product object

Field Type Description
marketplace_order_line_id String Marketplace order line ID
marketplace_product_id String Marketplace product identifier
merchant_product_id.id String Merchant product ID
merchant_product_id.field String Source of merchant product ID
marketplace_package_id String Marketplace package ID
marketplace_status String Marketplace status of the line
lengow_status Lengow status Lengow status of the line
title String Merchant’s product title
category String Merchant’s product category
url_product String Merchant’s product URL
url_image String Merchant’s product image (main)
amount Decimal Total price of the line (product price * quantity)
shipping Decimal Shipping fees for the product
tax Decimal Total tax amount of the line
discount Decimal Total discount amount of the line
quantity Integer Ordered quantity
created_at Date (ISO 8601) Created date
updated_at Date (ISO 8601) Updated date

Address object

Field Required Type Description
company False String Company
civility True String Civility
first_name True String Firstname
last_name True String Lastname
first_line True String First line of the address
second_line False String Second line of the address
complement False String Address complement
zipcode True Decimal Zipcode
city True Decimal City
phone_home False Decimal Home phone number
phone_office False Decimal Office phone number
phone_mobile False Integer Mobile phone number
full_address False Address Full address
email False String Email
common_country_iso_a2 True Country (ISO 3166-2) Country

Tracking object

Field Type Description
number String Tracking number
method String Civility
carrier String Carrier
url String Tracking URL
is_delivered_by_marketplace Boolean Is the package delivered by marketplace ? (Amazon FBA for example)
parcel_weight Decimal Package weight
shipped_at Date (ISO 8601) Shipping date
relay.id String Relay ID
relay.name String Relay name

Payment object

Field Type Description
id Integer Unique identifier
checkout String
status String Marketplace’s status for the payment
type String Type of payment (example : Paypal)
settled_at Date (ISO 8601) Is the package delivered by marketplace ? (Amazon FBA for example)

Set Merchant Order ID

curl http://api.lengow.io/v3.0/orders/moi/ -X PATCH -H "Content-Type: application/json" --data
'{
    "account_id": 1,
    "merchant_order_id": ["123456789"],
    "marketplace": "marketplace_name",
    "marketplace_order_id": "1234-ABC"
}'
<?php
$response = $sdk->patch('/orders/moi/', [], [
    "account_id" => 1,
    "merchant_order_id" =>  array("123456789"),
    "marketplace" =>  "marketplace_name",
    "marketplace_order_id" =>  "1234-ABC"
], $accessToken);
?>

PATCH http://api.lengow.io/v3.0/orders/moi/

You can import your owns order identifiers in the Lengow systems.

Request

Parameter Type Description
account_id String Your Lengow account ID
order_id String order to delete ID
marketplace String The marketplace code of the order
merchant_order_id Array Your merchant order ID

Response

If your request was successful, the order object will be send.

Get all actions on orders

Simple call :

curl http://api.lengow.io/v3.0/orders/actions/?account_id=1
<?php
$response = $sdk->get('/orders/actions/?account_id=1', [], [], $accessToken);
?>

GET http://api.lengow.io/v3.0/orders/actions/

Filtering

You can filter the result with different filters. account_id is a mandatory filter.

With filtering :

curl http://api.lengow.io/v3.0/orders/actions/?account_id=1&marketplace_order_id=123456-ABC&marketplace=darty
<?php
$response = $sdk->get('/orders/actions/?account_id=1&marketplace_order_id=123456-ABC&marketplace=darty', [], [], $accessToken);
?>

List of supported filters:

Filter Type
id Integer
account_id Integer
marketplace String
marketplace_order_id String
action_type String
processed Boolean
queued Boolean
tracking_number String
carrier String
line String
created_at Date (ISO 8601)
created_from Date (ISO 8601)
created_to Date (ISO 8601)
errors String

Result

Field Type Description
id Integer Lengow unique ID for the action
account_id Integer Account ID
marketplace String Marketplace code
marketplace_order_id String Marketplace order ID
action_type [accept,refuse,ship,cancel,refund] Action type
processed Boolean Is the action processed by marketplace ?
queued Boolean Lengow still trying to make this action on the marketplace.
tracking_number String Tracking number
carrier String Carrier
line String Line ID
created_at Date (ISO 8601) Created date of the action
errors String Returned error. To have the final error, you should wait that queued becomes false.

Create an action on an order

curl http://api.lengow.io/v3.0/orders/actions/ -X POST -H "Content-Type: application/json" --data
'{
    "marketplace_order_id": "1234-ABC",
    "account_id": 1,
    "marketplace": "menlook",
    "action_type": "ship",
    "tracking_number": "123456",
    "carrier": "ups"
}'
<?php
$response = $sdk->post('/orders/actions/', [], [
    "marketplace_order_id" => "1234-ABC",
    "account_id" => 1,
    "marketplace" => "menlook",
    "action_type" => "ship",
    "tracking_number" => "123456",
    "carrier" => "ups"
], $accessToken);
?>

POST http://api.lengow.io/v3.0/orders/actions/

With this API, you can make actions on your orders.

Parameter Required Type Description
marketplace_order_id True String Order identifier of the marketplace
account_id True Integer Your account ID
marketplace True String The marketplace name
action_type True String [accept, refuse, cancel, ship, return, refund]

Depending on marketplace and action, you have to give more informations.

Please refers you to the marketplace API.

Parameter Required Type Description
tracking_number Conditional String Tracking number
tracking_url Conditional String Tracking URL (if not tracking_number)
carrier Conditional String Carrier
line Conditional String Line ID for partial action

Marketplaces

Get marketplace informations

Simple call :

curl http://api.lengow.io/v3.0/marketplaces/
<?php
$response = $sdk->get('/marketplaces/', [], [], $accessToken);
?>

GET http://api.lengow.io/v3.0/marketplaces/

Marketplace code

All keys of the result are a Marketplace code used by others API. Always refers you to this API to get this code.

A Marketplace code is unique and must match this regexp : [a-Z0-9-_]

Filtering

With filtering :

curl http://api.lengow.io/v3.0/marketplaces/?account_id=1
<?php
$response = $sdk->get('/marketplaces/?account_id=1', [], [], $accessToken);
?>

You can use the optionnal account_id filter to only get your marketplaces.

Result

Field Type Description
name String Marketplace name
country Country (ISO 4217) Marketplace country
description String Marketplace description (with HTML)
homepage String Homepage of marketplace’s website
logo String Marketplace logo (URL)
status String Mapping between lengow’s status (keys) and marketplace’s status (values)
actions String Informations about each actions (based on lengow’s actions)
actions.args String Mandatory arguments
actions.optional_args String Optional arguments
actions.status String Allowed status for this action