NAV Navbar
Logo
shell php javascript

Introduction

Using the AloPeyk API, businesses can easily integrate our on-demand delivery service into their platform whether they use an E-Commerce platform (Magento, Prestashop, OpenCart, WooCommerce, etc.) or they have developed their own app.

This API is designed to allow developers to check out our pricings, create orders, and track updates on that order until completion.

For access to Postman sample codes, you can use below link to import Collection https://www.getpostman.com/collections/2f63a21fd5f0ccd83ff0

Environments

There are two available environments: Sandbox and Production, both share the same codebase.

Sandbox environment is for testing your app compatibility with AloPeyk’s API.

Production environment is a real-time and after testing your app with Sandbox you can ask for production token To get started using the AloPeyk Delivery API you need to submit a request for a sandbox access token.

Sandbox

https://sandbox-api.alopeyk.com/api/v2/

Sandbox environment allows you to test your integration without sending requests to real drivers. It also comes with a simulator that allows your requests to be handled by bots acting like real drivers (they accept orders, ‘drive’ from origin to destination and so on). You can run your implementations on the staging area just as you would on “production-like” conditions.

In this environment, the order status changes every 30 seconds and it stops changing as soon as get to delivered. For more details, please check Tracking documentation.

Production

https://api.alopeyk.com/api/v2/

If you feel ready to move your code to production and start using the AloPeyk’s API with real drivers, please fill out this form. We will contact you to check your app and generate your Production Token.

Client libraries

To have complete access to AloPeyk’s all API libraries you need check this Github Repositories. Some of the most useful repositories are listed below.

PHP

You can access and contribute to the official PHP Library available on github. For more details about how to use it, you need read the README.md file.

Laravel

You can access and contribute to the official Laravel Library available on github and also on Packagist. For more details about how to use it, you need read the README.md file.

Woocommerce

If your online shop has based on Woocommerce, you can use the official AloPeyk’s Woocommerce Plugin available on github and aslo on Wordpress plugin directory. For more details about how to use it, you need read the Installation Guide.

Basics

The AloPeyk API is fully RESTful:

API Rate Limits

Our API is limited Per IP. Rate limiting of the API is primarily structured on a per-user basis, but all requests made before being authenticated are rate limited by the IP source of that request.

Our main limit factors are Request Per Minute and Request Per Day. If you pass any of these two rate limitations, your access will be limited or blocked for a specified time window, so you’ll have to wait until that duration is over.

Minute Rate Limit

Currently you can send up to 100 requests every minute. You will be able to check the current quotas on every response header.

Response Header

{
...
"X-MinuteRateLimit-Identifier": "[IP]:[YYYY]-[MM]-[DD]-[hh]-[mm]",
"X-MinuteRateLimit-Limit": "100",
"X-MinuteRateLimit-Remaining": "XX"
...
}

Daily Rate Limit

Currently you can send up to 43200 requests every day. You will be able to check the current quotas on every response header.

Response Header

{
...
"X-DailyRateLimit-Identifier": "[IP]:[YYYY]-[MM]-[DD]-[hh]-[mm]",
"X-DailyRateLimit-Limit": "43200",
"X-DailyRateLimit-Remaining": "XX"
...
}

Authentication
GET

For Authentication, use this code:

curl "https://sandbox-api.alopeyk.com/api/v2/" \
  -X GET \
  -H "Authorization: Bearer ${$token}" \
  -H "X-Requested-With: XMLHttpRequest"
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "GET",
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . $token,
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}

?>
var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://sandbox-api.alopeyk.com/api/v2/');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

Make sure to replace $token with your own JWT Token.

All AloPeyk API endpoints support the JWT authentication protocol.

To start sending authenticated HTTP requests you will need to use your JWT authorization token which is sent to you.

Since you have a valid token you need to add it as an HTTP header to every HTTP request you send to the AloPeyk API.

GET https://sandbox-api.alopeyk.com/some_endpoint HTTP/1.1
Authorization: Bearer <JWT_TOKEN>
Host: sandbox-api.alopeyk.com

Your JWT token will have a long expiration time, although that duration could be decreased in the future. Note that your token will not be expired until you request a new one.

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..........

AloPeyk
Service

Location

GET
Get Address

curl "https://sandbox-api.alopeyk.com/api/v2/locations?latlng=35.755484%2C51.415306" \
  -X GET \
  -H "Authorization: Bearer {$token}" \
  -H "X-Requested-With: XMLHttpRequest"
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://sandbox-api.alopeyk.com/api/v2/locations?latlng=35.756780%2C51.411255",



  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "GET",
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . $token,
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://sandbox-api.alopeyk.com/api/v2/locations?latlng=35.756780%2C51.411255');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": "findPlace",
  "object": {
    "address": [
      "بیستم",
      "گاندی جنوبی",
      "ایران"
    ],
    "region": "ونک",
    "district": "",
    "city": "tehran",
    "traffic_zone": {
      "congestion": false,
      "odd_even": false
    },
    "city_fa": "تهران",
    "province": "تهران"
  }
}

This endpoint retrieves place information by its latitude and longitude.

HTTP Request

GET https://sandbox-api.alopeyk.com/api/v2/locations

Query Parameters

Parameter Default Required Description
latlng NULL true Fill this parameter with your place latitude and longitude

GET
Location Suggestions

curl 'https://sandbox-api.alopeyk.com/api/v2/locations?input=میرداماد' \
  -X GET \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/locations?input=میرداماد",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "GET",
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . $token,
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://sandbox-api.alopeyk.com/api/v2/locations?input=میرداماد');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": "autoComplete",
  "object": [
    {
      "title": "میرداماد",
      "region": "شیوا",
      "lat": "35.680097111817098",
      "lng": "51.466359241720198",
      "district": "منطقه ۱۴",
      "city": "tehran",
      "city_fa": "تهران"
    },
    {
      "title": "میرداماد",
      "region": "مینایی",
      "lat": "35.654716852415099",
      "lng": "51.4560997326357",
      "district": "منطقه ۱۵",
      "city": "tehran",
      "city_fa": "تهران"
    },
    {
      "title": "میرداماد",
      "region": "داودیه",
      "lat": "35.760104930870803",
      "lng": "51.432777284209102",
      "district": false,
      "city": "tehran",
      "city_fa": "تهران"
    },
    {
      "title": "میرداماد",
      "region": "tehran",
      "lat": "35.5386945664753",
      "lng": "51.2160959801693",
      "district": false,
      "city": "tehran",
      "city_fa": "تهران"
    },
    {
      "title": "بلوار میرداماد",
      "region": "داودیه",
      "lat": "35.7600557285908",
      "lng": "51.431922949816098",
      "district": false,
      "city": "tehran",
      "city_fa": "تهران"
    }
  ]
}

This endpoint retrieves suggestions by search input.

The result will be an array of suggestions. Each one includes the region and the name of the retrieved place, and offers coordinates for that item.

HTTP Request

GET https://sandbox-api.alopeyk.com/api/v2/locations

Query Parameters

Parameter Default Required Description
input NULL true Fill this parameter with your search input

Price

POST
Normal Price

Request a quote for an order with origin address and destination address

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/price/calc' \
  -X POST \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json' \
  --DATA '{"transport_type":"motor_taxi","addresses":[{"type":"origin","lat":"35.755460","lng":"51.416874"},{"type":"destination","lat":"35.758495","lng":"51.442550"},{"type":"destination","lat":"35.895452","lng":"51.589632"}],"has_return":false,"cashed":false}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/price/calc",
  CURLOPT_RETURNTRANSFER => **true**,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "POST",
  CURLOPT_POSTFIELDS     => json_encode(
    [
      "transport_type" => "motor_taxi",
      "addresses"      => [
        [
          "type" => "origin",
          "lat"  => 35.756780,
          "lng"  => 51.411255,
        ],
        [
          "type" => "destination",
          "lat"  => 35.758495,
          "lng"  => 51.442550,
        ],
        [
          "type" => "destination",
          "lat"  => 35.895452,
          "lng"  => 51.589632,
        ],
      ],
      "has_return" => *false*,
      "cashed"     => *false*,
    ]
  ),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "Content-Type: application/json; charset=utf-8",
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = JSON.stringify({
  'transport_type': 'motor_taxi',
  'addresses': [
    {
      'type': 'origin',
      'lat' : 35.756780,
      'lng' : 51.411255,
    },
    {
      'type': 'destination',
      'lat' : 35.758495,
      'lng' : 51.442550,
    },
    {
      'type': 'destination',
      'lat' : 35.895452,
      'lng' : 51.589632,
    },
  ],
  'has_return': false,
  'cashed': false
});

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://sandbox-api.alopeyk.com/api/v2/orders/price/calc');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);

The above command returns JSON structured like this:

{
  "status": "success",
  "message": null,
  "object": {
    "addresses": [
      {
        "type": "origin",
        "lat": 35.75678,
        "lng": 51.411255,
        "address": "تهران، منطقه ۳، کاووسیه، خ گاندی، خ بیستم",
        "city": "tehran",
        "city_fa": "تهران",
        "priority": 0
      },
      {
        "type": "destination",
        "lat": 35.758495,
        "lng": 51.44255,
        "address": "منطقه ۳، داودیه،  میرداماد جنوبی، م مادر ابتدای خ بهروز",
        "city": "tehran",
        "city_fa": "تهران",
        "priority": 1,
        "distance": 2830,
        "duration": 349,
        "coefficient": 1,
        "price": 8000
      },
      {
        "type": "destination",
        "lat": 35.895452,
        "lng": 51.589632,
        "address": "بخش رودبارقصران، روستای امامه پایین",
        "city": "tehran",
        "city_fa": "تهران",
        "priority": 2,
        "distance": 20192,
        "duration": 2492,
        "coefficient": 0.42308,
        "price": 25500
      }
    ],
    "price": 33500,
    "credit": true,
    "distance": 23022,
    "duration": 2841,
    "status": "OK",
    "user_credit": 996973,
    "delay": 0,
    "city": "tehran",
    "city_fa": "تهران",
    "transport_type": "motor_taxi",
    "has_return": false,
    "cashed": false,
    "price_with_return": 46500,
    "score": 670,
    "score_detail": {
      "انجام درخواست": 335,
      "اعتباری": 335
    },
    "final_price": 33500,
    "discount": 0,
    "discount_coupons": [],
    "invalid_discount_coupons": [],
    "failed_final_price": 0,
    "failed_discount": 0,
    "failed_discount_coupons": [],
    "scheduled": false
  }
}

This endpoint retrieves calculation information for a pair of {latitude,longitude}s.

HTTP Request

POST https://sandbox-api.alopeyk.com/api/v2/orders/price/calc

Request Parameters

Parameter Default Required Description
transport_type NULL true The transport type of the order. Currently valid values for this attribute are motorbike for simple package delivery, motor_taxi for passenger transportations, cargo for cargo, cargo_s for Small Cargo, and car for Car transportations.
addresses[0][type] NULL true Must be of type origin.
addresses[0][lat] NULL true Latitude of the origin address.
addresses[0][lng] NULL true Longitude of the origin address.
addresses[1][type] NULL true Must be of type destination.
addresses[1][lat] NULL true Latitude of the first destination address.
addresses[1][lng] NULL true Longitude of the first destination address.
addresses[2][type] NULL false Must be of type destination.
addresses[2][lat] NULL false Latitude of extra destination addresses.
addresses[2][lng] NULL false Longitude of extra destination addresses.
has_return false false If you are going to calculate price for an order which has a return option, set it to true.
cashed false false If you are going to force the payment type as cash, set it to true.
optimize false false Estimate an optimized route. Set to true to use on price calculations.

Response Descriptions

Attribute Description
status Indicates that the calculation progress has been successful or not.
price Total calculated price.
credit Indicates payment type of the order (payment by credit or cash). Will be true only if you have enough credit on your account for that order. In the case of credit deficiency, or cashed=true, this attribute will be set to false.
distance Estimated distance between the source and the destination.
duration Estimated duration of the path between the source and the destination.
user_credit Your current credit (in Tomans).
price_with_return Calculated price for the order, in case of has_return=true.

POST
Batch Price

This endpoint is the same as Normal Price But the difference is you can calculate up to 15 pairs of Normal Price in one request.

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/batch-price' \
  -X POST \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json; charset=utf-8' \
  --DATA '[{"transport_type":"car","addresses":[{"type":"origin","lat":35.75678,"lng":51.411255},{"type":"destination","lat":35.758495,"lng":51.44255},"has_return":false,"cashed":false},{"transport_type":"motor_taxi","addresses":[{"type":"origin","lat":35.75678,"lng":51.411255},{"type":"destination","lat":35.895452,"lng":51.589632}],"has_return":false,"cashed":false}]'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/batch-price",
  CURLOPT_RETURNTRANSFER => **true**,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "POST",
  CURLOPT_POSTFIELDS     => json_encode(
    [
      [
        "transport_type" => "car",
        "addresses"      => [
          [
            "type" => "origin",
            "lat"  => 35.756780,
            "lng"  => 51.411255,
          ],
          [
            "type" => "destination",
            "lat"  => 35.758495,
            "lng"  => 51.442550,
          ],
        ],
        "has_return" => false,
        "cashed"     => false,
      ],
      [
        "transport_type" => "motor_taxi",
        "addresses"      => [
          [
            "type" => "origin",
            "lat"  => 35.756780,
            "lng"  => 51.411255,
          ],
          [
            "type" => "destination",
            "lat"  => 35.895452,
            "lng"  => 51.589632,
          ],
        ],
        "has_return" => false,
        "cashed"     => false,
      ]
    ]
  ),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "Content-Type: application/json; charset=utf-8",
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = JSON.stringify([
  {
    "transport_type": "car",
    "addresses": [
      {
        "type": "origin",
        "lat": 35.75678,
        "lng": 51.411255
      },
      {
        "type": "destination",
        "lat": 35.758495,
        "lng": 51.44255
      }
    ],
    "has_return": false,
    "cashed": false
  },
  {
    "transport_type": "motor_taxi",
    "addresses": [
      {
        "type": "origin",
        "lat": 35.75678,
        "lng": 51.411255
      },
      {
        "type": "destination",
        "lat": 35.895452,
        "lng": 51.589632
      }
    ],
    "has_return": false,
    "cashed": false
  }
]);

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://sandbox-api.alopeyk.com/api/v2/orders/batch-price');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

The above command returns JSON structured like this:

{
  "status": "success",
  "message": null,
  "object": [
    {
      "addresses": [
        {
          "type": "origin",
          "lat": 35.75678,
          "lng": 51.411255,
          "address": "تهران، منطقه ۳، کاووسیه، خ گاندی، خ بیستم",
          "city": "tehran",
          "city_fa": "تهران",
          "priority": 0
        },
        {
          "type": "destination",
          "lat": 35.758495,
          "lng": 51.44255,
          "address": "منطقه ۳، داودیه،  میرداماد جنوبی، م مادر ابتدای خ بهروز",
          "city": "tehran",
          "city_fa": "تهران",
          "priority": 1,
          "distance": 2830,
          "duration": 174,
          "coefficient": 0.9068,
          "price": 6000
        }
      ],
      "price": 6000,
      "credit": true,
      "distance": 2830,
      "duration": 174,
      "status": "OK",
      "user_credit": 1000,
      "delay": 0,
      "city": "tehran",
      "city_fa": "تهران",
      "transport_type": "car",
      "has_return": false,
      "cashed": false,
      "price_with_return": 9000,
      "score": 120,
      "score_detail": {
        "انجام درخواست": 60,
        "اعتباری": 60
      },
      "final_price": 6000,
      "discount": 0,
      "discount_coupons": [],
      "invalid_discount_coupons": [],
      "failed_final_price": 0,
      "failed_discount": 0,
      "failed_discount_coupons": [],
      "scheduled": false
    },
    {
      "addresses": [
        {
          "type": "origin",
          "lat": 35.75678,
          "lng": 51.411255,
          "address": "تهران، منطقه ۳، کاووسیه، خ گاندی، خ بیستم",
          "city": "tehran",
          "city_fa": "تهران",
          "priority": 0
        },
        {
          "type": "destination",
          "lat": 35.895452,
          "lng": 51.589632,
          "address": "بخش رودبارقصران، روستای امامه پایین",
          "city": "tehran",
          "city_fa": "تهران",
          "priority": 1,
          "distance": 22279,
          "duration": 2749,
          "coefficient": 0.4,
          "price": 26500
        }
      ],
      "price": 26500,
      "credit": true,
      "distance": 22279,
      "duration": 2749,
      "status": "OK",
      "user_credit": 1000,
      "delay": 0,
      "city": "tehran",
      "city_fa": "تهران",
      "transport_type": "motor_taxi",
      "has_return": false,
      "cashed": false,
      "price_with_return": 39500,
      "score": 530,
      "score_detail": {
        "انجام درخواست": 265,
        "اعتباری": 265
      },
      "final_price": 26500,
      "discount": 0,
      "discount_coupons": [],
      "invalid_discount_coupons": [],
      "failed_final_price": 0,
      "failed_discount": 0,
      "failed_discount_coupons": [],
      "scheduled": false
    }
  ]
}

HTTP Request

POST https://sandbox-api.alopeyk.com/api/v2/orders/batch-price

Request Parameters

Parameter Default Required Description
transport_type NULL true The transport type of the order. Currently valid values for this attribute are motorbike for simple package delivery, motor_taxi for passenger transportations, cargo for cargo, cargo_s for Small Cargo, and car for Car transportations.
addresses[0][type] NULL true Must be of type origin.
addresses[0][lat] NULL true Latitude of the origin address.
addresses[0][lng] NULL true Longitude of the origin address.
addresses[1][type] NULL true Must be of type destination.
addresses[1][lat] NULL true Latitude of the first destination address.
addresses[1][lng] NULL true Longitude of the first destination address.
has_return false false If you are going to calculate price for an order which has a return option, set it to true.
cashed false false If you are going to force the payment type as cash, set it to true.

Response Descriptions

Attribute Description
status Indicates that the calculation progress has been successful or not.
price Total calculated price.
credit Indicates payment type of the order (payment by credit or cash). Will be true only if you have enough credit on your account for that order. In the case of credit deficiency, or cashed=true, this attribute will be set to false.
distance Estimated distance between the source and the destination.
duration Estimated duration of the path between the source and the destination.
user_credit Your current credit (in Tomans).
price_with_return Calculated price for the order, in case of has_return=true.

Orders

Order Handling Details

Below you can find different steps for order completion:

1- Creating an order: In the beginning, the order has a status of new, which tells us that the order has been newly created. The order has to have at least two addresses. The first address is always of the type origin, and the second one is of the type destination. if the order contains a has return option, the last address of the order will be of type return, but it will be no different than origin or destination addresses. Orders can have multiple destination addresses. Destination addresses are currently limited to 5. In this stage every address will be in a pending status. At this point the order can be cancelled by you, see the next step for more details on canceling an order.

2- Now it’s time to start dispatching the order. In this step, the order will attain a searching status. This means that we will be searching amongst our available couriers who are closest to the origin address listed inside the addresses list. The timestamp on which the dispatching process is started will be set as the launched_at attribute on the order object. If no couriers are found for the order, or no courier accepts the order, the dispatcher machine will stop searching after 10 minutes, and update the order status to expired. You will be able to cancel the order up until this point. After canceling, the status will change to cancelled, and the cancelled_by attribute, which contains your id, will be set. In both expiration and cancellation cases, the stopped_at attribute will tell us exactly when the progress has been stopped.

3- Accepting an order: When an order is accepted by one of our couriers, the status of the order will be changed to accepted and the accepted_at attribute will be filled by the timestamp of the acceptance time. The distance and duration attributes of the first address (the origin address), will be set by the distance and duration calculated based the position of the courier at which he has accepted the order. You can also cancel the order after this step. From now on, all other actions will affect addresses. Actions on first address of the order (The origin address), will also affect the order, changing the status, picking_at and delivering_at values. Other addresses, except the last one, will not affect the order. The last address fills the delivered_at and status attributes to the time when the order is delivered and the devlivered status respectively.

4- Arriving to the origin: In this step the status of the origin address will be changed to arrived and the arrived_at attribute will be filled by the time of courier arrival. Also the status of the order will be changed to picking, and the picking_at attribute will be filled by arrived_at‘s value. In this step, the courier can reject the order after 5 minutes if he is not able to see any progress, or has mutually agreed with you to cancel the order. In this case, the status of the order will be changed to cancelled, and the cancelled_by attribute will be changed to the id of the responsible courier, also stopped_at will be filled by the time of the cancellation.

5- Handling the origin address: The status of the origin address will be changed to handled and the handled_at attribute will be filled by the time the address is handled, also the status of the order will be changed to delivering, and the delivering_at attribute will be filled by handled_at’s value.

6- Arriving to next address: The status of the next address which is usually a destination address, but can also be a return address if the courier needs to return to the first address, will also be changed to arrived and the arrived_at attribute will be filled by the time of arrival. Not that the order’s information will not be touched during this step.

7- Handling the next address: The status of the next address which again is usually a destination address, but can also be a return address if the courier needs to return to the first address, will be changed to handled and the handled_at attribute will be filled by the time of handling the address. If this is the last address, the address type will be return in case the order has a return option. Otherwise, this address will also be of type destination. Now the status of the order will be changed to delivered, and the delivered_at attribute will be filled by the handled_at value.

8- Finishing the order. The status of the order will be changed to finished and the finished_at attribute will be filled by timestamp the order has been finished.

POST
Create Order

curl 'https://sandbox-api.alopeyk.com/api/v2/orders' \
  -X POST \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json; charset=utf-8' \
  --DATA '{"transport_type":"motor_taxi","addresses":[{"type":"origin","lat":"35.755460","lng":"51.416874","description":"some description for origin","unit":"unit of origin address","number":"number of origin address","person_fullname":"sender s name","person_phone":"sender s phone"},{"type":"destination","lat":"35.758495","lng":"51.442550","description":"some description for origin","unit":"unit of origin address","number":"number of origin address","person_fullname":"sender s name","person_phone":"sender s phone"},{"type":"destination","lat":"35.895452","lng":"51.589632","description":"some description for origin","unit":"unit of origin address","number":"number of origin address","person_fullname":"sender s name","person_phone":"sender s phone"}],"has_return":false,"cashed":false,"extra_params":"{\"order_id\":45,\"customer_id\":23}"}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders",
  CURLOPT_RETURNTRANSFER => **true**,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "POST",
  CURLOPT_POSTFIELDS     => json_encode(
    [
      "transport_type" => "motor_taxi",
      "addresses"      => [
        [
          "type"            => "origin",
          "lat"             => 35.756780,
          "lng"             => 51.411255,
          "description"     => "some description for origin",
          "unit"            => "unit of origin address",
          "number"          => "number of origin address",
          "person_fullname" => "sender s name",
          "person_phone"    => "sender s phone",
        ],
        [
          "type"            => "destination",
          "lat"             => 35.758495,
          "lng"             => 51.442550,
          "description"     => "some description for destination",
          "unit"            => "unit of destination address",
          "number"          => "number of destination address",
          "person_fullname" => "receiver s name",
          "person_phone"    => "receiver s phone",
        ],
        [
          "type"            => "destination",
          "lat"             => 35.895452,
          "lng"             => 51.589632,
          "description"     => "some description for destination",
          "unit"            => "unit of destination address",
          "number"          => "number of destination address",
          "person_fullname" => "receiver s name",
          "person_phone"    => "receiver s phone"
        ]
      ],
      "has_return" => false,
      "cashed"     => false,
      "extra_params" => json_encode([
        "order_id" => 45,
        "customer_id" => 23
      ]),
    ]
  ),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "Content-Type: application/json; charset=utf-8",
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = JSON.stringify({
  "transport_type": "motor_taxi",
  "addresses": [
    {
      "type": "origin",
      "lat": "35.756780",
      "lng": "51.411255",
      "description": "some description for origin",
      "unit": "unit of origin address",
      "number": "number of origin address",
      "person_fullname": "sender s name",
      "person_phone": "sender s phone"
    },
    {
      "type": "destination",
      "lat": "35.758495",
      "lng": "51.442550",
      "description": "some description for destination",
      "unit": "unit of destination address",
      "number": "number of destination address",
      "person_fullname": "receiver s name",
      "person_phone": "receiver s phone"
    },
    {
      "type": "destination",
      "lat": "35.895452",
      "lng": "51.589632",
      "description": "some description for destination",
      "unit": "unit of destination address",
      "number": "number of destination address",
      "person_fullname": "receiver s name",
      "person_phone": "receiver s phone"
    }
  ],
  "has_return": false,
  "cashed": false,
  "extra_params": "{\"order_id\":45,\"customer_id\":23}"
});

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://sandbox-api.alopeyk.com/api/v2/orders');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": null,
  "object": {
    "transport_type": "motor_taxi",
    "customer_id": 3635,
    "status": "new",
    "traffic_congestion_zone": false,
    "traffic_odd_even_zone": false,
    "launched_at": "2019-01-07T10:50:11+03:30",
    "city": "tehran",
    "delay": 0,
    "price": 33500,
    "credit": true,
    "cashed": false,
    "has_return": false,
    "distance": 23022,
    "duration": 2841,
    "invoice_number": "62RRB3",
    "pay_at_dest": false,
    "device_id": null,
    "weight": 20,
    "is_api": true,
    "is_vip": false,
    "updated_at": "2019-01-07T10:50:11+03:30",
    "created_at": "2019-01-07T10:50:11+03:30",
    "id": 15474,
    "signature": {
      "url": "/uploads/order/15474/signature.jpg?var=1546845611"
    },
    "order_token": "6cfdfdd4615474g8d70ecff8ef7eeg36352e40d79c6",
    "nprice": null,
    "subsidy": null,
    "signed_by": "",
    "final_price": 33500,
    "score_calc": {
      "score": 670,
      "score_detail": {
        "انجام درخواست": 335,
        "اعتباری": 335
      }
    },
    "addresses": [
      {
        "id": 30376,
        "order_id": 15474,
        "customer_id": 3635,
        "courier_id": null,
        "lat": 35.75678,
        "lng": 51.411255,
        "type": "origin",
        "priority": 0,
        "city": "tehran",
        "status": "pending",
        "address": "تهران، منطقه ۳، کاووسیه، خ گاندی، خ بیستم",
        "description": "some description for origin",
        "unit": "unit of origin address",
        "number": "number of origin address",
        "person_fullname": "sender s name",
        "person_phone": "sender s phone",
        "signed_by": null,
        "distance": null,
        "google_distance": null,
        "duration": null,
        "google_duration": null,
        "arrived_at": null,
        "handled_at": null,
        "arrive_lat": null,
        "arrive_lng": null,
        "handle_lat": null,
        "handle_lng": null,
        "created_at": "2019-01-07T10:50:11+03:30",
        "updated_at": "2019-01-07T10:50:11+03:30",
        "deleted_at": null,
        "signature": null,
        "city_fa": "تهران"
      },
      {
        "id": 30377,
        "order_id": 15474,
        "customer_id": 3635,
        "courier_id": null,
        "lat": 35.758495,
        "lng": 51.44255,
        "type": "destination",
        "priority": 1,
        "city": "tehran",
        "status": "pending",
        "address": "منطقه ۳، داودیه،  میرداماد جنوبی، م مادر ابتدای خ بهروز",
        "description": "some description for destination",
        "unit": "unit of destination address",
        "number": "number of destination address",
        "person_fullname": "receiver s name",
        "person_phone": "receiver s phone",
        "signed_by": null,
        "distance": 2830,
        "google_distance": null,
        "duration": 349,
        "google_duration": null,
        "arrived_at": null,
        "handled_at": null,
        "arrive_lat": null,
        "arrive_lng": null,
        "handle_lat": null,
        "handle_lng": null,
        "created_at": "2019-01-07T10:50:11+03:30",
        "updated_at": "2019-01-07T10:50:11+03:30",
        "deleted_at": null,
        "signature": null,
        "city_fa": "تهران"
      },
      {
        "id": 30378,
        "order_id": 15474,
        "customer_id": 3635,
        "courier_id": null,
        "lat": 35.895452,
        "lng": 51.589632,
        "type": "destination",
        "priority": 2,
        "city": "tehran",
        "status": "pending",
        "address": "بخش رودبارقصران، روستای امامه پایین",
        "description": "some description for destination",
        "unit": "unit of destination address",
        "number": "number of destination address",
        "person_fullname": "receiver s name",
        "person_phone": "receiver s phone",
        "signed_by": null,
        "distance": 20192,
        "google_distance": null,
        "duration": 2492,
        "google_duration": null,
        "arrived_at": null,
        "handled_at": null,
        "arrive_lat": null,
        "arrive_lng": null,
        "handle_lat": null,
        "handle_lng": null,
        "created_at": "2019-01-07T10:50:11+03:30",
        "updated_at": "2019-01-07T10:50:11+03:30",
        "deleted_at": null,
        "signature": null,
        "city_fa": "تهران"
      }
    ],
    "order_discount": null,
    "extra_param": {
      "order_id": 15474,
      "params": "{\"order_id\":45,\"customer_id\":23}"
    },
    "orderDiscount": null
  }
}

Once you calculated the price of your order, you can use this endpoint in order to create a new order.

HTTP Request

POST https://sandbox-api.alopeyk.com/api/v2/orders

Request Parameters

Parameter Default Required Description
transport_type NULL true The transport type of the order. Current valid values for this attribute are motorbike for simple package delivery, motor_taxi for passenger transportions, cargo for cargo, cargo_s for Small Cargo, and car for Car transportations.
addresses[0][type] NULL true Must be of type origin.
addresses[0][lat] NULL true Latitude of the origin address.
addresses[0][lng] NULL true Longitude of the origin address.
addresses[0][description] NULL false The description of the address which must be of type text.
addresses[0][unit] NULL false Exact unit number of the address.
addresses[0][number] NULL false Exact building number of the destination address.
addresses[0][person_fullname] NULL false Full name of the person receiving the package or the person residing at that address.
addresses[0][person_phone] NULL false Phone number of the person receiving the package or the person residing at that address.
addresses[1][type] NULL true Must be of type destination.
addresses[1][lat] NULL true Latitude of the first destination address.
addresses[1][lng] NULL true Longitude of the first destination address.
addresses[1][description] NULL false The description of the address which must be of type text.
addresses[1][unit] NULL false Exact unit number of the address.
addresses[1][number] NULL false Exact building number of the destination address.
addresses[1][person_fullname] NULL false Full name of the person receiving the package or the person residing at that address.
addresses[1][person_phone] NULL false Phone number of the person receiving the package or the person residing at that address.
addresses[2][type] NULL false Must be destination.
addresses[2][lat] NULL false Latitude of the extra destination addresses.
addresses[2][lng] NULL false Longitude of the extra destination addresses.
addresses[2][description] NULL false The description of the address which must be of type text.
addresses[2][unit] NULL false Exact unit number of the address.
addresses[2][number] NULL false Exact building number of the destination address.
addresses[2][person_fullname] NULL false Full name of the person receiving the package or the person residing at that address.
addresses[2][person_phone] NULL false Phone number of the person receiving the package or the person residing at that address.
has_return false false If you are going to calculate price for an order which has a return option, set it to true.
delay NULL false You can apply a integer value in minutes to add a stop time in the locations. If set to this option, you can not reduce it and you can only increase its value.
scheduled_at NULL false A timestamp (2020-10-25 18:45) that decides whether you would like to create a scheduled order which will be launched at you desired date and time.
cashed false false If you are going to force the payment type as cash, set it to true.
extra_params NULL false A JSON object allowing your database to be mapped with AloPeyk’s orders (ex : { my_order_id : 3333 } ). This object is returned on each webhook call.

Response Descriptions

Attribute Description
id The ID of the order
invoice_number Order’s Invoice Number (5 random chars).
customer_id The ID of the customer.
order_token The unique token of the order (for the tracking page).
status Status of the order. See Order Statuses section for a complete list of possible statuses.
accept_lat Source Latitude.
accept_lng Source Longitude.
price Price of the order.
credit Payment type of the Order (cash or credit).
distance Estimated distance between the source and the destination.
duration Estimated duration for path between the source and the destination.
progress Current progress of the order on a scale of 0 to 1.
signature Signature of the order. This attribute will be NULL until the delivered status.
screenshot Screenshot of the order (Link of the screenshot).
launched_at Once the order is launched, this will be the same as the created_at attribute if the order is not scheduled.
updated_at The last timestamp when the order has been updated.
created_at The timestamp when the order was created.

GET
Get Order Detail

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}?columns=*,addresses,screenshot,progress,courier,customer,last_position_minimal,eta_minimal' \
  -X GET \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}?columns=*,addresses,screenshot,progress,courier,customer,last_position_minimal,eta_minimal",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "GET",
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . $token,
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}?columns=*,addresses,screenshot,progress,courier,customer,last_position_minimal,eta_minimal');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": null,
  "object": {
    "id": 15474,
    "invoice_number": "62RRB3",
    "customer_id": 3635,
    "device_id": null,
    "courier_id": 3840,
    "cancelled_by": null,
    "status": "delivered",
    "distance": 23022,
    "duration": 2841,
    "price": 33500,
    "credit": true,
    "cashed": false,
    "has_return": false,
    "pay_at_dest": false,
    "delay": 0,
    "is_vip": 0,
    "transport_type": "motor_taxi",
    "city": "tehran",
    "is_api": true,
    "weight": 20,
    "traffic_odd_even_zone": 0,
    "traffic_congestion_zone": 0,
    "accept_lat": 35.755292742349,
    "accept_lng": 51.415393095455,
    "rate": 0,
    "comment": null,
    "scheduled_at": null,
    "launched_at": "2019-01-07T10:50:11+03:30",
    "accepted_at": "2019-01-07T10:50:18+03:30",
    "delivered_at": "2019-01-07T10:52:08+03:30",
    "finished_at": null,
    "stopped_at": null,
    "removed_at": null,
    "created_at": "2019-01-07T10:50:11+03:30",
    "updated_at": "2019-01-07T10:52:08+03:30",
    "deleted_at": null,
    "picking_at": "2019-01-07T10:50:37+03:30",
    "delivering_at": "2019-01-07T10:50:55+03:30",
    "screenshot": {
      "url": "https://sandbox-api.alopeyk.com/api/v2/screenshots?markers=origin,35.75678,51.411255|destination,35.758495,51.44255|destination,35.895452,51.589632"
    },
    "addresses": [
      {
        "lat": "35.75678",
        "lng": "51.411255",
        "type": "origin",
        "priority": 0,
        "arrived_at": "2019-01-07T10:50:37+03:30",
        "handled_at": "2019-01-07T10:50:55+03:30",
        "id": 30376,
        "city": "tehran",
        "order_id": "15474",
        "customer_id": "3635",
        "courier_id": "3840",
        "status": "handled",
        "address": "تهران، منطقه ۳، کاووسیه، خ گاندی، خ بیستم",
        "description": "some description for origin",
        "unit": "unit of origin address",
        "number": "number of origin address",
        "person_fullname": "sender s name",
        "person_phone": "sender s phone",
        "signed_by": "",
        "distance": "408",
        "duration": "50",
        "created_at": "2019-01-07T10:50:11+03:30",
        "updated_at": "2019-01-07T10:50:55+03:30",
        "deleted_at": "",
        "arrive_lat": "35.755289373482185",
        "arrive_lng": "51.41540617273421",
        "handle_lat": "35.75528975658215",
        "handle_lng": "51.41541251821029",
        "signature": {
          "url": "/uploads/order/15474/address/30376/signature.jpg?var=1546846129"
        },
        "city_fa": "تهران"
      },
      {
        "lat": "35.758495",
        "lng": "51.44255",
        "type": "destination",
        "priority": 1,
        "arrived_at": "2019-01-07T10:51:13+03:30",
        "handled_at": "2019-01-07T10:51:32+03:30",
        "id": 30377,
        "city": "tehran",
        "order_id": "15474",
        "customer_id": "3635",
        "courier_id": "3840",
        "status": "handled",
        "address": "منطقه ۳، داودیه،  میرداماد جنوبی، م مادر ابتدای خ بهروز",
        "description": "some description for destination",
        "unit": "unit of destination address",
        "number": "number of destination address",
        "person_fullname": "receiver s name",
        "person_phone": "receiver s phone",
        "signed_by": "",
        "distance": "2830",
        "duration": "349",
        "created_at": "2019-01-07T10:50:11+03:30",
        "updated_at": "2019-01-07T10:51:32+03:30",
        "deleted_at": "",
        "arrive_lat": "35.75529166468492",
        "arrive_lng": "51.415383898653836",
        "handle_lat": "35.7552837694252",
        "handle_lng": "51.4153970328592",
        "signature": {
          "url": "/uploads/order/15474/address/30377/signature.jpg?var=1546846129"
        },
        "city_fa": "تهران"
      },
      {
        "lat": "35.895452",
        "lng": "51.589632",
        "type": "destination",
        "priority": 2,
        "arrived_at": "2019-01-07T10:51:50+03:30",
        "handled_at": "2019-01-07T10:52:08+03:30",
        "id": 30378,
        "city": "tehran",
        "order_id": "15474",
        "customer_id": "3635",
        "courier_id": "3840",
        "status": "handled",
        "address": "بخش رودبارقصران، روستای امامه پایین",
        "description": "some description for destination",
        "unit": "unit of destination address",
        "number": "number of destination address",
        "person_fullname": "receiver s name",
        "person_phone": "receiver s phone",
        "signed_by": "",
        "distance": "20192",
        "duration": "2492",
        "created_at": "2019-01-07T10:50:11+03:30",
        "updated_at": "2019-01-07T10:52:08+03:30",
        "deleted_at": "",
        "arrive_lat": "35.755292797575216",
        "arrive_lng": "51.41538377459997",
        "handle_lat": "35.755293345216415",
        "handle_lng": "51.41536923741546",
        "signature": {
          "url": "/uploads/order/15474/address/30378/signature.jpg?var=1546846129"
        },
        "city_fa": "تهران"
      }
    ],
    "eta_minimal": {
      "id": 636,
      "last_position_id": 1814,
      "duration": 4396,
      "distance": 45694,
      "action": "handle",
      "address_id": "30378",
      "updated_at": "2019-01-07 10:51:34"
    },
    "courier_info": {
      "id": 3840,
      "phone": "09493273305",
      "firstname": "محمد رضا",
      "lastname": "نورشی",
      "email": "",
      "referral_code": "A36A1",
      "plate_number": "",
      "rates_avg": "0.0000",
      "avatar": {
        "url": "/uploads/user/3840/avatar.jpg?var=1546846129"
      },
      "abs_avatar": {
        "url": "https://api.alopeyk.com/uploads/user/3840/avatar.jpg?var=1546846129"
      },
      "last_online": null,
      "is_online": null
    },
    "launched_or_created_at": "2019-01-07T10:50:11+03:30",
    "progress": "1.0000",
    "last_position_minimal": null,
    "addresses_timeline": [
      {
        "id": 30376,
        "priority": 0,
        "status": "handled",
        "type": "origin",
        "signature": null,
        "city_fa": null
      },
      {
        "id": 30377,
        "priority": 1,
        "status": "handled",
        "type": "destination",
        "signature": null,
        "city_fa": null
      },
      {
        "id": 30378,
        "priority": 2,
        "status": "handled",
        "type": "destination",
        "signature": null,
        "city_fa": null
      }
    ],
    "next_address_any_full": null,
    "signature": {
      "url": "/uploads/order/15474/address/30378/signature.jpg?var=1546846129"
    },
    "order_token": "6cfdfdd4615474g8d70ecff8ef7eeg36352e40d79c6",
    "nprice": null,
    "subsidy": null,
    "signed_by": "",
    "final_price": 33500,
    "score_calc": {
      "score": 670,
      "score_detail": {
        "انجام درخواست": 335,
        "اعتباری": 335
      }
    },
    "order_discount": null,
    "extra_param": {
      "order_id": 15474,
      "params": "{\"order_id\":45,\"customer_id\":23}"
    },
    "courier_vehicle": null,
    "orderDiscount": null,
    "customerScore": 670,
    "courierVehicle": null
  }
}

In order to get the order details, call this endpoint.

HTTP Request

GET https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}

URL Parameters

Parameter Default Required Description
order_id NULL true Order ID

Response Descriptions

Attribute Description
id ID of the order.
invoice_number The unique invoice number of the order for later references.
customer_id Your ID.
device_id The ID of the device used to create the order.
order_token The unique token of the order.
status Status of the order. See Order Statuses section for a complete list of possible statuses.
price Price of the order.
credit Payment type of the order.
cashed Payment type of the order.
has_return Determine if the order has a return option which indicates whether the courier has to return to the origin address after handling the final address.
pay_at_dest Determine whether the order must be paid for at the destination address.
distance Estimated distance between the source and the destination.
duration Estimated duration for the path between the source and the destination.
accept_lat Latitude of the position where courier has accepted the order.
accept_lng Longitude of the position where courier has accepted the order.
accept_duration Estimated duration for the path between the source and the position where courier has accepted the order.
accept_distance Estimated distance between the source and the position where courier has accepted the order.
rate The rating you give the courier after you finish the order.
comment Your comment on the order which can be filled when you finish or cancel the order, or by the support team on the event of order cancellation.
progress Current Progress of the order on a scale of 0 to 1.
signature Signature of the order. This attribute will be NULL until the last address is handled.
screenshot Screenshot of the order progress on the map.
launched_at When the order has been launched, this will be same as created_at attribute if the order does not have a scheduled status.
updated_at The last timestamp the order has been updated.
created_at The timestamp when the order has been created.
courier This object contains the information of the courier who has accepted the order. Including his phone, firstname, lastname, avatar, abs_avatar. In this object, the avatar key refers to the relative path to your avatar and abs_avatar is the absolute path. Note that {user_id} in the URL will be replaced by the ID of the courier or the customer depending on who this object belongs to.
customer This is your user object.
last_position_minimal The compact version of the last recorded position of the courier who has accepted the order. This compact version includes the ID of the order as id, the ID of the courier as courier_id, the last recorded latitude and longitude of the courier as lat and lng, and finally updated_at as the last timestamp this object has recorded any changes.

GET
Cancel Order

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/cancel' \
  -X GET \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/cancel",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "GET",
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . $token,
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/cancel');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": null,
  "object": {
    "id": 14757,
    "status": "cancelled",
    "courier_id": 3136,
    "customer_id": 86,
    "signature": {
      "url": "/uploads/order/14757/signature.jpg?var=1540380369"
    },
    "order_token": null,
    "nprice": null,
    "subsidy": null,
    "signed_by": "",
    "final_price": null
  }
}

You can cancel any order before courier arrival (before the accepted status)

HTTP Request

GET https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/cancel

URL Parameters

Parameter Default Required Description
order_id NULL true Order ID.

POST
Webhooks

{
  "order": {
    "id": 263197,
    "invoice_number": "4NTNKF",
    "status": "accepted",
    "city": "tehran",
    "transport_type": "motor_taxi",
    "delay": 0,
    "distance": 22533,
    "duration": 2780,
    "price": 31500,
    "credit": false,
    "cashed": false,
    "has_return": false,
    "pay_at_dest": false,
    "accept_lat": 35.754097,
    "accept_lng": 51.415339,
    "signature": null,
    "screenshot": {
      "url": "https://screenshots.alopeyk.com/?size=640x330&maptype=roadmap&language=fa&markers=icon:https://api.alopeyk.com/images/marker-origin.png%7C35.75546,51.416874&markers=icon:https://api.alopeyk.com/images/marker-destination.png%7C35.758495,51.44255&markers=icon:https://api.alopeyk.com/images/marker-destination.png%7C35.895452,51.589632"
    },
    "progress": "0.1429",
    "order_token": be5c4b781263197g86cc78fa6b1a2fg2526b18ac75a,
    "tracking_url": "http://tracking.alopeyk.com/#/be5c4b781263197g86cc78fa6b1a2fg2526b18ac75a",
    "cancelled_by": null,
    "scheduled_at": null,
    "launched_at": "2017-09-12T18:45:39+04:30",
    "accepted_at": "2017-09-12T18:49:34+04:30",
    "picking_at": null,
    "delivering_at": null,
    "delivered_at": null,
    "finished_at": null,
    "stopped_at": null,
    "created_at": "2017-09-12T18:45:39+04:30",
    "updated_at": "2017-09-12T18:49:34+04:30",
    "addresses": [
      {
        "lat": "35.75546",
        "lng": "51.416874",
        "type": "origin",
        "priority": 0,
        "arrived_at": "",
        "handled_at": "",
        "id": 547412,
        "city": "tehran",
        "order_id": "263197",
        "customer_id": 1111111111111,
        "courier_id": 222222222222,
        "status": "pending",
        "address": "address of order s origin",
        "description": "some description for origin",
        "unit": "unit of origin address",
        "number": "number of origin address",
        "person_fullname": "sender s name",
        "person_phone": "sender s phone",
        "signed_by": "",
        "distance": "205",
        "duration": "25",
        "created_at": "2017-09-12T18:45:39+04:30",
        "updated_at": "2017-09-12T18:49:36+04:30",
        "deleted_at": "",
        "arrive_lat": "",
        "arrive_lng": "",
        "handle_lat": "",
        "handle_lng": "",
        "signature": null
      },
      {
        "lat": "35.758495",
        "lng": "51.44255",
        "type": "destination",
        "priority": 1,
        "arrived_at": "",
        "handled_at": "",
        "id": 547413,
        "city": "tehran",
        "order_id": "263197",
        "customer_id": 1111111111111,
        "courier_id": 222222222222,
        "status": "pending",
        "address": "address of order s destination",
        "description": "some description for destination",
        "unit": "unit of destination address",
        "number": "number of destination address",
        "person_fullname": "receiver s name",
        "person_phone": "receiver s phone",
        "signed_by": "",
        "distance": "2341",
        "duration": "288",
        "created_at": "2017-09-12T18:45:39+04:30",
        "updated_at": "2017-09-12T18:49:34+04:30",
        "deleted_at": "",
        "arrive_lat": "",
        "arrive_lng": "",
        "handle_lat": "",
        "handle_lng": "",
        "signature": null
      },
      {
        "lat": "35.895452",
        "lng": "51.589632",
        "type": "destination",
        "priority": 2,
        "arrived_at": "",
        "handled_at": "",
        "id": 547414,
        "city": "tehran",
        "order_id": "263197",
        "customer_id": 1111111111111,
        "courier_id": 222222222222,
        "status": "pending",
        "address": "address of order s destination",
        "description": "some description for destination",
        "unit": "unit of destination address",
        "number": "number of destination address",
        "person_fullname": "receiver s name",
        "person_phone": "receiver s phone",
        "signed_by": "",
        "distance": "20192",
        "duration": "2492",
        "created_at": "2017-09-12T18:45:39+04:30",
        "updated_at": "2017-09-12T18:49:34+04:30",
        "deleted_at": "",
        "arrive_lat": "",
        "arrive_lng": "",
        "handle_lat": "",
        "handle_lng": "",
        "signature": null
      }
    ],
    "courier": {
      "phone": "01234567891",
      "firstname": "AAAAAA",
      "lastname": "BBBBBB",
      "avatar": {
        "url": "/uploads/user/{user_id}/avatar.jpg?var=1497182505"
      },
      "abs_avatar": {
        "url": "https://api.alopeyk.com/uploads/user/{user_id}/avatar.jpg?var=1497182505"
      },
      "last_position": {
        "lat": 35.754098,
        "lng": 51.415349,
      },
    },
    "eta_minimal": {
      "duration": 60,
      "distance": 551,
      "address_id": 547412,
      "updated_at": "2017-09-12 18:49:36",
    }
  }
}

In order to receive your orders real-time updates, we recommend using our HTTP Webhooks. By providing us with a URL, we will be able to send the latest order payload via POST method to the provided URL (Webhook) on each status change.

We will send the order object including the courier’s position if any, as the POST request body with the following generic structure:

Your Webhook API Looks Like

POST http(s)://www.example.com/my/orders/webhook

List of public IP sending webhooks

For security purposes here is the list of public IP you can receive webhooks events from us:

79.175.149.5

79.175.149.5

Structure Descriptions

Attribute Description
id The ID of the order
invoice_number The order’s Invoice Number (5 random chars).
accept_lat Source Latitude.
accept_lng Source Longitude.
status Status of the order. See the Order Statuses section for a complete list of possible statuses.
distance Estimated distance between the source and the destination.
duration Estimated duration for the path between the source and the destination.
price Price of the order.
credit Payment type of the order (cash or credit).
cashed Indicates whether the payment type of order has been forced to cash or not.
progress Current Progress of the order on a scale of 0 to 1.
signature Signature of the order. This attribute will be NULL until the last destination is handled and signed.
screenshot Screenshot of the order progress on the map.
has_return Indicates whether the order has a return option.
pay_at_dest Indicates whether the order must be paid for at the destination address.
courier Order’s courier object, including phone, firstname and lastname. We have also included the latitude and longitude of the courier’s last position on this object.
order_token The unique token generated for that specific order.
tracking_url The sharable tracking URL for that specific order.
launched_at When the order has been launched, this will be the same as the created_at attribute (if the order is not a scheduled order).
updated_at The last timestamp when the order has been updated.
created_at The timestamp when the order has been created.
extra_params An object of the extra parameters you can set for your webhook requests when creating new orders.

Statuses

Status Description
new The order has been created and is ready to be dispatched to the nearest courier available.
searching The dispatcher machine is currently looking for near-by available couriers and is waiting for them to accept the order.
cancelled The order has been cancelled. if this event takes place by the customer it has to be before the picking status otherwise it means that the support team has cancelled the order.
expired No available courier was found for the order or no courier has responded or accepted your request
accepted One of our couriers has accepted the order.
picking The courier has arrived at the source of the order which is in fact the first address (the origin).
delivering The courier has successfuly handled the first address and is now delivering the package(s).
delivered The courier successfully dropped all packages at their designated addresses i.e. the courier has handled those addresses.
finished This status is not required. You can finish the order and rate our courier in which case the rate and comment attributes will be filled by you while updating the order to this status.
scheduled This status is specific to the scheduled orders. Once the scheduled_at timestamp is reached, the order will be dispatched automatically and its status will be updated to new. From this stage the orders will follow the same routine listed above.

GET
Tracking

Once you successfully have created an order, you will be able to watch the courier on a live map.

At Sandbox environment, courier location is static and order status will change every 30 seconds. But at Production environment, the courier location and order status based on reality will be change.

You can access tracking URL (tracking_url) trough Webhook data. Even you can manually create this URL by concatenation Order Token (‘order_token’) which is accessible in Order details method and the tracking base URL

https://sandbox-tracking.alopeyk.com/#/<order_token>

For customizing some elements, you can pass these variables on a URL by GET method

Parameter Type Description
logo URL Replace default “alopeyk logo” with your custom logo.
customer_image URL Replace your alopeyk profile image with your own customer image.
customer_name String Replace your alopeyk profile name with your own customer name.
show_payment_status Boolean By sending false for this variable, you can hide payment status.
show_order_price Boolean By sending false for this variable as value, you can hide order price box.
show_courier_phone Boolean By sending false for this variable, you can hide courier phone number.
show_order_info_box Boolean By sending false for this variable as value, you can hide order info box.

POST
Rate Order

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/finish' \
  -X POST \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json; charset=utf-8' \
  --DATA '{"rate":5,"comment":"Amazing! Your API is excellent. Thanks."}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/finish",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "POST",
  CURLOPT_POSTFIELDS     => json_encode(
    [
      "rate"    => 5,
      "comment" => "Amazing! Your API is excellent. Thanks."
    ]
  ),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = JSON.stringify({
  'rate': 5,
  'comment': 'Amazing! Your API is excellent. Thanks.'
});

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/finish');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');

xhr.send(data);

The above command returns a JSON response structured like this:

{
    "status": "success",
    "message": null,
    "object": {
        "id": 11111,
        "status": "finished",
        "courier_id": 2222,
        "customer_id": 11,
        "accepted_at": "2018-10-27T13:14:42+03:30",
        "city": "tehran",
        "transport_type": "motorbike",
        "price": 26000,
        "rate": 5,
        "next_address_any": null,
        "signature": {
            "url": "/uploads/order/14817/signature.jpg?var=1540634493"
        },
        "order_token": null,
        "nprice": null,
        "subsidy": null,
        "signed_by": "",
        "final_price": 26000
    }
}

When an order is in its final status (delivered or returned due to the order’s has_return attribute), you can call this endpoint, to fill the rate and the comment attributes.

HTTP Request

POST https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/finish

URL Parameters

Parameter Default Required Description
order_id NULL true Order ID

Request Parameters

Parameter Default Required Description
rate NULL false Your Rating on the order. Must be an integer in the range of 1-5.
comment NULL false Your comment on the order. Must be of type text.

PUT
Edit Order

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}' \
  -X PUT \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json' \
  --DATA '{"has_return": false,"cashed": false,"credit": true,"pay_at_dest": false,"delay": 20,"transport_type": "motorbike"}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "PUT",
  CURLOPT_POSTFIELDS     => json_encode(
    [
      "has_return": false,
      "cashed": false,
      "credit": true,
      "pay_at_dest": false,
      "delay": 20,
      "transport_type": "motorbike"
    ]
  ),
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . $token,
    "X-Requested-With: XMLHttpRequest",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = JSON.stringify({
  "has_return": false,
  "cashed": false,
  "credit": true,
  "pay_at_dest": false,
  "delay": 20,
  "transport_type": "motorbike"
});

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('PUT', 'https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns a JSON response structured like Get Order Detail.

For order editions and updates, transport types of the same group can be changed to each other. This means that the transport types of motor orders can not be changed into transport types belonging to car or cargo group.

If an order has a return policy and courier has started the trip back the origin address. The has_return parameter cannot be turned off. In order to edit the order details, this endpoint can be called:

HTTP Request

PUT https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}

URL Parameters

Parameter Default Required Description
order_id NULL true Order ID

Request Parameters

Parameter Default Required Description
has_return NULL false If your order needs to be returned to the origin, you can apply it by sending the true for this option before announcing the end of the order by the courier.
cashed&credit NULL false If you want to change the payment type, you can use these two options. One of these two options should always be true and other one false.
pay_at_dest NULL false If the cashed option is true, by set this option to true the order price can be paid at destination. This option is available only for single-destination trips.
delay NULL false You can apply a integer value in minutes to add a stop time in the locations. If set to this option, you can not reduce it and you can only increase its value.
transport_type NULL false Depending on the section of the groups in the above description, you can change the option to change the type of trip.

POST
Add Hidden Description

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/address/{$address_id}/hidden_description' \
  -X POST \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json; charset=utf-8' \
  --DATA '{"description":"Some Text"}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/address/{$address_id}/hidden_description",
  CURLOPT_RETURNTRANSFER => **true**,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "POST",
  CURLOPT_POSTFIELDS     => json_encode(
    [
      "description" => "Some Text",
    ]
  ),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "Content-Type: application/json; charset=utf-8",
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = JSON.stringify({
  "description": "Some Text"
});

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/address/{address_id}/hidden_description');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": null,
  "object": {
    "user_id": 2424,
    "order_id": 23404,
    "address_id": 599650,
    "description": "Some Text",
    "updated_at": "2018-12-22 13:51:37",
    "created_at": "2018-12-22 13:51:37",
    "id": 106
  }
}

This type of description is invisible for courier. It is worth noting that customer and AloPeyk support team can view content of this field.

HTTP Request

POST https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/address/{address_id}/hidden_description

URL Parameters

Parameter Default Required Description
order_id NULL true Order ID
address_id NULL true Address ID

Request Parameters

Parameter Default Required Description
description NULL true The hidden description of the address which must be of type text.

Response Descriptions

Attribute Description
user_id The ID of the customer
order_id The ID of the order
address_id The ID of the address that the hidden description added to it
description Text of the hidden description added to the address.
updated_at The last timestamp when the hidden description has been updated.
created_at The timestamp when the hidden description was created.
id The ID of the idden description

DEL
Delete Hidden Description

curl 'https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/address/{$address_id}/hidden_description/{$hidden_description_id}' \
  -X DELETE \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json; charset=utf-8' \
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/orders/{$order_id}/address/{$address_id}/hidden_description/{$hidden_description_id}",
  CURLOPT_RETURNTRANSFER => **true**,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "DELETE",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "Content-Type: application/json; charset=utf-8",
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('DELETE', 'https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/address/{address_id}/hidden_description/{hidden_description_id}');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": null,
  "object": {
    "id": 109,
    "user_id": 2424,
    "order_id": 23419,
    "address_id": 599686,
    "description": "Some Text",
    "created_at": "2018-12-22 17:39:51",
    "updated_at": "2018-12-22 17:39:51",
    "deleted_at": null
  }
}

Use this method in order to delete hidden description fields.

HTTP Request

DELETE https://sandbox-api.alopeyk.com/api/v2/orders/{order_id}/address/{address_id}/hidden_description/{hidden_description_id}

URL Parameters

Parameter Default Required Description
order_id NULL true Order ID
address_id NULL true Address ID
hidden_description_id NULL true Hidden Description ID

Response Descriptions

Attribute Description
id The ID of the idden description
user_id The ID of the customer
order_id The ID of the order
address_id The ID of the address that the hidden description added to it
description Text of the address hidden description.
updated_at The last timestamp when the hidden description has been updated.
created_at The timestamp when the hidden description was created.

AloPost
Service

Orders

POST
Create Order

curl --location --request POST '{{alopost-url}}/api/v1/orders' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}' \
--data-raw '{
  "parcel_type": 1,
  "parcel_service_type": 1,
  "insurance_type": 1,
  "wrapping_type": 0,
  "weight": 2000,
  "description": "قابل حمل است",
  "parcel_specs": 2,
  "insurance_amount": 500,
  "addresses": [
    {
      "lat": "35.637700",
      "lng": "51.439944",
      "type": "origin",
      "address": "تهران، خیابان وزراء، کوچه چهاردهم، پلاک پنجم، ساختمان الوپیک",
      "number": "104/2",
      "unit": "10",
      "description": "ندارد...",
      "name": "test name",
      "postal_code": "1234567899",
      "national_code": "1552783936",
      "city_code": 1,
      "mobile": "09490000000"
    },
    {
      "type": "destination",
      "address": "test address",
      "name": "test name",
      "postal_code": "9800000000",
      "national_code": "1111111111",
      "city_code": 81,
      "mobile": "09490000000"
    }
  ]
}'
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/orders",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(
    [
      "parcel_type"         => 1,
      "parcel_service_type" => 1,
      "insurance_type"      => 1,
      "wrapping_type"       => 0,
      "weight"              => 2000,
      "description"         => "قابل حمل است",
      "parcel_specs"        => 2,
      "insurance_amount"    => 500,
      "addresses" => [
        [
          "lat"           => "35.637700",
          "lng"           => "51.439944",
          "type"          => "origin",
          "address"       => "تهران، خیابان وزراء، کوچه چهاردهم، پلاک پنجم، ساختمان الوپیک",
          "number"        => "104/2",
          "unit"          => "10",
          "description"   => "ندارد...",
          "name"          => "test name",
          "postal_code"   => "1234567899",
          "national_code" => "1552783936",
          "city_code"     => 1,
          "mobile"        => "09490000000"
        ],
        [
          "type"          => "destination",
          "address"       => "test address",
          "name"          => "test name",
          "postal_code"   => "9800000000",
          "national_code" => "1111111111",
          "city_code"     => 81,
          "mobile"        => "09490000000"
        ]
      ]
    ]
  ),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({
    "parcel_type": 1,
    "parcel_service_type": 1,
    "insurance_type": 1,
    "wrapping_type": 0,
    "weight": 2000,
    "description": "قابل حمل است",
    "parcel_specs": 2,
    "insurance_amount": 500,
    "addresses": [
      {
        "lat": "35.637700",
        "lng": "51.439944",
        "type": "origin",
        "address": "تهران، خیابان وزراء، کوچه چهاردهم، پلاک پنجم، ساختمان الوپیک",
        "number": "104/2",
        "unit": "10",
        "description": "ندارد...",
        "name": "test name",
        "postal_code": "1234567899",
        "national_code": "1552783936",
        "city_code": 1,
        "mobile": "09490000000"
      },
      {
        "type": "destination",
        "address": "test address",
        "name": "test name",
        "postal_code": "9800000000",
        "national_code": "1111111111",
        "city_code": 81,
        "mobile": "09490000000"
      }
    ]
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{alopost-url}}/api/v1/orders");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send(data);

You can register alopost order using this api.

First you need to fill body items and send it to sandbox api.

Request Parameters

Parameter Required type Description
parcel_type true integer Parcel type that specify type of parcel. National Post Company of Iran support PACKAGE_VANGUARD ( پاکت پیشتاز ) currently.
parcel_service_type true integer parcel service type that specify parcel send with VANGUARD ( پیشتاز ) or CUSTOM_BUILT ( سفارشی ) type in National Post Company of Iran
insurance_type true integer insurance type that Specifies the type of product to send and this is effective in price
wrapping_type true integer wrapping type that specify type of wrapping for parcel. It depends on volumn and size of parcel.
weight true integer weight of parcel
description true text description of parcel for better guidance of National Post Company
parcel_specs true integer parcel_specs specify parcel is letter or SMALL_PARCEL.
insurance_amount true integer insurance_amount specify the value of parcel.
addresses true array addresses specify orgin and destination address with some parameters such as latitude, longitude and city_code. You can get code of city in list of city route.
scheduled_at false Date Time You can set scheduled at such as this format (2020-01-07 11:02:44). Order create and run on this time.

Response Descriptions

Attribute Description
id The ID of the order
order_number This number save in iran National Post Company database and you can track it with using this.
customer_id Your customer id in our database
price Price of parcel from iran National Post Company api. This price is ( postal_income + tax_price )
insurance_price Insurance price of parcel from iran National Post Company api.
tax_price Tax price of parcel from iran National Post Company api.
wrapping_price Wrapping price of parcel from iran National Post Company api.
parcel_type Parcel type that specify type of parcel. National Post Company of Iran support PACKAGE_VANGUARD ( پاکت پیشتاز ) currently.
parcel_service_type parcel service type that specify parcel send with VANGUARD ( پیشتاز ) or CUSTOM_BUILT ( سفارشی ) type in National Post Company of Iran
insurance_type insurance type that Specifies the type of product to send and this is effective in price
wrapping_type wrapping type that specify type of wrapping for parcel. It depends on volumn and size of parcel.
weight weight of parcel
description description of parcel for better guidance of iran National Post Company
parcel_specs parcel_specs specify parcel is letter or SMALL_PARCEL.
insurance_amount insurance_amount specify the value of parcel.
postal_income postal_fare + insurance_price
postal_fare Iran National Post Company share right
status Order status
transport_type The transport type of the order. Current valid values for this attribute is motorbike for simple package delivery.
scheduled_at If is set Order create and run on this time
updated_at The last timestamp when the order has been updated.
created_at The timestamp when the order was created.

GET
Get Order Detail

curl --location --request GET '{{alopost-url}}/api/v1/orders/{order_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/orders/{order_id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{alopost-url}}/api/v1/orders/%7Border_id%7D");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send();

In order to get the order details, call this endpoint.

Request Parameters

Parameter Required type Description
orderId true integer Order ID

Response Descriptions

Attribute Description
id The ID of the order
order_number This number save in iran National Post Company database and you can track it with using this.
alopeyk_order_id AloPeyk order id.
transport_type The transport type of the order. Current valid values for this attribute is motorbike for simple package delivery.
customer_id Your customer id in our database
office_id Office id delivery parcel
price Price of parcel from iran National Post Company api. This price is ( postal_income + tax_price )
insurance_price Insurance price of parcel from iran National Post Company api.
tax_price Tax price of parcel from iran National Post Company api.
wrapping_price Wrapping price of parcel from iran National Post Company api.
parcel_type Parcel type that specify type of parcel. National Post Company of Iran support PACKAGE_VANGUARD ( پاکت پیشتاز ) currently.
parcel_service_type parcel service type that specify parcel send with VANGUARD ( پیشتاز ) or CUSTOM_BUILT ( سفارشی ) type in National Post Company of Iran
insurance_type insurance type that Specifies the type of product to send and this is effective in price
wrapping_type wrapping type that specify type of wrapping for parcel. It depends on volumn and size of parcel.
weight weight of parcel
description description of parcel for better guidance of iran National Post Company
parcel_specs parcel_specs specify parcel is letter or SMALL_PARCEL.
insurance_amount insurance_amount specify the value of parcel.
postal_income postal_fare + insurance_price
postal_fare Iran National Post Company share right
status Order status
scheduled_at If is set Order create and run on this time
updated_at The last timestamp when the order has been updated.
created_at The timestamp when the order was created.
addresses Origin and destination address
office office information

GET
Cancel Order

curl --location --request GET '{{alopost-url}}/api/v1/orders/{order_id}/cancel' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/orders/{order_id}/cancel",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{alopost-url}}/api/v1/orders/{order_id}/cancel");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send();

You can cancel any order before courier arrival (before the accepted status)

Request Parameters

Parameter Required type Description
orderId true integer Order ID

GET
List of active orders

curl --location --request GET '{{alopost-url}}/api/v1/orders/active' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/orders/active",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{alopost-url}}/api/v1/orders/active");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send();

You can see your active orders list with this api.

Response Descriptions

Attribute Description
id The ID of the order
order_number This number save in iran National Post Company database and you can track it with using this.
alopeyk_order_id AloPeyk order id.
transport_type The transport type of the order. Current valid values for this attribute is motorbike for simple package delivery.
customer_id Your customer id in our database
office_id Office id delivery parcel
price Price of parcel from iran National Post Company api. This price is ( postal_income + tax_price )
insurance_price Insurance price of parcel from iran National Post Company api.
tax_price Tax price of parcel from iran National Post Company api.
wrapping_price Wrapping price of parcel from iran National Post Company api.
parcel_type Parcel type that specify type of parcel. National Post Company of Iran support PACKAGE_VANGUARD ( پاکت پیشتاز ) currently.
parcel_service_type parcel service type that specify parcel send with VANGUARD ( پیشتاز ) or CUSTOM_BUILT ( سفارشی ) type in National Post Company of Iran
insurance_type insurance type that Specifies the type of product to send and this is effective in price
wrapping_type wrapping type that specify type of wrapping for parcel. It depends on volumn and size of parcel.
weight weight of parcel
description description of parcel for better guidance of iran National Post Company
parcel_specs parcel_specs specify parcel is letter or SMALL_PARCEL.
insurance_amount insurance_amount specify the value of parcel.
postal_income postal_fare + insurance_price
postal_fare Iran National Post Company share right
status Order status
scheduled_at If is set Order create and run on this time
updated_at The last timestamp when the order has been updated.
created_at The timestamp when the order was created.
addresses Origin and destination address
office office information

GET
List of orders

curl --location --request GET '{{alopost-url}}/api/v1/orders' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/orders",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{alopost-url}}/api/v1/orders");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send();

You can get your all orders list untill now with this api route.

Response Descriptions

Attribute Description
id The ID of the order
order_number This number save in iran National Post Company database and you can track it with using this.
alopeyk_order_id AloPeyk order id.
transport_type The transport type of the order. Current valid values for this attribute is motorbike for simple package delivery.
customer_id Your customer id in our database
office_id Office id delivery parcel
price Price of parcel from iran National Post Company api. This price is ( postal_income + tax_price )
insurance_price Insurance price of parcel from iran National Post Company api.
tax_price Tax price of parcel from iran National Post Company api.
wrapping_price Wrapping price of parcel from iran National Post Company api.
parcel_type Parcel type that specify type of parcel. National Post Company of Iran support PACKAGE_VANGUARD ( پاکت پیشتاز ) currently.
parcel_service_type parcel service type that specify parcel send with VANGUARD ( پیشتاز ) or CUSTOM_BUILT ( سفارشی ) type in National Post Company of Iran
insurance_type insurance type that Specifies the type of product to send and this is effective in price
wrapping_type wrapping type that specify type of wrapping for parcel. It depends on volumn and size of parcel.
weight weight of parcel
description description of parcel for better guidance of iran National Post Company
parcel_specs parcel_specs specify parcel is letter or SMALL_PARCEL.
insurance_amount insurance_amount specify the value of parcel.
postal_income postal_fare + insurance_price
postal_fare Iran National Post Company share right
status Order status
scheduled_at If is set Order create and run on this time
updated_at The last timestamp when the order has been updated.
created_at The timestamp when the order was created.
addresses Origin and destination address
office office information

GET
Failed List of orders

curl --location --request GET '{{alopost-url}}/api/v1/orders/failed' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/orders/failed",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{alopost-url}}/api/v1/orders/failed");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send();

You can get your own failed orders list.

Response Descriptions

Attribute Description
id The ID of the order
order_number This number save in iran National Post Company database and you can track it with using this.
alopeyk_order_id AloPeyk order id.
transport_type The transport type of the order. Current valid values for this attribute is motorbike for simple package delivery.
customer_id Your customer id in our database
office_id Office id delivery parcel
price Price of parcel from iran National Post Company api. This price is ( postal_income + tax_price )
insurance_price Insurance price of parcel from iran National Post Company api.
tax_price Tax price of parcel from iran National Post Company api.
wrapping_price Wrapping price of parcel from iran National Post Company api.
parcel_type Parcel type that specify type of parcel. National Post Company of Iran support PACKAGE_VANGUARD ( پاکت پیشتاز ) currently.
parcel_service_type parcel service type that specify parcel send with VANGUARD ( پیشتاز ) or CUSTOM_BUILT ( سفارشی ) type in National Post Company of Iran
insurance_type insurance type that Specifies the type of product to send and this is effective in price
wrapping_type wrapping type that specify type of wrapping for parcel. It depends on volumn and size of parcel.
weight weight of parcel
description description of parcel for better guidance of iran National Post Company
parcel_specs parcel_specs specify parcel is letter or SMALL_PARCEL.
insurance_amount insurance_amount specify the value of parcel.
postal_income postal_fare + insurance_price
postal_fare Iran National Post Company share right
status Order status
scheduled_at If is set Order create and run on this time
updated_at The last timestamp when the order has been updated.
created_at The timestamp when the order was created.
addresses Origin and destination address
office office information

GET
List Cities

curl --location --request GET '{{alopost-url}}/api/v1/cities?page=1&name=اصفهان' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}' \
--data-raw ''
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/cities?page=1&name=اصفهان",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = "";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{alopost-url}}/api/v1/cities?page=1&name=اصفهان");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send(data);

You can get all cities from this api route.

you can send page number and name of city for search on list.

POST
AloPost AloPeyk Calculate Price

curl --location --request POST '{{alopost-url}}/api/v1/alopeyk/calculate/price' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}' \
--data-raw '{
    "parcel_specs": 1,
    "addresses": [
        {
            "lat": "35.732518", 
            "lng": "51.413458", 
            "type": "origin"
        }
    ]
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/alopeyk/calculate/price",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(
    [
      "parcel_specs" => 1,
      "addresses" => [
        {
          "lat"  => "35.732518", 
          "lng"  => "51.413458", 
          "type" => "origin"
        }
      ]
    ]
  ),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({
    "parcel_specs": 1,
    "addresses": [
        {
            "lat": "35.732518", 
            "lng": "51.413458", 
            "type": "origin"
        }
    ]
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{alopost-url}}/api/v1/alopeyk/calculate/price");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send(data);

This endpoint calculate alopeyk price.

Request Parameters

Parameter Required type Description
parcel_specs true integer parcel_specs specify parcel is letter or SMALL_PARCEL.
addresses[0][type] true string Must be of type origin.
addresses[0][lat] true float Latitude of the origin address.
addresses[0][lng] true float Latitude of the origin address.

Response Descriptions

Attribute Description
status Indicates that the calculation progress has been successful or not.
price Total calculated price.
credit Indicates payment type of the order (payment by credit or cash). Will be true only if you have enough credit on your account for that order. In the case of credit deficiency, or cashed=true, this attribute will be set to false.
distance Estimated distance between the source and the destination.
duration Estimated duration of the path between the source and the destination.
user_credit Your current credit (in Tomans).
price_with_return Calculated price for the order, in case of has_return=true.

POST
AloPost Post Calculate price

curl --location --request POST '{{alopost-url}}/api/v1/postal/calculate/price' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {$token}' \
--data-raw '{
    "weight": 10,
    "parcel_type": 1,
    "parcel_service_type": 1,
    "addresses": [
        {
            "city_code": 1
        },
        {
            "city_code": 81
        }
    ],
    "insurance_type": 1,
    "insurance_amount": 200000000,
    "wrapping_type": 1
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{alopost-url}}/api/v1/postal/calculate/price",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(
    [
      "weight"              => 10,
      "parcel_type"         => 1,
      "parcel_service_type" => 1,
      "addresses" => [
        [
          "city_code" => 1
        ],
        [
          "city_code" => 81
        ]
      ],
      "insurance_type"   => 1,
      "insurance_amount" => 200000000,
      "wrapping_type"    => 1
    ]
  ),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {$token}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({
    "weight": 10,
    "parcel_type": 1,
    "parcel_service_type": 1,
    "addresses": [
        {
            "city_code": 1
        },
        {
            "city_code": 81
        }
    ],
    "insurance_type": 1,
    "insurance_amount": 200000000,
    "wrapping_type": 1
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{alopost-url}}/api/v1/postal/calculate/price");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {$token}");

xhr.send(data);

Calculate price of parcel with iran national post company api.

Request Parameters

Parameter Required type Description
parcel_type true integer Parcel type that specify type of parcel. National Post Company of Iran support PACKAGE_VANGUARD ( پاکت پیشتاز ) currently.
parcel_service_type true integer parcel service type that specify parcel send with VANGUARD ( پیشتاز ) or CUSTOM_BUILT ( سفارشی ) type in National Post Company of Iran
insurance_type true integer insurance type that Specifies the type of product to send and this is effective in price
wrapping_type true integer wrapping type that specify type of wrapping for parcel. It depends on volumn and size of parcel.
weight true integer weight of parcel
insurance_amount true integer Insurance amount specify the value of parcel.
addresses[0][city_code] true integer City code that you can get in list of cities entrypoint
addresses[1][city_code] true float City code that you can get in list of cities entrypoint

Response Descriptions

Attribute Description
status Indicates that the calculation progress has been successful or not.
message Message of postal api
credit Indicates payment type of the order (payment by credit or cash). Will be true only if you have enough credit on your account for that order. In the case of credit deficiency, or cashed=true, this attribute will be set to false.
data[totalprice] Final price of parcel
data[postprice] This price is ( postal_income + tax_price )
data[postfare] Iran National Post Company share right
data[insuranceprice] Insurance price of parcel from iran National Post Company api.
data[wrappingprice] Wrapping price of parcel from iran National Post Company api.
data[tax] Tax price of parcel from iran National Post Company api.

COD
Service

GET
Get Configs

curl --location --request GET '{{COD-url}}/api/v1/config' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/config",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/config");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Fetchs COD configs. These configs will be used by clients.

GET
Product Categories

curl --location --request GET '{{COD-url}}/api/v1/categories' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/categories",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/categories");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves a list of valid categories for the product that is going to be sent.

Orders

POST
COD Create Order

curl --location --request POST '{{COD-url}}/api/v1/orders' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-raw '{
  "addresses": [
      {
      "address": "تهران، میدان آرژانتین خیابان بخارست خیابان دهم پلاک ۲۳ واحد ۲",
      "description": "ندارد",
      "lat": "35.728518",
      "lng": "51.403380",
      "mobile": "09490000000",
      "name": "sara",
      "number": "23",
      "type": "origin",
      "unit": "1"
    },
    {
      "address": "تهران، میدان فردوسی بعد از چهارراه سپند کوچه خسرو پلاک ۲۲۵",
      "description": "ندارد",
      "lat": "35.710139",
      "lng": "51.398535",
      "mobile": "09490000000",
      "name": "sara",
      "number": "23",
      "type": "destination",
      "unit": "1"
    }
  ],
  "credit_card_number": "740570036780014002938101",
    "customer_name": "شخص خودم",
    "customer_phone": "09490000000",
    "description": "ندارد",
    "package_price": 1100,
    "transport_type": "motorbike",
    "product_category_id": "22",
    "package_description": "cod",
    "product_category_description" : "fdfd"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(
      [
      "addresses" => [
        [
          "address"     => "تهران، میدان آرژانتین خیابان بخارست خیابان دهم پلاک ۲۳ واحد ۲",
          "description" => "ندارد",
          "lat"         => "35.728518",
          "lng"         => "51.403380",
          "mobile"      => "09490000000",
          "name"        => "sara",
          "number"      => 23,
          "type"        => "origin",
          "unit"        => 1
        ],
        [
          "address"     => "تهران، میدان فردوسی بعد از چهارراه سپند کوچه خسرو پلاک ۲۲۵",
          "description" => "ندارد",
          "lat"         => "35.710139",
          "lng"         => "51.398535",
          "mobile"      => "09490000000",
          "name"        => "sara",
          "number"      => 23,
          "type"        => "destination",
          "unit"        => 1
        ]
      ],
      "credit_card_number"           => "740570036780014002938101",
      "customer_name"                => "شخص خودم",
      "customer_phone"               => "09490000000",
      "description"                  => "ندارد",
      "package_price"                => 1100,
      "transport_type"               => "motorbike",
      "product_category_id"          => 22,
      "package_description"          => "cod",
      "product_category_description" =>"fdfd"
    ]
  ),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({
  "addresses": [
      {
      "address": "تهران، میدان آرژانتین خیابان بخارست خیابان دهم پلاک ۲۳ واحد ۲",
      "description": "ندارد",
      "lat": "35.728518",
      "lng": "51.403380",
      "mobile": "09490000000",
      "name": "sara",
      "number": "23",
      "type": "origin",
      "unit": "1"
    },
    {
      "address": "تهران، میدان فردوسی بعد از چهارراه سپند کوچه خسرو پلاک ۲۲۵",
      "description": "ندارد",
      "lat": "35.710139",
      "lng": "51.398535",
      "mobile": "09490000000",
      "name": "sara",
      "number": "23",
      "type": "destination",
      "unit": "1"
    }
  ],
  "credit_card_number": "740570036780014002938101",
    "customer_name": "شخص خودم",
    "customer_phone": "09490000000",
    "description": "ندارد",
    "package_price": 1100,
    "transport_type": "motorbike",
    "product_category_id": "22",
    "package_description": "cod",
    "product_category_description" : "fdfd"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{COD-url}}/api/v1/orders");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send(data);

You can register cod order using this api.

Request Parameters

Parameter Required type Description
credit_card_number true string Sheba number of the seller.
customer_name true string Full name of the destination customer.
customer_phone true string Cell phone of the destination customer.
package_price true integer Price of the parcel that is going to be sent to the customer.
product_category_id true integer Category id for the parcel that is going to be sent to the customer.
package_description true string A brief description about the product that the seller is trying to sell.
product_category_description false string If seller chose سایر for product category we need a description for product’s category
scheduled_at false Date Time You can set scheduled at such as this format (2020-01-07 11:02:44). Created order will be dispatched at this time.

GET
Retrieve Payment URL

curl --location --request GET '{{COD-url}}/api/v1/orders/{order_id}/retrieve_payment_url' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/{order_id}/retrieve_payment_url",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/{order_id}/retrieve_payment_url");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Gets the text that is going to be sent to the customer. This text contains a url which redirects the cutomer to the before payment web page.

URL Parameters

Parameter Required type Description
orderId true integer Order ID

GET
Get Order by id

curl --location --request GET '{{COD-url}}/api/v1/orders/{order_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/{order_id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/{order_id}");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieve a single order by its id

URL Parameters

Parameter Required type Description
orderId true integer Order ID

GET
Remove Order by id

curl --location --request GET '{{COD-url}}/api/v1/orders/{order_id}/remove' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/{order_id}/remove",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/{order_id}/remove");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Soft deletes an order from database.

URL Parameters

Parameter Required type Description
orderId true integer Order ID

GET
Print Order Invoice

curl --location --request GET '{{COD-url}}/api/v1/orders/{token}/print_invoice' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/{token}/print_invoice",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/{token}/print_invoice");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Provides a printable invoice page for the requested order.

URL Parameters

Parameter Required type Description
token true string Unique token of the order

POST
Reset Payment URL

curl --location --request POST '{{COD-url}}/api/v1/orders/{order_id}/reset_payment_url' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-raw ''
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/{order_id}/reset_payment_url",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = "";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{COD-url}}/api/v1/orders/{order_id}/reset_payment_url");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send(data);

Regenerate the payment url.

URL Parameters

Parameter Required type Description
orderId true integer Order ID

POST
Change Package Price

curl --location --request POST '{{COD-url}}/api/v1/orders/{order_id}/reset_payment_url' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-urlencode 'price=1100'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/{order_id}/reset_payment_url",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "price=1100",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = "price=1100";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{COD-url}}/api/v1/orders/{order_id}/reset_payment_url");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send(data);

Update package’s price and regenerate the payment url.

URL Parameters

Parameter Required type Description
orderId true integer Order ID

Body Parameters

Parameter Required type Description
price true integer New price for the package

GET
Get Payment Status

curl --location --request GET '{{COD-url}}/api/v1/orders/{order_id}/payment_status' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}}/api/v1/orders/{order_id}/payment_status",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/{order_id}/payment_status");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Get payment status of the package

URL Parameters

Parameter Required type Description
orderId true integer Order ID

Response Descriptions

Attribute Description
paid Indicates if price of the package has been paid or not

Finance

POST
Transfer Credit

curl --location --request POST '{{COD-url}}/api/v1/credit_transfer' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-raw '{
    "amount" : 1000
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/credit_transfer",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(["amount" => 1000]),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({"amount":1000});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{COD-url}}/api/v1/credit_transfer");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send(data);

Transfer COD credit to alopeyk account for the authenticated user

Body Parameters

Parameter Required type Description
amount true integer Credit amount that is going to be transferred

GET
Refund Request

curl --location --request GET '{{COD-url}}/api/v1/refund_request' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/refund_request",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/refund_request");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Registers a refund request in COD for authenticated user.

GET
Get Transactions

curl --location --request GET '{{COD-url}}/api/v1/transactions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/transactions",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/transactions");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves a paginated list of authenticated user’s transactions

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
PayOff Information

curl --location --request GET '{{COD-url}}/api/v1/pay-off' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/pay-off",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/pay-off");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retirieves a summary of authenticated user’s financial activity within COD.

Response Descriptions

Attribute Description
total_sale_price Sum of the price of the packages that authenticated user has successfuly sold via COD.
not_receivable_amount This amount cannot be refunded yet.
receivable_amount This amount can be refunded as per user’s request.
transferable_amount This amount can be transferred to alopeyk’s credit.
requested_amount This amount is already requested to be refunded and is in autopay queue.
sum_of_all_paid Sum of the amounts that have been paid to the user until now.
tax_and_transaction_fee Sum of the taxes and transaction fees that have been withdrawd from user’s account.
transferred_to_alopeyk Sum of the transferred amounts.
national_code National code of the user.
sheba_number
account_holder_name
bank_name

User Info

GET
Get National Code

curl --location --request GET '{{COD-url}}/api/v1/users/national_code' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/users/national_code",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/users/national_code");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieve authenticated user’s national code from database.

Response Descriptions

Attribute Description
national_code National code of the authenticated user.

POST
Set National Code

curl --location --request POST '{{COD-url}}/api/v1/users/national_code' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-raw '{
    "national_code" : 1111111111
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/users/national_code",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(["national_code" => 1111111111]),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({"national_code":1111111111});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{COD-url}}/api/v1/users/national_code");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send(data);

Set national code for authenticated user

Body Parameters

Parameter Required type Description
national_code true string a valid national code

GET
Get Sheba Number

curl --location --request GET '{{COD-url}}/api/v1/users/sheba' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/users/sheba",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/users/sheba");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves sheba number and owner of the sheba number for authenticated user.

Response Descriptions

Attribute Description
sheba Sheba number.
owner fullname of the account’s owner.

POST
Set Sheba Number

curl --location --request POST '{{COD-url}}/api/v1/users/sheba' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-raw '{
    "owner":"رضا رضایی",
  "sheba":"IR111111111111111111111111"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/users/sheba",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(
    [
      "owner" => "رضا رضایی",
      "sheba" => "IR111111111111111111111111"
    ]
  ),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({"owner":"رضا رضایی","sheba":"IR111111111111111111111111"});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{COD-url}}/api/v1/users/sheba");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send(data);

Set a new sheba number for authenticated user.

Body Parameters

Parameter Required type Description
owner true string Owner’s name of the sheba number
sheba true string Sheba number

POST
Validate Sheba Number

curl --location --request POST '{{COD-url}}/api/v1/users/sheba-check' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' \
--data-raw '{
    "sheba" : "IR111111111111111111111111"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/users/sheba-check",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(["sheba" => "IR111111111111111111111111"]),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var data = JSON.stringify({"sheba":"IR111111111111111111111111"});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{COD-url}}/api/v1/users/sheba-check");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send(data);

Check if a sheba number is valid or not.

Body Parameters

Parameter Required type Description
sheba true string Sheba number

Response Descriptions

Attribute Description
isSuccess Indicates if the sheba number is valid.
sheba Provided sheba number.
firstName firstname of the account’s owner.
lastName lastname of the account’s owner.
fullName fullname of the account’s owner.
isActive Indicates if provided sheba number is currently active.

GET
Get Credit

curl --location --request GET '{{COD-url}}/api/v1/users/credit' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/users/credit",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/users/credit");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves credit of authenticated user.

Response Descriptions

Attribute Description
credit COD credit of the user. This value is the sum of all withdraws and deopsits in user’s COD account.

Statuses

Retrieves filtered orders by status of the authenticated user.

GET
Archived Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/archived' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/archived",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/archived");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the archived orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Failed Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/failed' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/failed",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/failed");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the failed orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Active Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/active' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/active",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/active");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the active orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Scheduled Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/scheduled' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/scheduled",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/scheduled");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the scheduled orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
New Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/new' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/new",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/new");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the new orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
PickedUp Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/picked_up' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/picked_up",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/picked_up");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the PickedUp orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Accepted Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/accepted' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/accepted",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/accepted");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the accepted orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Rejected Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/rejected' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/rejected",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/rejected");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the rejected orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Delivered Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/delivered' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/delivered",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/delivered");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the delivered orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Returned Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/returned' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/returned",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/returned");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the returned orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Finished Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/finished' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/finished",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/finished");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the finished orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

GET
Cancelled Orders

curl --location --request GET '{{COD-url}}/api/v1/orders/state/cancelled' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{COD-url}}/api/v1/orders/state/cancelled",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer {{token}}"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "{{COD-url}}/api/v1/orders/state/cancelled");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer {{token}}");

xhr.send();

Retrieves all the cancelled orders of the authenticated user.

Request Parameters

Parameter Required type Description
page false integer If you need to paginate the results use this parameter to specify the number of the page that you wish to fetch its data
perpage false integer If you need to paginate the results use this parameter to specify the number of the items within each page.

Credit

GET
Get Credit

curl 'https://sandbox-api.alopeyk.com/api/v2/show-profile' \
  -X GET \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json; charset=utf-8' \
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/show-profile",
  CURLOPT_RETURNTRANSFER => **true**,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "Content-Type: application/json; charset=utf-8",
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://sandbox-api.alopeyk.com/api/v2/show-profile');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');

xhr.send(data);

The above command returns a JSON response structured like this:

{
  "status": "success",
  "message": null,
  "object": {
    "id": 196,
    "phone": "09*********",
    "firstname": "***",
    "lastname": "*****",
    "type": "CUSTOMER",
    "email": "*******@***.com",
    "city": "tehran",
    "email_verified": 0,
    "verify": 1,
    "found_us": "",
    "referral_code": null,
    "referred_by": null,
    "created_at": "2017-10-03T13:16:32+03:30",
    "updated_at": "2017-10-03T13:16:56+03:30",
    "deleted_at": null,
    "credit": 0,
    "referred_by_user": null,
    "list_referred_users": null,
    "avatar": {
      "url": "/uploads/user/196/avatar.jpg?var=*******"
    },
    "abs_avatar": {
      "url": "https://api.alopeyk.com/uploads/user/196/avatar.jpg?var=*******"
    },
    "last_online": null,
    "is_online": null,
    "customer": {
      "id": 71,
      "user_id": 196,
      "notifications": null,
      "is_api": true,
      "is_vip": 0,
      "webhook": "",
      "options": [],
      "tier": "blue",
      "tiered_at": "2017-10-03T13:16:32+03:30",
      "tiered_till": "2018-10-03T13:16:32+03:30",
      "total_turnover": null,
      "loyalty_score": null,
      "total_score": null,
      "annual_turnover": null,
      "company_name": null,
      "company_info": null,
      "created_at": "2017-10-03T13:16:32+03:30",
      "updated_at": "2018-12-23T14:30:36+03:30",
      "deleted_at": null,
      "verified_at": "2018-12-23 14:30:36",
      "ban_id": null,
      "banned_at": null,
      "banned_till": null
    },
    "score": 0
  }
}

In order to view your AloPeyk account credit and score, you can use this method.

HTTP Request

GET https://sandbox-api.alopeyk.com/api/v2/show-profile

Response Parameters

Parameter Description
credit The amount of your AloPeyk credit in IRAN Toman.

POST
Transfer Credit

curl 'https://sandbox-api.alopeyk.com/api/v2/transactions/transfer' \
  -X POST \
  -H 'Authorization: Bearer {$token}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'Content-Type: application/json; charset=utf-8' \
  --DATA '{"amount":1000,"phone":"09*********"}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://sandbox-api.alopeyk.com/api/v2/transactions/transfer",
  CURLOPT_RETURNTRANSFER => **true**,
  CURLOPT_ENCODING       => "",
  CURLOPT_MAXREDIRS      => 10,
  CURLOPT_TIMEOUT        => 30,
  CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST  => "POST",
  CURLOPT_POSTFIELDS     => json_encode(
    [
      "amount" => 1000,
      "phone"  => "09*********",
    ]
  ),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . $token,
    "Content-Type: application/json; charset=utf-8",
    "X-Requested-With: XMLHttpRequest"
  ],
]);

$response = curl_exec($curl);
$err      = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
var data = JSON.stringify({
  "amount": 1000,
  "phone": "09*********"
});

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://sandbox-api.alopeyk.com/api/v2/transactions/transfer');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');

xhr.send(data);

The above command returns a JSON response structured like this:

{
    "status": "success",
    "message": null,
    "object": true
}

In order to transfer AloPeyk credit to another AloPeyk account, the only information you need is target account phone number and amount of transformation.

It should be noted that transfer amount must be equal or less than your AloPeyk account credit.

HTTP Request

POST https://sandbox-api.alopeyk.com/api/v2/transactions/transfer

Request Parameters

Parameter Default Required Description
amount NULL true The amount of AloPeyk credit that you want to transfer in IRAN Toman.
phone NULL true The phone number that you want to transfer credit to it. it should be a valid AloPeyk customer phone number.

Errors

Error Code Meaning
400 Bad Request – Your request is invalid.
401 Unauthorized – Your JWT token is invalid.
403 Forbidden – You do not enough permissions to perform this action.
404 Not Found – The specified resource could not be found.
405 Method Not Allowed – You tried to access an API endpoint with an invalid REST method.
406 Not Acceptable – You requested by a format that isn’t JSON.
410 Gone – The requested resource has been removed from our servers.
429 Too Many Requests – You’re requesting too many resources.
500 Internal Server Error – We had a problem with our server. Try again later.
502 Bad Gateway – The server cant handle your request for the moment. Try again later.
503 Service Unavailable – We’re temporarially offline for maintanance. Please try again later.

In this case response code is 200, but it still indicates an error.

Error Const Meaning
UNKNOWN_ERROR An unknown reason prevented us to perform the action you have requested.
FORBIDDEN_ERROR You are going to perform an action which is not allowed.
INVALID_REQUEST_ERROR You have sent an invalid request.
ORDER_NOT_FOUND_ERROR The order on which you are going to perform an action was not found.
ORDER_CANCELLED_ERROR The order on which you are going to perform an action has been already cancelled.
USER_MINUS_CREDIT_ERROR Your account credit has gone under zero, so you can’t create a new order.
LIMIT_EXCEEDED_ERROR Your current active (not finished) orders count has exceeded our limit, so you can’t create a new one until you finish one of them.