Integration Guide

What you'll build

By the end of this guide you will have a production-ready integration that:

  • Validates customer addresses before shipping
  • Discovers available carriers and services per route
  • Quotes rates, purchases labels, and tracks shipments
  • Receives real-time status updates via webhooks
  • Runs on production with live carriers

This guide walks you through the complete integration path. Follow it from top to bottom and you'll go from zero to production-ready shipping.

Where you are

flowchart LR
  A["1. Setup"] --> B["2. Validate"] --> C["3. Discover"] --> D["4. Ship"] --> E["5. Monitor"] --> F["6. Go Live"]
  style A fill:#1873dc,color:#fff
  style F fill:#1873dc,color:#fff

Phase 1 — Setup (15 minutes)

Get your credentials and make your first API call.

StepWhat to doAPIReference
Create a sandbox accountSign up at accounts-sandbox.envia.com/signupAuth & Environments
Generate an API keyDashboard → Settings → API → AddAuth & Environments
Test your tokenMake a GET request to the Queries APIQueriesSee below

Test that your token works:

curl --request GET \
  --url https://queries-test.envia.com/webhook-types \
  --header "Authorization: Bearer $ENVIA_SANDBOX_TOKEN"

If you get a JSON response with webhook types, your token is working.

Phase 2 — Validate addresses (Geocodes API)

Before shipping, validate your customer's address to prevent failed deliveries.

EndpointPurposeWhen to use
Validate Zip CodeVerify a postal code and get city/stateAddress form submission
Locate CityFind city details by nameAutocomplete / fuzzy search
curl --request GET \
  --url "https://geocodes.envia.com/zipcode/MX/64060" \
  --header "Authorization: Bearer $ENVIA_SANDBOX_TOKEN"

Phase 3 — Discover carriers and services (Queries API)

Find out which carriers serve a given route before quoting rates.

EndpointPurposeWhen to use
Available CarriersList carriers for a countryBuild carrier selector
Available ServicesList services for a carrier/countryBuild service selector
Address StructureGet required address fields per countryBuild dynamic address forms

See Common Queries Endpoints for a focused guide on the most-used discovery endpoints.

Phase 4 — Ship (Shipping API)

This is the core loop your application will execute for every order:

flowchart LR
  Rate["Get Rates"] --> Label["Create Label"] --> Track["Track"]
  Label --> Pickup["Schedule Pickup"]
  Label --> Cancel["Cancel"]
StepEndpointWhat it does
Get ratesQuote ShipmentsReturns available services with prices for one carrier
Create labelCreate Shipping LabelPurchases a label, returns tracking number and PDF
TrackTrack ShipmentsReturns status and event history for tracking numbers
Schedule pickupSchedule PickupRequests carrier pickup at your address
CancelCancel ShipmentVoids a label and releases the charge

For complete request/response examples of every step, see the Core Workflow guide.

💡

Tip: The rate endpoint accepts one carrier per request. To compare carriers, call it once per carrier or use the Queries API to narrow down your choices first.

Phase 5 — Monitor with webhooks

Instead of polling the tracking endpoint, register a webhook to receive real-time updates.

StepAPIEndpoint
List available webhook typesQueriesGET /webhook-types
Register your endpointQueriesPOST /webhooks
Test deliveryShippingTest Webhook
curl --request POST \
  --url https://queries-test.envia.com/webhooks \
  --header "Authorization: Bearer $ENVIA_SANDBOX_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "type_id": 3,
    "url": "https://your-app.com/webhooks/envia",
    "active": 1
  }'

Phase 6 — Go to production

When your sandbox integration is working end-to-end, switch to production. See the full Production Readiness Checklist to make sure nothing is missed.

Quick summary:

  1. Create a production account at accounts.envia.com/signup
  2. Generate a production API key
  3. Replace base URLs (api-testapi, queries-testqueries). Note: the Geocodes API already uses the production URL in both environments
  4. Use separate webhook URLs for production
  5. Fund your account balance before creating labels

What to read next


🛟

Need Help?

Have questions or need assistance with your integration?
Our support team is ready to help 🚀

Create a support ticket here and we’ll guide you with setup, troubleshooting, or feature requests.