LastMile Delivery

API Documentation for LastMile Denmark
LastMile API

Welcome to the Lastmile Delivery API documentation.

LastMile is an independent delivery service in Denmark.

We hope the integration will be easy and if you have any questions, please direct them to soren@lastmile.nu

What can I do with the API?

The API will grant you access the LastMile delivery system. You need to be either a client or a partner. Once a partner or a client you will receive an API-token.

What is the difference between a partner and a client?

A client is a single business who needs a delivery service. The client either orders the driver manually or is integrating LastMile delivery API to its webshop.

A partner has multiple clients who needs a reliable delivery a service. The Partner is in charge of the order flow for the client. The partner requests the delivery service on behalf of the client. The partner is in charge of billing the client as LastMile will send on combined invoice to the partner. Each client will get a unique API-token.

Delivery create
POST /delivery/create

For ordering a courier to make a pickup, you need to send this post request. The pickup information is automatically deducted from the API-token used (each client (pickup place) needs its own token)

If the wanted time is not possible, the order will be pushed into the future. You will be notified that the order is pushed and you will receive the time the courier arrives. If the time is not acceptable, you need to cancel the pickup.

Address If you already have the latitude and longitude of the customer, please send them along. This can avoid some errors.

Request parameters

firstname
string required

The name of person who is receiving the order

telephone
string required

The telephone number of the person receiving the order. Our courier needs to get a hold of the customer from time to time

Min length: 8
Example:
40414243
street
string required

Our courier needs to know where to deliver the order

Example:
Vestergade 65
zip
string required

The zip code of address of the person receiving the order

Example:
5000
city
string optional

The corresponding city to the zip code

Example:
Odense C
country
string optional

Country where the address is locate. Please write in local tounge. (Danmark, Sverige, Norge)

time
string required

The time where the order should be picked up at the pickup-site. either: HH:II or YY-MM-DD HH:II for future orders

Example:
20:00
latitude
string required
longitude
string required
paid
boolean optional

if the paid = false, the order is not paid and the restaurant must charge the customer in the store

Default:
true
delivery
string optional

If you use the LastMile iPad solution where the order content is displayed, use this to distinguish orders that are for delivery and orders where the end customer will come pick it up. 1=Delivery, 0=Self pickup. Default value is 1

Example:
1
ordercontent
string optional

If you use the LastMile iPad solution where the ordercontent is displayed,wrap the order content in json and send it

Example:
{"items":[{"product":"Cheeseburger menu","amount":1,"unitprice":100,"remarks":"No onions","extras":[{"product":"Potato Fries","amount":1,"unitprice":0,"remarks":"More cheese please"},{"product":"Coca-Cola","amount":1,"unitprice":0,"remarks":"no ice please"},{"product":"Mayo","amount":4,"unitprice":0,"remarks":"no ice please"}]},{"product":"Cheeseburger","amount":1,"unitprice":70,"remarks":"","extras":[]},{"product":"Pizza pepperoni","amount":1,"unitprice":30,"remarks":"Extra cheese","extras":[]},{"product":"The Classic","amount":1,"unitprice":120,"remarks":"","extras":[{"product":"Pommes Frites","amount":1,"unitprice":10},{"product":"Coca Cola","amount":1,"unitprice":0},{"product":"Ketchup","amount":1,"unitprice":2}]}]}
order_id_at_partner
string optional

your own id of the order (The order id you send to the restaurant)

Example:
111b11
restaurantdelivery
string optional

To indicate if the restaurant handles the delivery them self

Example:
0

Request headers

Accept
string optional

application/json

Authorization
string optional

Insert correct Bearer token here

Example:
Bearer ABC123

Responses

201 Created

If succesfull

Body
Object
properties
error
boolean

if successfull the error will be false

message
string
Example:
The delivery has been booked
data
Object

Here is where it gets interestring

push
boolean

if we cannot arrive at the requested time, this will be true.

early
boolean

In rare cases, we will offer an earlier time. Push will be true and early will be true. This is currently disabled.

wanted
string

The requested time send.

Example:
2019-02-14 20:00
time
string

The time the courier arrives at the pickup place

Example:
2019-02-14 20:00
arrive_at_dropoff
string

The time the courier is expected to arrive at the person with the order

Example:
2019-02-14 20:03
distance
integer

The distance from pickup to dropoff in meters

Example:
1718
price
integer

The price. This price is individual based on the clients. This is the price LastMile will charge the client or partner

Example:
68
price_with_vat
integer
Example:
85
next_available_after
Object

If early is true, this will be presented. Otherwise this will be null

nextTime
string

the next possible pickup

Example:
20:49
nextArriveAtDropoff
string

Arrival at dropoff site

Example:
21:56
uid
string

This string is unique for this delivery. Keep it. You will need it if you have to cancel or recieve updates regarding the delivery.

Example:
rqtKqoaWUx
additional properties
string
401 Unauthorized

Forgot the Bearer token ?

Body
Object
message
string
Example:
Unauthenticated.
400 error

You get this kind of error if something is wrong. Check the message

Body
Object
error
boolean
Example:
true
message
string
Example:
required field cannot be empty
Delivery cancel
POST /delivery/cancel

If you need to cancel a delivery, this is how you do it. When you created the delivery, you received a ‘uid’. You need that to cancel the delivery. The motivation for using a ‘uid’ instead of just the id is a security measure.

Remember in order to freely cancel the delivery, the cancellation must be done 20 minutes before the pickup_time.

Request parameters

delivery
string optional

Insert the uid you got upon creating the delivery request

Request headers

Authorization
string optional

Inset your bearer token here

Example:
ABC1234

Responses

200 OK

excelent - delivery canceled

Body
Object
error
boolean
msg
string
Example:
Trip canceled
Delivery list
GET /delivery/list

If you need a detailed list of the deliveries from a specific client, simply send the start and end date in the format YYYY-MM-DD. Both dates are included in the return. Here you can see all the timestamps recorded.

Request headers

Authorization
string required

Your clients api-token goes here!

start
string required

The from date YYYY-MM-DD

Example:
2019-02-15
end
string required

The end date of the range. Must be larger than start

Example:
2019-02-19

Responses

200 OK
Body
Object
error
boolean

This will be false

deliveries
integer
Example:
3
list
Array
Object
receiver_name
string
Example:
Soren
receiver_address
string
Example:
Vestergade 65
receiver_zip
string
Example:
5000
receiver_city
string
Example:
Odense
receiver_telephone
string
Example:
40411234
reciever_latitude
string
Example:
55.38892722
reciever_longitude
string
Example:
10.39662587
remarks
unknown nullable
wanted_time
unknown nullable

2019-02-15 20:00:00

pickup_at
string
Example:
2019-02-15 20:00:00
assigned_to_courier_at
unknown nullable
accepted_by_courier_at
unknown nullable
pickup_arrival
unknown nullable
pickup_leave
unknown nullable
dropoff_arrival
unknown nullable
done
integer
distance_to_reciever
string
Example:
2813
delay_at_pickup
integer
delay_at_dropoff
unknown nullable
delivery_price_no_vat
string
Example:
62
canceled
integer
400 Errors

If errors, you get http 400

Body
Object
error
boolean
Example:
true
message
string

Here you get a message as to what the error is

Example:
date wrong. Please use format yyyy-mm-dd
Partner

You can qualify for becomming a partner if you are representing clientes who are requesting a delivery service.

If you wish a partnership, please contact: kenneth@lastmile.nu

As a partner, you can easilly add your clients to the system and start requesting deliveries on their behalf. The invoice for the deliveries will be send to you as a partner.

Add client
POST /partner/client/create

As a LastMile partner you can easily connect your new clients to the LastMile delivery platform and start offering delivery service right away. Send a post-request with the required parameters to add your client. Once added, you recieve a unique API-token paired to your client. The price structure is the same as the overall partner agreement.

Please let LastMile know when your client wishes to start the deliveries. We might need to adjust the amount of couriers to satisfy our client needs.

Request parameters

email
string required

LastMile uses emails as identifier. In the future the client will also be able to login and see delivery details if needed.

business_name
string required

LastMile need to know the name of the business

cvr
string required

LastMile need the CVR.

contact_pickup_place
string required

LastMile need a contact person at the pickup place

telephone_pickup_place
string required

LastMile need a telephone so that we can communitcate with the business incase of delay or changes

address
string required

LastMile need to know where to go

zip
string required

LastMile need to know the zip code of the pickup location

city
string required

The corrosponding cityname to the zipcode

area
string required

The lastmile area. This is important to have correct.

country
string optional

If the city is in another country then you basecountry.

Example:
Denmark

Request headers

Accept
string optional
Example:
application/json
Authorization
string optional

Your api_token

Example:
abc123

Responses

201 Created

Everything is perfect. you recieve the api_token and everything is good to go. Prices are set according to the initial partner agreement. The price can be changed using your browser.

Body
Object
error
boolean
message
string
Example:
Perfect. If you need to update some dealis, please login using your browser.
details
Object
api_token
string
Example:
8fBmeRiwhJCv9PXsii5tynB9Dk4GgnHUwdOG5ihtKsLb5V4ydBPVX2v8thmk
LastMileId
integer
Example:
4
400 Error

if you are missing something

Body
Object
error
boolean
Example:
true
message
Object
email
Array
Example:
["Please provide an email. Its used as a unique identifier. We wont spam. promise!"]
string
Example:
Please provide an email. Its used as a unique identifier. We wont spam. promise!
business_name
Array
Example:
["Please provide your clients business name"]
string
Example:
Please provide your clients business name
Get Clients
GET /partner/get/clients

You can use this, to get a list of all your clients. You can see the details you have entered of all your users

Request headers

Authorization
string required

Insert you personal (partner) api token

Responses

200 OK
Body
Object
error
boolean
clients
Array
Object
name
string
Example:
Client 1
email
string
Example:
Client1@domain.tld
api_token
string
Example:
LnrkQfy4ms4UbHJXT2aTzZXHPSLuZmMSl72CFux2aMnBOTQDXK8sdgWoFiqN
active
integer
address
string
Example:
Vestergade 65
zip
string
Example:
5000
city
string
Example:
Odense C
longitude
string
Example:
10.382895
latitude
string
Example:
55.39472716
business_name
string
Example:
Client 1 business
contact_pickup_place
string
Example:
Contact 1
telephone_pickup_place
string
Example:
40411234
contact_other
string
Example:
Contact 2
telephone_other
string
Example:
40411234
id_at_partner
string
Example:
0
cvr
string
Example:
12345678
Update client
POST /partner/client/update

Every now and then it is necessary to update client information. All the variables return from the Client-get can be updated. If you send empty variables or leave some out, they will not be updated.

If you ever need to delete a client, update the client setting the variable ‘deleted’ = 1

Request parameters

name
string optional
email
string optional
active
boolean optional
deleted
boolean optional
area
integer optional
address
string optional
zip
number optional
city
string optional
longitude
number optional
latitude
number optional
country
string optional
business_name
string optional
contact_pickup_place
string optional
telephone_pickup_place
number optional
contact_other
string optional
telephone_other
number optional
callback
string optional
id_at_parther
string optional

Responses

201 Created
Get delivery time, distance and price
GET /delivery/timedistance

Use this to see how long time the delivery will take, the distance as well as the price.

if you already have the coordinates for the delivery address, please send them along. Then LastMile will use them insted.

Request parameters

street
string required

Enter street aswell as house number!

Example:
Vestergade 65
zip
string required

Zip code belonging to the address

Example:
5000
country
string required

Country where the address is locate. Please write in local tounge. (Danmark, Sverige, Norge)

Example:
Danmark
latitude
string optional

If you alread have the latitude, you can send it a long as well

longitude
string optional

If you alread have the longitude, you can send it a long as well

Responses

200 OK
Body
Object
distance
integer

The distance returned in meters

Example:
1400
delivery_time
integer

The delivery time in seconds

Example:
320
price_no_vat
integer
Example:
60
price_with_vat
integer
Example:
75
debug_info
Object

will be removed in time.

customer_coordinates
Object
latitude
number
Example:
55.39477184
longitude
number
Example:
10.38310782
client_coordinates
Object
latitude
number
Example:
55.39472716
longitude
number
Example:
10.382895
Get Areas
GET /partner/get/areas

If you ever need to see how LastMile has divided the country/cities into areas, this is the one to use

Request headers

Accept
string optional
Example:
application/json
Authorization
string required

Your Barer token

Example:
Bearer abc1234

Responses

200 OK

When everything goes will you will receive the following response

Body
Object
error
boolean
areas
Object

Odense has area 1, Aarhus 2… n will be announced later

1
string
Example:
Odense
2
string
Example:
Aarhus
3
string
Example:
Aalborg
n
string
Example:
NEXT TARGET
401 Unauthorized

Please make sure your token is correct.

Body
Object
message
string
Example:
Unauthenticated.