Domestic Shipping Workflow

Follow Jessica, a boutique clothing store owner in Mexico City, as she ships orders to customers within Mexico using address validation, carrier selection, and pickup scheduling.

Meet Jessica

Jessica owns a boutique clothing store in Mexico City. She sells trendy fashion items online and ships to customers throughout Mexico. Today, Jessica has three orders to fulfill: one to Monterrey, one to Guadalajara, and one to Cancún. She needs to ship these quickly and cost-effectively, and she prefers having the carrier pick up packages from her store rather than dropping them off at a branch.

Business type

Boutique clothing store with online sales

Challenge

Daily shipping needs with multiple domestic orders requiring efficient fulfillment

Solution

Use Envía APIs to validate addresses, get quotes, create labels, and schedule convenient pickups

The Journey

Jessica's domestic shipping workflow is streamlined and efficient:

Step-by-Step Workflow

Step 1: Validate Customer Addresses

What Jessica needs to do: Before creating shipping labels, Jessica wants to ensure all customer addresses are valid. This prevents delivery delays and ensures accurate shipping quotes.

API Calls: Jessica can validate customer addresses using the following endpoints:

From the Geocodes API:

  • Validate Zip Code - Verify postal codes and get city, state, and location details
  • Locate City - Find city information by city name and state, useful when postal codes aren't available or to validate city names

From the Queries API:

Jessica's first order is going to Monterrey, Nuevo León, with postal code 64060. She uses the Validate Zip Code endpoint:

curl --request GET \
  --url "https://geocodes.envia.com/zipcode/MX/64060" \
  --header "Authorization: Bearer $ENVIA_TOKEN"

Response example

{
  "meta": "zipcode",
  "data": {
    "postalCode": "64060",
    "city": "Monterrey",
    "state": "NL",
    "country": "MX"
  }
}
💡

Tip for Jessica: Validating addresses upfront helps Jessica catch any typos or incorrect postal codes before creating labels. This saves time and prevents failed deliveries.

Step 2: Check Available Carriers

What Jessica needs to do: Jessica wants to see which carriers can deliver to her customer's location in Monterrey. This helps her choose the best carrier for speed and cost.

💡

Note: If Jessica already knows which carrier she wants to use (e.g., she always uses Estafeta for domestic shipments), she can skip this step and proceed directly to getting a quote with that carrier.

API Call: Get Available Carriers from the Queries API

curl --request GET \
  --url "https://queries.envia.com/carriers?countryCode=MX&shipmentType=1" \
  --header "Authorization: Bearer $ENVIA_TOKEN"

Response example

{
  "meta": "carriers",
  "data": [
    {
      "carrier": "estafeta",
      "name": "Estafeta"
    },
    {
      "carrier": "fedex",
      "name": "FedEx"
    },
    {
      "carrier": "dhl",
      "name": "DHL"
    }
  ]
}

Jessica discovers that Estafeta, FedEx, and DHL all serve domestic routes in Mexico. She decides to get quotes from Estafeta for this shipment.

Step 3: Get Quote for Domestic Shipment

What Jessica needs to do: Jessica needs to get a shipping quote.

API Call: Quote Shipments from the Shipping API

curl --request POST \
  --url "https://api.envia.com/ship/rate/" \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "origin": {
      "name": "Jessica Rodriguez",
      "company": "Jessica Boutique",
      "phone": "+52 5551234567",
      "email": "[email protected]",
      "street": "Av. Insurgentes Sur 1647",
      "city": "Ciudad de Mexico",
      "state": "CMX",
      "country": "MX",
      "postalCode": "03920"
    },
    "destination": {
      "name": "Ana Lopez",
      "phone": "+52 8181234567",
      "street": "Av. Constitución 123",
      "city": "Monterrey",
      "state": "NL",
      "country": "MX",
      "postalCode": "64060"
    },
    "packages": [
      {
        "type": "box",
        "content": "Clothing",
        "amount": 1,
        "declaredValue": 450,
        "weight": 0.5,
        "weightUnit": "KG",
        "lengthUnit": "CM",
        "dimensions": {
          "length": 30,
          "width": 20,
          "height": 10
        }
      }
    ],
    "shipment": {
      "type": 1,
      "carrier": "estafeta"
    }
  }'

Response example

{
  "meta": "rate",
  "data": [
    {
      "carrier": "estafeta",
      "service": "ground",
      "serviceDescription": "Estafeta Terrestre",
      "deliveryEstimate": "2-3 business days",
      "totalPrice": "125.50",
      "currency": "MXN"
    }
  ]
}

Jessica notices: Domestic shipping quotes are simpler—no customs settings needed! The quote shows Jessica the available services, prices, and estimated delivery times for shipping within Mexico.

Step 4: Create Shipping Labels

What Jessica needs to do: Jessica has received quotes for all three orders. Now she'll create shipping labels for each one. She'll use the service code from the quote she selected.

API Call: Create Shipping Label from the Shipping API

Jessica creates labels for all three orders. Here's the first one to Monterrey:

curl --request POST \
  --url "https://api.envia.com/ship/create/" \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "origin": {
      "name": "Jessica Rodriguez",
      "company": "Jessica Boutique",
      "phone": "+52 5551234567",
      "email": "[email protected]",
      "street": "Av. Insurgentes Sur 1647",
      "city": "Ciudad de Mexico",
      "state": "CMX",
      "country": "MX",
      "postalCode": "03920"
    },
    "destination": {
      "name": "Ana Lopez",
      "phone": "+52 8181234567",
      "street": "Av. Constitución 123",
      "city": "Monterrey",
      "state": "NL",
      "country": "MX",
      "postalCode": "64060"
    },
    "packages": [
      {
        "type": "box",
        "content": "Clothing",
        "amount": 1,
        "declaredValue": 450,
        "weight": 0.5,
        "weightUnit": "KG",
        "lengthUnit": "CM",
        "dimensions": {
          "length": 30,
          "width": 20,
          "height": 10
        }
      }
    ],
    "shipment": {
      "type": 1,
      "carrier": "estafeta",
      "service": "estafeta_terrestre"
    }
  }'

Response example

{
  "meta": "generate",
  "data": [
    {
      "carrier": "estafeta",
      "service": "ground",
      "shipmentId": 987654,
      "trackingNumber": "EST123456789",
      "trackUrl": "https://tracking.envia.com/EST123456789",
      "label": "https://files.envia.com/labels/EST123456789.pdf",
      "totalPrice": 125.5,
      "currency": "MXN"
    }
  ]
}

Jessica repeats this process for her other two orders (Guadalajara and Cancún), creating labels for each. She saves all the tracking numbers.

Step 5: Schedule Pickup

What Jessica needs to do: Instead of taking packages to a carrier branch, Jessica prefers to have the carrier pick them up from her store. This saves her time and allows her to focus on her business. She'll schedule one pickup for all three packages.

📋

Pickup Rules: If Jessica is unsure about pickup requirements (cutoff times, business days, etc.), she should check the Pickup Rules documentation for the specific carrier. This ensures she schedules pickups correctly and avoids any issues.

API Call: Schedule Pickup from the Shipping API

curl --request POST \
  --url "https://api.envia.com/ship/pickup/" \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "carrier": "estafeta",
    "pickupAddress": {
      "name": "Jessica Rodriguez",
      "company": "Jessica Boutique",
      "phone": "+52 5551234567",
      "email": "[email protected]",
      "street": "Av. Insurgentes Sur 1647",
      "city": "Ciudad de Mexico",
      "state": "CMX",
      "country": "MX",
      "postalCode": "03920"
    },
    "pickupDate": "2025-01-27",
    "pickupTimeStart": "10:00",
    "pickupTimeEnd": "14:00",
    "trackingNumbers": [
      "EST123456789",
      "EST987654321",
      "EST456789123"
    ]
  }'

Response example

{
  "meta": "pickup",
  "data": {
    "carrier": "estafeta",
    "confirmation": "PKP-2025-001",
    "status": "scheduled",
    "date": "2025-01-27",
    "timeFrom": 10,
    "timeTo": 14
  }
}

Jessica saves time! By scheduling a pickup, Jessica doesn't need to leave her store or wait in line at a carrier branch. The carrier will collect all three packages during the scheduled time window, and Jessica receives a confirmation with the expected pickup time.

Step 6: Track Shipments

What Jessica needs to do: Jessica wants to monitor all three shipments and keep her customers informed about delivery status. She can track multiple shipments in one call.

API Call: Track Shipments from the Shipping API

curl --request GET \
  --url "https://api.envia.com/ship/tracking?trackingNumbers=EST123456789,EST987654321,EST456789123&carrier=estafeta" \
  --header "Authorization: Bearer $ENVIA_TOKEN"

Response example

{
  "meta": "track",
  "data": [
    {
      "trackingNumber": "EST123456789",
      "status": "In transit",
      "carrier": "estafeta",
      "events": [
        {
          "timestamp": "2025-01-27T10:30:00Z",
          "location": "Ciudad de Mexico, MX",
          "description": "Shipment picked up"
        }
      ]
    },
    {
      "trackingNumber": "EST987654321",
      "status": "In transit",
      "carrier": "estafeta",
      "events": [
        {
          "timestamp": "2025-01-27T10:30:00Z",
          "location": "Ciudad de Mexico, MX",
          "description": "Shipment picked up"
        }
      ]
    },
    {
      "trackingNumber": "EST456789123",
      "status": "In transit",
      "carrier": "estafeta",
      "events": [
        {
          "timestamp": "2025-01-27T10:30:00Z",
          "location": "Ciudad de Mexico, MX",
          "description": "Shipment picked up"
        }
      ]
    }
  ]
}

What Jessica Learned

Through her daily shipping routine, Jessica discovered several key benefits:

  1. Address validation prevents errors - Validating postal codes upfront catches mistakes before creating labels
  2. Domestic shipping is simpler - No customs documentation or HS codes needed for shipments within Mexico
  3. Pickup scheduling saves time - Having carriers collect packages from her store is much more convenient than visiting branches
  4. Batch operations are efficient - She can schedule one pickup for multiple packages and track them all together
  5. The workflow scales easily - As her business grows, she can handle more orders using the same process

Jessica's customers in Monterrey, Guadalajara, and Cancún all received their orders on time, and Jessica is now confident she can handle her growing order volume efficiently!

Related Resources