API calls

 

For ecommerce software (Magento, Prestashop, WooCommerce, Opencart) see the pre-made plugins.


To add an order form in your website, where customers can create shipments without logging in, you can adapt this PHP example.


To integrate shipment tracking and client registration/login in your website, use the Settings/Integrations menu, then copy and adapt the links and forms there.

 

URL

Each instance of the CurierManager app may have its own base URL. The generic api url is:

BaseURL/API/<operation>?api_key=<api key>&…

For example if your software instance is http://app.curiermanager.ro/cscourier/ (but it may differ in your case) the full URL to create an expedition will be:

http://app.curiermanager.ro/cscourier/API/create_awb?api_key=<api_key>&...

The API Key will be created by the courier company. The rest of the parameters are also given as GET/POST parameters (no JSON for input params).
Security note: if it is expected for a request URL to end up in a browser address bar, there is the risk of making the API key public. Please note that even using the api key in a development environment risks URLs to leak due to various browser plugins sending meta-data home. Another example is using print URLs as links, which may lead to them being printed as the page header - including the api key. Therefore, we recommend against using the api key in public GET requests. You also have the option of using the HTTP header field "api_key". Also, of course, the SSL version is always preferred.

Return Value
All responses are a JSON map, with the following fields:
- status can be "done", "forbidden" or "failed"
- message is a text field that usually explains the status
- data contains the detailed response.

 The API can be tested using the following address

BaseURL/test_api.html

Create expedition

API/create_awb?api_key=<api key>

The following fields can be added:

"type", "service_type", "retur", "retur_type", "ramburs", "ramburs_type", "insurance", "weight", "content", "comments", "cnt", "content", "customer_reference", "fragile", "width", "height", "length", 

from_name, from_contact, from_str, from_nr, from_bl, from_sc, from_et, from_ap, from_interfon, from_sector, from_city, from_county, from_zipcode, from_country, from_phone,

to_name, to_contact", to_str, to_nr, to_bl, to_sc, to_et, to_ap, to_interfon, to_sector, to_city, to_county, to_country, to_zipcode, to_phone, to_extra, to_cui, to_regcom

type: envelope | package 

service_type: obtain from courier company (eg: regular, express). you can also use the list_services API mentioned below, with type=main

retur: 0 | 1  -  Package swap

cnt: number of packages/envelopes

retur_type: colet | document

ramburs: <CoD amount>

ramburs_type: cont | cash | instrumente_plata  -  CoD type, with values meaning account, cash or check.

weight: <weight in kg>

insurance: insured value

payer: who is paying the cost of transport for this shipment. Allowed values are:

- client (default value), if the payment will be made by the contracted client, usually on a monthly invoice

- sender|expeditor, if the payment is made in cash by the sender

- recipient | destinatar, if the payment is made in cash by the recipient.

 

from_... fields are used for the sender address, to_... fields for the recipient address

...name: name, company name if applicable

...contact: contact within company

...str: street

...nr: street number

...bl: building

...sc: entrance

...interfon: interphone number

to_extra: any extra information regarding recipient address

use_default_from_address: if "true", it will use the default expedition address in the system instead of the fields above.

There are no mandatory fields except api_key, but you should be aware that expeditions lacking relevant information most likely can't be delivered.

Expeditions with the "cnt" set to values over 1 will be automatically converted to groups. You will receive in the response the number of the first package in the group (like "XXX"), and the rest are created as such:
1st package: XXX
2nd package: XXX/2
3rd package: XXX/3
And so on.

Any number of extra services (like “Delivery Saturday”) can be specified, each by adding a parameter like service_<service id> with the value true. For example if Delivery Saturday has the id 57, you would have: service_57=true
Do not use "1" as synonym for "true" - it is a common cause of problems.

The full list of services can be obtained through the API using the URL:

API/list_services?api_key=<api key>&type=[main|extra]

Return value

The data field contains a map with the created expedition. Expedition number is in the "no" field.

The status for the created expedition will be uncollected by default (neridicat for Romanian accounts). It can be changed from the Settings menu (Initial_api_status).

awb_event_handler is an optional parameter which can be used when creating the awb. It contains an URL towards which the system will send event call – GET requests, having the content parameter added containing a JSON map with the following fields:

  • awb – awb number
  • status – awb status

 Right now the system is sending events for status changes.

Events are being sent asynchronously, with a delay of max 60s.

Get price

API/get_price?api_key=<api key>

Takes the same parameters as API_createAWB, and returns a map with fields "price" and "zone"

Print AWB

API/print?api_key=<apikey>&awbno=<awbno>

Returns the HTML version of the printed waybill.

If you want to save the awb in a pdf format add &pdf=true

You can change the format with the parameter format, with the legal values: a6, default. The default value is approximately a5. 

Get shipment status:

API/get_status?api_key=<apikey>&awbno=<awbno>

Returns a text with the current expedition status.

Change shipment status:

API/change_status?api_key=<apikey>&awbno=<awbno>&status=<newstatus>

Changes the status of the expedition. Can be used to change status from draft to uncollected, from uncollected to active. Can also be used to cancel an expedition, if the permissions to do so are granted.

Get shipment info:

API/get_info?api_key=<apikey>&awbno=<awbno>

Returns a JSON map consisting of:

  • text fields with expedition info ("id", "no", "status", "from_address", "to_address", "from_city", "to_city", "from_country", "to_country", "ramburs", "ramburs_type")
  • "invoice", which contains a map with invoice info (date as unixtime, series, no, value - invoice value without VAT)
  • "decont_client", which contains a map with client settlement info: date as unixtime, transaction_no, value

 

Get Proof of Delivery:

API/get_POD?api_key=<apikey>&awbno=<awbno>&type=<picture|signature>

type is optional and defaults to "picture".

If there is a document of that type, it will download it. If there are several documents of the same type it will download only the most recent one.
Extension of downloaded documents may vary - currently we have jpg and pdf in use.

 

Get shipment history:

API/get_history?api_key=<apikey>&awbno=<awbno>&full=[true|false]

Returns a json map with the fields "no", "status" and "history", where history is a list of status changes with the fields:  date (unixtime), status and description.

If the parameter full is true and the api key is not a client api key (i.e. is a courier api key), it will add extra raw information from the database - both extra rows and extra fields.

 

Cancel an shipment:

API/cancel?api_key=<apikey>&awbno=<awbno>

Returns "ok" in case of success, or "forbidden" if the api key client does not have the permission to cancel shipments.



Get shipments list

API/get_shipments?api_key=<apikey>&from_date=<date>&to_date=<date>

Returns a json list of shipments.

The from_date and to_date parameters should be dd-MM-yyyy.
 

Get city list

API/list_cities?api_key=<apikey>

Returns a json list of cities, with the fields "name" and "province" for each.

 

Get invoice list

API/list_invoices?api_key=<apikey>&from_date=<date>&to_date=<date>&include_open=[true|false]

Returns a json list of invoices.

The from_date and to_date parameters should be dd-MM-yyyy.
 

 

Get saved addresses

API/list_addresses?api_key=<apikey>&only_common=[true|false]

Returns the raw list of saved addresses. If the api key is not attached to a client, it will return the saved addresses for all clients. If only_common is true, it will returned only predefined addresses that are public to all clients.
 

 

The life-cycle of an expedition

An expedition can have one of the following statuses:

  • draft – it can still be edited by the client. It is not ready for pick-up
  • uncollected – it is ready and waiting for pickup
  • active - being delivered
  • delivered - the expedition has been delivered successfully
  • returned - the expedition has been returned for some reason
  • canceled -  the expedition has been canceled before pickup
  • exception - anything else

Romanian companies will use Romanian language status names. These are: initial, neridicat, in_curs, livrat, returnat, anulat, exceptie.

Search support