Steps
- Create a delivery request
- Initiate delivery with quote id and delivery request id
Step 1: Create a delivery request
To create a delivery request, you need to specify information such as details of the pickup and dropoff locations (longitude, latitude, address in words) and details of items (name, quantity, size, category) you want to be delivered.
Once a delivery has been requested, you will see a summary of quotes (possible prices) to complete that delivery.
const url = 'https://api.stallsone.com/v1/businesses/:business/delivery_requests'
const headers = { 'Authorization': `Bearer ${stalls_sk}` }
const body = {
"pickup": {
"longitude": "1",
"latitude": "0.23",
"address": {
"street_address_1": "101 Market St",
"street_address_2": "Floor 8",
"city": "San Francisco",
"state": "CA",
"zip_code": "94105",
"country": "US"
}
},
"dropoff": {
"longitude": "1.231",
"latitude": "2.11",
"address": {
"street_address_1": "101 Market St",
"street_address_2": "Floor 8",
"city": "San Francisco",
"zip_code": "94105",
"country": "US",
"state": "CA"
}
},
"items": [
{
"name": "2kg Tomato paste",
"quantity": 5,
"size": "medium",
"category": "food"
}
]
}
await axios.post(url, body, { headers })
import requests
url = 'https://api.stallsone.com/v1/businesses/:business/delivery_requests'
headers = { 'Authorization': f'Bearer {stalls_sk}' }
body = {
"pickup": {
"longitude": "1",
"latitude": "0.23",
"address": {
"street_address_1": "101 Market St",
"street_address_2": "Floor 8",
"city": "San Francisco",
"state": "CA",
"zip_code": "94105",
"country": "US"
}
},
"dropoff": {
"longitude": "1.231",
"latitude": "2.11",
"address": {
"street_address_1": "101 Market St",
"street_address_2": "Floor 8",
"city": "San Francisco",
"zip_code": "94105",
"country": "US",
"state": "CA"
}
},
"items": [
{
"name": "2kg Tomato paste",
"quantity": 5,
"size": "medium",
"category": "food"
}
]
}
requests.post(url, data = body, headers = headers)
{
"message": "Delivery request created successfully.",
"delivery_request": {
"deliveries": [],
"quotes": [
{
"id": "dqo_t58jFt9ciUAqYeI4RHFVJ1sH",
"fee": 704,
"currency": "USD",
"delivery_duration": 86,
"delivery_request_id": "drq_R5Bn7VWh7FEQBj1e77TvKTGX",
"created_at": "2021-06-26T21:27:15.000+01:00",
"updated_at": "2021-06-26T21:27:15.000+01:00"
}
],
"id": "drq_R5Bn7VWh7FEQBj1e77TvKTGX",
"business_id": "bus_IwGRRqrx7pXqyT",
"completed": false,
"pickup_point_id": "dpt_LQySpyN17rOt2PtHv6qU5vz8",
"dropoff_point_id": "dpt_4FWhaoxsgFQxx66qLkaq42Uf",
"expires_at": "2021-06-26T21:30:13.548+01:00",
"status": "pending",
"created_at": "2021-06-26T21:27:13.549+01:00",
"updated_at": "2021-06-26T21:27:13.549+01:00"
}
}
Step 2: Initiate delivery with quote id and delivery request id
The next step is to initiate a delivery using a particular quote of a delivery request. This will confirm the delivery and we will proceed in debiting your balance and begin the delivery.
const url = 'https://api.stallsone.com/v1/logistics/delivery_requests/:id/initiate'
const headers = { 'Authorization': `Bearer ${stalls_sk}` }
const body = {
"quote_id": "dqo_hgse53KTPVxPcBfCPzJ5tGYv",
"requires_id_verification": true,
"requires_dropoff_signature": true,
"dropoff": {
"name": "John Doe",
"phone_number": "4155555555",
"notes": "Knock 3 times.",
"email": "[email protected]"
},
"pickup": {
"name": "Sam Jin",
"phone_number": "4155555555",
"notes": "Please dial my number.",
"email": "[email protected]"
}
}
await axios.post(url, body, { headers })
import requests
url = 'https://api.stallsone.com/v1/logistics/delivery_requests/:id/initiate'
headers = { 'Authorization': f'Bearer {stalls_sk}' }
body = {
"quote_id": "dqo_hgse53KTPVxPcBfCPzJ5tGYv",
"requires_id_verification": true,
"requires_dropoff_signature": true,
"dropoff": {
"name": "John Doe",
"phone_number": "4155555555",
"notes": "Knock 3 times.",
"email": "[email protected]"
},
"pickup": {
"name": "Sam Jin",
"phone_number": "4155555555",
"notes": "Please dial my number.",
"email": "[email protected]"
}
}
requests.post(url, data = body, headers = headers)
{
"message": "Delivery initiated successfully.",
"delivery_request": {
"deliveries": [
{
"delivery_request_id": "drq_R5Bn7VWh7FEQBj1e77TvKTGX",
"completed": 0,
"created_at": null,
"currency": "USD",
"dropoff_eta": "2021-06-26T22:35:00.000+01:00",
"fee": 704,
"id": "del_A2vS6gIyYpsdjVbNuLG2qRpE",
"status": "pending",
"updated_at": "2021-06-26T21:28:03.000+01:00"
}
],
"id": "drq_R5Bn7VWh7FEQBj1e77TvKTGX",
"business_id": "bus_IwGRRqrx7pXqyT",
"completed": 0,
"pickup_point_id": "dpt_LQySpyN17rOt2PtHv6qU5vz8",
"dropoff_point_id": "dpt_4FWhaoxsgFQxx66qLkaq42Uf",
"expires_at": "2021-06-26T21:30:13.000+01:00",
"currency": "USD",
"fee": 704,
"requires_id_verification": true,
"requires_dropoff_signature": true,
"selected_quote_id": "dqo_t58jFt9ciUAqYeI4RHFVJ1sH",
"status": "in_progress",
"created_at": "2021-06-26T21:27:13.000+01:00",
"updated_at": "2021-06-26T21:28:03.432+01:00"
}
}