# API CANCEL COURSIER.FR V3 (EN)

<table border="1" id="bkmrk-08%2F06%2F2020-version-3" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 33.3333%;">12/11/2020</td><td style="width: 33.3333%;">[![image-1662457811981.png](https://bookstack.digf.fr/uploads/images/gallery/2022-09/scaled-1680-/image-1662457811981.png)](https://bookstack.digf.fr/uploads/images/gallery/2022-09/image-1662457811981.png)</td><td class="align-right" style="width: 33.3333%;">Version 3.1</td></tr></tbody></table>

##### **Objective**

Cancel a given mission. This can be done until the mission is dispatched to one of our courriers and until 1 hour before the pickup start date. In case of a mission with shuttle, we consider the pickup start date from our hub, not from the customer (which concerns the shuttle).

##### **Protocol**

Requests are made via HTTPS with the url <u>api.coursier.fr/v3/cancel.php,</u> the response is a JSON containing all the delivery information, which let you do a final check to be sure you've cancelled the right mission. In case of fragmentation, several records will be sent, each with their own information.

##### **Authentication**

The authentication happens with an apikey paired to your coursier.fr user, these informations can be found in your customer area. You must have a monthly billing account, if it is not the case, you may contact a salesman at <commercial@coursier.fr>. You must give as parameters the apikey, the user and the customer account used (a user can be associated with several customer accounts).

In order to test our APIs, as of now you may use the following testing account to begin your developping tasks while you wait for your definitive credentials :

User : <test@apicfr.fr>

Pass : T3stCFR\*

ClientId : 7055339

Apikey : e1ab1411d66765e73cf4b068d39cda8a

##### **Parameters**

Parameters must be send in a JSON array using the POST method.

<table id="bkmrk-nom-requis-type-desc" style="width: 0px;" width="614"><tbody><tr><td style="width: 222px;">**NAME**

</td><td style="width: 107px;">**REQUIRED**

</td><td style="width: 116px;">**TYPE**

</td><td style="width: 357px;">**DESCRIPTION**

</td></tr><tr><td style="width: 222px;">User

</td><td style="width: 107px;">Y

</td><td style="width: 116px;">Varchar(32)

</td><td style="width: 357px;">User to access the coursier.fr interfaces

</td></tr><tr><td style="width: 222px;">Apikey

</td><td style="width: 107px;">Y

</td><td style="width: 116px;">Varchar(32)

</td><td style="width: 357px;">Apikey linked to your user

</td></tr><tr><td style="width: 222px;">ClientId

</td><td style="width: 107px;">Y

</td><td style="width: 116px;">int

</td><td style="width: 357px;">Customer account number

</td></tr><tr><td style="width: 222px;">MissionNumber

</td><td style="width: 107px;">Y

</td><td style="width: 116px;">int

</td><td style="width: 357px;">ID of the delivery, obtained when placing the order.

</td></tr><tr><td style="width: 222px;">Lang

</td><td style="width: 107px;">N

</td><td style="width: 116px;">varchar(2)

</td><td style="width: 357px;">Language code for the retrieval of messages (default ; FR)

</td></tr></tbody></table>

##### **JSON Response**

The response is a JSON array with all the related information to the delivery or the delivery fragment given. In case of error, the API returns a JSON with a Message field specifying the nature of the error.

<table id="bkmrk-nom-taille-descripti" style="width: 810px; height: 1066px;"><tbody><tr style="height: 35px;"><td style="width: 225px; height: 35px;">**NAME**

</td><td style="width: 116px; height: 35px;">**TYPE**

</td><td style="width: 469px; height: 35px;">**DESCRIPTION**

</td></tr><tr style="height: 79px;"><td style="width: 225px; height: 79px;">MissionId

</td><td style="width: 116px; height: 79px;">int

</td><td style="width: 469px; height: 79px;">ID of the delivery, in case of load failure the ID is different for every fragment.

</td></tr><tr style="height: 79px;"><td style="width: 225px; height: 79px;">MissionNumber

</td><td style="width: 116px; height: 79px;">int

</td><td style="width: 469px; height: 79px;">Number of the delivery, this number is the key to interact with our courier or the customer service.

</td></tr><tr><td style="width: 225px;">From

</td><td style="width: 116px;">varchar(80)

</td><td style="width: 469px;">Name of the pick-up address

</td></tr><tr><td style="width: 225px;">To

</td><td style="width: 116px;">varchar(80)

</td><td style="width: 469px;">Name of the shipping address

</td></tr><tr style="height: 57px;"><td style="width: 225px; height: 57px;">PickupStartDate

</td><td style="width: 116px; height: 57px;">Datetime

</td><td style="width: 469px; height: 57px;">Beginning of the pick-up slot

</td></tr><tr style="height: 57px;"><td style="width: 225px; height: 57px;">PickupEndDate

</td><td style="width: 116px; height: 57px;">Datetime

</td><td style="width: 469px; height: 57px;">End of the pick-up slot

</td></tr><tr style="height: 57px;"><td style="width: 225px; height: 57px;">DeliveryStartDate

</td><td style="width: 116px; height: 57px;">Datetime

</td><td style="width: 469px; height: 57px;">Beginning of the shipping slot

</td></tr><tr style="height: 57px;"><td style="width: 225px; height: 57px;">DeliveryEndDate

</td><td style="width: 116px; height: 57px;">Datetime

</td><td style="width: 469px; height: 57px;">end of the shipping slot

</td></tr></tbody></table>

##### **API call example**

```PHP
<?php
$Url = "https://api.coursier.fr/v3/cancel.php";
$Data = array('User' => 'test@apicfr.fr',
			  'Apikey' => 'e1ab1411d66765e73cf4b068d39cda8a',
			  'ClientId' => '7055339',
			  'MissionNumber' => '9005657',
			  'Lang' => 'FR',
			 );

$datajson = json_encode($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datajson);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($curl);
curl_close($curl);
var_dump($res);
?>
```

##### **Response example**

<p class="callout success">\[{"MissionId":"10013192","MissionNumber":"9012846","From":"COURSIER.FR","To":"LE BHV MARAIS","PickupStartDate":"2020-10-25 07:30:00","PickupEndDate":"2020-10-25 10:00:00","DeliveryStartDate":"2020-10-25 08:00:00","DeliveryEndDate":"2020-10-25 10:00:00"}\] </p>