Fetching Shipping Methods
This guide will walk you through fetching active shipping methods using the Montonio API. More info can be found in the API reference.
Get all shipping methods
After activating contracts with various carriers through our Partner System, you can retrieve the shipping methods available for your store. There are two types of shipping methods: couriers and pickup points. Pickup points are divided into subtypes: parcel machines, parcel shops, and post offices — locations where customers can collect their parcels. Couriers are divided into courier services with subtypes like standard and standardB2B.
This is a complete example of how to fetch shipping methods activated for your store. Before continuing, ensure you have activated at least one carrier for your store using our Partner System. The process is as follows:
- Fetch all activated shipping methods for your store using the
GET /shipping-methodsendpoint. The response will contain a list of carriers and shipping methods by country. The idea is to tell you which types of shipping methods are available for you. - Fetch available courier services for your store by calling
GET /shipping-methods/courier-services?carrierCode=[carrier_code]&countryCode=[receiver_country_code]. - Fetch available pickup points for your store, use the
GET /shipping-methods/pickup-points?carrierCode=[carrier_code]&countryCode=[receiver_country_code].
Get available shipping methods
import axios from 'axios';
const config = { method: 'get', url: 'https://shipping.montonio.com/api/v2/shipping-methods', headers: { 'Accept': 'application/json', 'Authorization': 'Bearer [your_token]', }};
async function makeRequest() { try { const response = await axios.request(config); console.log(JSON.stringify(response.data)); } catch (error) { console.log(error); }}
makeRequest();The example API response will be the following:
{ "countries": [ { "carriers": [ { "carrierCode": "smartpost", "shippingMethods": [ { "type": "courier", "subtypes": [ { "code": "standard" } ], "constraints": { "parcelDimensionsRequired": false } }, { "type": "pickupPoint", "subtypes": [ { "code": "parcelMachine" } ], "constraints": { "parcelDimensionsRequired": false } } ] }, { "carrierCode": "venipak", "shippingMethods": [ { "type": "courier", "subtypes": [ { "code": "standard" } ], "constraints": { "parcelDimensionsRequired": false } }, { "type": "pickupPoint", "subtypes": [ { "code": "parcelMachine" }, { "code": "parcelShop" } ], "constraints": { "parcelDimensionsRequired": false } } ] } ], "countryCode": "EE" } ]}The example API response shows that the store has two active carriers, Venipak and SmartPosti, with pickup points and courier services. Each shipping method includes a subtypes array indicating the specific types available (e.g., parcelMachine, parcelShop for pickup points).
Handling parcel dimension requirements
Each shipping method includes a constraints object that specifies validation requirements. The parcelDimensionsRequired field indicates whether parcel dimensions (length, width, height) must be provided when creating shipments with that shipping method.
When parcelDimensionsRequired is true:
- You must include
length,width, andheightfields for each parcel in the shipment creation request - Failing to provide dimensions will result in a validation error
When integrating:
- Check the
parcelDimensionsRequiredflag when displaying shipping options - Conditionally require dimension inputs in the checkout flow when the flag is
true - Ensure parcel dimensions are included in shipment creation requests when required
Get available pickup points
Next, we will fetch all available Estonian pickup points for carrier SmartPosti:
import axios from 'axios';
const config = { method: 'get', url: 'https://shipping.montonio.com/api/v2/shipping-methods/pickup-points?carrierCode=smartpost&countryCode=ee&type=parcelMachine', headers: { 'Accept': 'application/json', 'Authorization': 'Bearer [your_token]', }};
async function makeRequest() { try { const response = await axios.request(config); console.log(JSON.stringify(response.data)); } catch (error) { console.log(error); }}
makeRequest();The example API response will be the following:
{ "pickupPoints": [ { "id": "dcad89cd-20bc-45b2-a148-43d34f297d2a", "name": "Tallinna Kollane keskus (valge)", "type": "parcelMachine", "streetAddress": "Õismäe tee 107a", "locality": "Tallinn", "postalCode": "13515", "carrierCode": "smartpost", "additionalServices": [ { "code": "cod" } ] }, { "id": "d9119757-626a-4327-8904-841efa3e0849", "name": "PAKIPUNKT Leevi pood", "type": "parcelMachine", "streetAddress": "Posti tee 2b", "locality": "Leevi", "postalCode": "64231", "carrierCode": "smartpost", "additionalServices": [] } ], "countryCode": "EE"}Currently, there are three types of pickup points: parcelMachine, parcelShop, and postOffice. The availability of these pickup points varies by carrier and country.
You can filter the list of pickup points returned by using the type query parameter. For example: GET https://shipping.montonio.com/api/v2/shipping-methods/pickup-points?carrierCode=smartpost&countryCode=ee&type=parcelMachine
Each pickup point includes an additionalServices array that lists the available additional services (e.g., cod for Cash on Delivery, ageVerification). Only include services in your shipment request that are listed here.
Get available courier services
Next, we will fetch all available courier services for the country Estonia and carrier SmartPosti:
import axios from 'axios';
const config = { method: 'get', url: 'https://shipping.montonio.com/api/v2/shipping-methods/courier-services?carrierCode=smartpost&countryCode=ee', headers: { 'Accept': 'application/json', 'Authorization': 'Bearer [your_token]', }};
async function makeRequest() { try { const response = await axios.request(config); console.log(JSON.stringify(response.data)); } catch (error) { console.log(error); }}
makeRequest();The example API response will be the following:
{ "courierServices": [ { "id": "e580d125-53eb-4c76-a6ed-c909765262a3", "name": "Standard", "type": "standard", "carrierCode": "smartpost", "additionalServices": [ { "code": "cod" }, { "code": "ageVerification" } ] } ], "countryCode": "EE"}Each courier service includes an additionalServices array that lists the available additional services (e.g., cod for Cash on Delivery, ageVerification). Only include services in your shipment request that are listed here.
Some errors which might occur during the request are listed below:
| Code | Description |
|---|---|
400 | Bad request. Please double-check the request body. You will get a more detailed error message. |
401 | Unauthorized. Please check if the JWT was generated correctly and the accessKey and secretKey are correct. |
500 | Internal server error. Something went wrong on our side. |