> For new integrations, EasyParcel recommends the NextGen API: https://developer.easyparcel.com/

# Making Order

> EasyParcel API · Singapore · MarketPlace · version 1.1.1.0
> Page: https://developers.easyparcel.com/sg/marketplace/making-order · Markdown: https://developers.easyparcel.com/sg/marketplace/making-order.md · PDF: https://developers.easyparcel.com/pdf/Singapore_MarketPlace_1.1.1.0.pdf

The authenticated user can make single order at EasyParcel. User need to make sure the courier service is available.

## Endpoint

- Method: `POST`
- Demo URL: `https://demo.connect.easyparcel.sg/?ac=MPSubmitOrderBulk`
- Live URL: `https://connect.easyparcel.sg/?ac=MPSubmitOrderBulk`
- Body: `application/x-www-form-urlencoded`. Nested fields use PHP `http_build_query` names, e.g. `bulk[0][pick_code]`.
- Action: `MPSubmitOrderBulk`

## Request parameters

### Request L1

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `authentication` | string(25) | Yes | Obtain from EasyParcel IT administrator |
| `api` | string(25) | Yes | Obtain from registered account. |
| `bulk` | array | Yes | (Refer to [Request L2](#request-l2)) |
| `idempotency_key` | string(255) | No | refer to https://easyparcel.github.io/nextgen-integration-doc/NextGenSwitches/idempotency_key |

### Request L2 · `bulk[]` {#request-l2}

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `weight` | double(8,2) | Yes | The weight of the parcel. |
| `width` | double(8,2) | Optional | The width of the parcel. |
| `length` | double(8,2) | Optional | The length of the parcel. |
| `height` | double(8,2) | Optional | The height of the parcel. |
| `content` | string(35) | Yes | The content of the parcel. |
| `value` | double(8,2) | Yes | The amount of the items. |
| `service_id` | string(10) | Yes | Obtain from MPRateChecking return value. |
| `pick_name` | string(35) | Yes | Sender's name. |
| `pick_company` | string(30) | Optional | Sender's company. |
| `pick_mobile` | string(16) | Optional | Sender's mobile. |
| `pick_contact` | string(16) | Yes | Sender's contact. |
| `pick_unit` | string(10) | Yes | Sender's unit |
| `pick_code` | string(10) | Yes | Sender's postcode. |
| `pick_country` | string(35) | Yes | Sender's country (“SG”). |
| `send_name` | string(35) | Yes | Receiver's name. |
| `send_company` | string(30) | Optional | Receiver's company. |
| `send_mobile` | string(16) | Optional | Receiver's mobile. |
| `send_contact` | string(16) | Yes | Receiver's contact. |
| `send_unit` | string(10) | Yes | Receiver's unit |
| `send_addr1` | string(35) | Yes | Receiver's addr1 |
| `send_state` | string(10) | Yes | Receiver's state |
| `send_code` | string(10) | Yes | Receiver's postcode. |
| `send_country` | string(35) | Yes | Receiver's country.  (Refer to [Appendix II](https://developers.easyparcel.com/sg/marketplace/appendix/country-code-list.md)) |
| `collect_date` | date | Yes | Check the available pickup date. If didn't put the date,today date will be default. Format : “YYYY-MM-DD” |
| `reference` | string(25) | Optional | The parcel reference |
| `send_additional_id` | string(50) | Optional | Personal customs clearance code of south korea receiver (Only required for TracX Logis International) |
| `eori_acknowledged` | boolean | Optional | For EasyParcel Business accounts, shipments to Europe require a valid EORI number to be configured in the Business Profile. Set this to true to acknowledge the risk and proceed with order submission without an EORI number provided |

## Sample code

### PHP

```php
<?php
$domain = "https://demo.connect.easyparcel.sg/?ac=";

$action = "MPSubmitOrderBulk";
$postparam = array(
    'authentication' => 'xxxxxx',
    'api' => 'xxxxxx',
    'bulk' => array(
        array(
            'weight' => '1',
            'width' => '0',
            'length' => '0',
            'height' => '0',
            'content' => 'book',
            'value' => '20',
            'service_id' => 'EP-CS0D',
            'pick_name' => 'Yong Tat',
            'pick_company' => 'Yong Tat Sdn Bhd',
            'pick_mobile' => '',
            'pick_contact' => '+6568505280',
            'pick_unit' => '30',
            'pick_code' => '059892',
            'pick_country' => 'SG',
            'send_name' => 'Sam',
            'send_company' => '',
            'send_mobile' => '',
            'send_contact' => '+60-0178320239',
            'send_unit' => '12',
            'send_addr1' => '12',
            'send_state' => 'png',
            'send_code' => '119916',
            'send_country' => 'SG',
            'collect_date' => '2017-11-15',
            'reference' => 'order123',
        ),
        array(
            'weight' => '1',
            'width' => '0',
            'length' => '0',
            'height' => '0',
            'content' => 'book',
            'value' => '20',
            'service_id' => 'EP-CS0D',
            'pick_name' => 'Yong Tat',
            'pick_company' => 'Yong Tat Sdn Bhd',
            'pick_mobile' => '',
            'pick_contact' => '+6568505280',
            'pick_unit' => '30',
            'pick_code' => '059892',
            'pick_country' => 'SG',
            'send_name' => 'Sam',
            'send_company' => '',
            'send_mobile' => '',
            'send_contact' => '+60-0178320239',
            'send_unit' => '12',
            'send_addr1' => '12',
            'send_state' => 'png',
            'send_code' => '119916',
            'send_country' => 'SG',
            'collect_date' => '2017-11-15',
            'reference' => 'order123',
        ),
    ),
);

$url = $domain.$action;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postparam));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

ob_start();
$return = curl_exec($ch);
ob_end_clean();
curl_close($ch);

$json = json_decode($return);
echo "<pre>"; print_r($json); echo "</pre>";
?>
```

### cURL

```bash
curl -X POST 'https://demo.connect.easyparcel.sg/?ac=MPSubmitOrderBulk' \
  --data-urlencode 'authentication=xxxxxx' \
  --data-urlencode 'api=xxxxxx' \
  --data-urlencode 'bulk[0][weight]=1' \
  --data-urlencode 'bulk[0][width]=0' \
  --data-urlencode 'bulk[0][length]=0' \
  --data-urlencode 'bulk[0][height]=0' \
  --data-urlencode 'bulk[0][content]=book' \
  --data-urlencode 'bulk[0][value]=20' \
  --data-urlencode 'bulk[0][service_id]=EP-CS0D' \
  --data-urlencode 'bulk[0][pick_name]=Yong Tat' \
  --data-urlencode 'bulk[0][pick_company]=Yong Tat Sdn Bhd' \
  --data-urlencode 'bulk[0][pick_mobile]=' \
  --data-urlencode 'bulk[0][pick_contact]=+6568505280' \
  --data-urlencode 'bulk[0][pick_unit]=30' \
  --data-urlencode 'bulk[0][pick_code]=059892' \
  --data-urlencode 'bulk[0][pick_country]=SG' \
  --data-urlencode 'bulk[0][send_name]=Sam' \
  --data-urlencode 'bulk[0][send_company]=' \
  --data-urlencode 'bulk[0][send_mobile]=' \
  --data-urlencode 'bulk[0][send_contact]=+60-0178320239' \
  --data-urlencode 'bulk[0][send_unit]=12' \
  --data-urlencode 'bulk[0][send_addr1]=12' \
  --data-urlencode 'bulk[0][send_state]=png' \
  --data-urlencode 'bulk[0][send_code]=119916' \
  --data-urlencode 'bulk[0][send_country]=SG' \
  --data-urlencode 'bulk[0][collect_date]=2017-11-15' \
  --data-urlencode 'bulk[0][reference]=order123' \
  --data-urlencode 'bulk[1][weight]=1' \
  --data-urlencode 'bulk[1][width]=0' \
  --data-urlencode 'bulk[1][length]=0' \
  --data-urlencode 'bulk[1][height]=0' \
  --data-urlencode 'bulk[1][content]=book' \
  --data-urlencode 'bulk[1][value]=20' \
  --data-urlencode 'bulk[1][service_id]=EP-CS0D' \
  --data-urlencode 'bulk[1][pick_name]=Yong Tat' \
  --data-urlencode 'bulk[1][pick_company]=Yong Tat Sdn Bhd' \
  --data-urlencode 'bulk[1][pick_mobile]=' \
  --data-urlencode 'bulk[1][pick_contact]=+6568505280' \
  --data-urlencode 'bulk[1][pick_unit]=30' \
  --data-urlencode 'bulk[1][pick_code]=059892' \
  --data-urlencode 'bulk[1][pick_country]=SG' \
  --data-urlencode 'bulk[1][send_name]=Sam' \
  --data-urlencode 'bulk[1][send_company]=' \
  --data-urlencode 'bulk[1][send_mobile]=' \
  --data-urlencode 'bulk[1][send_contact]=+60-0178320239' \
  --data-urlencode 'bulk[1][send_unit]=12' \
  --data-urlencode 'bulk[1][send_addr1]=12' \
  --data-urlencode 'bulk[1][send_state]=png' \
  --data-urlencode 'bulk[1][send_code]=119916' \
  --data-urlencode 'bulk[1][send_country]=SG' \
  --data-urlencode 'bulk[1][collect_date]=2017-11-15' \
  --data-urlencode 'bulk[1][reference]=order123'
```

## Response

### Response L1

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `api_status` | string(10) | Validation result | (Refer to [Appendix I](https://developers.easyparcel.com/sg/marketplace/appendix/api-return-status.md)) |
| `error_code` | int(5) | Error code | (Refer to [Appendix I](https://developers.easyparcel.com/sg/marketplace/appendix/api-return-status.md)) |
| `error_remark` | string(100) | Error message | (Refer to [Appendix I](https://developers.easyparcel.com/sg/marketplace/appendix/api-return-status.md)) |
| `result` | array | The response of the submit order | (Refer to [Response L2](#response-l2)) |

### Response L2 · `result` {#response-l2}

| Field | Type | Description | Remarks |
| --- | --- | --- | --- |
| `status` | string(10) | The status of the orders made. | Fail / Success |
| `remarks` | string(100) | The error message for orders made. |  |
| `order_number` | string(12) | The response of the order placed. | Failed = 0 / Success = (order_number) |
| `price` | double(8,2) | Order price |  |

## Response samples

### Success

```json
{
  "api_status":"Success",
  "error_code":"0",
  "error_remark":"",
  "result":[
    {
      "status":"success",
      "remarks":"Order Successfully Placed (Parcel from  to )",
      "order_number":"EI-000JJ",
      "price":"6.30"
    },
    {
      "status":"success",
      "remarks":"Order Successfully Placed (Parcel from  to )",
      "order_number":"EI-000JT",
      "price":"6.30"
    }
  ]
}
```

### Fail

```json
{
  "api_status":"Error",
  "error_code":"1",
  "error_remark":"Required authentication key",
  "result":[
    
  ]
}
```

## Referenced appendices

Copied from the appendix pages linked above.

### Appendix II: Country Code List

Source: https://developers.easyparcel.com/sg/marketplace/appendix/country-code-list.md

| Short Country Name | Full Country Name |
| --- | --- |
| SG | SINGAPORE |
| AU | AUSTRALIA |
| BN | BRUNEI DARUSSALAM |
| KH | CAMBODIA |
| CA | CANADA |
| CN | CHINA |
| HK | HONG KONG |
| JP | JAPAN |
| MO | MACAU |
| MM | MYANMAR |
| MY | MALAYSIA |
| NZ | NEW ZEALAND |
| KR | KOREA, REPUBLIC OF |
| TW | TAIWAN |
| TH | THAILAND |
| GB | UNITED KINGDOM |
| US | UNITED STATES |
| VN | VIETNAM |

### Appendix I: API Return Status

Source: https://developers.easyparcel.com/sg/marketplace/appendix/api-return-status.md

| api_status | error_code | error_remark |
| --- | --- | --- |
| Error | 3 | Required api key |
| Error | 4 | Invalid api key |
| Error | 5 | Unauthorized user |
| Success | 0 |  |

Support: WhatsApp EasyParcel API Support — https://api.whatsapp.com/send/?phone=6042023160

Published by EasyParcel Singapore Pte Ltd (201605202W). GST No: 201605202W.
