Generate guide
This guide allows you to generate a shipping guide using the DrEnvio API. It includes information about the different environments available, the list of supported carriers, request parameters, response structure, and more.
Environments
The DrEnvio API supports two environments: Production and Sandbox.
Production Environment: The production environment is where real shipments are processed. To use the production API, send your requests to the following URL:
URL used for generating shipments with Redpack and, in the case of FedEx, only when the ShippingId is G1.
https://api-clientes.vercel.app/v2/shipments/generate
URL used for generating shipments with the remaining carriers.
https://prod.api-drenvio.com/v2/shipments/generate
Sandbox Environment: The sandbox environment is used for testing purposes. It provides simulated data to help you develop and test your integration before moving to production. To use the sandbox API, send your requests to the following URL:
https://sandbox.api-drenvio.com/v2/shipments/generate
API request
To generate the shipping label, send a POST request with a JSON body like this:
{ "origin": { "city": "Monterrey", "company": "SACR0 DESIGN", "country": "MX", "district": "MIRAVALLE", "email": "sample_sample@localhost", "int_number": "2", "name": "SAMPLE FULL NAME", "number": "282", "phone": "8683457800", "postal_code": "66250", "reference": "SAMPLE DISTRICT", "state": "NL", "street": "ANTONIO VIVALDI" }, "destination": { "city": "Monterrey", "company": "PARROQUIA DE NUESTRA SEÑORA DE LA PIEDAD", "country": "MX", "district": "Piedad Narvarte", "email": "sample_sample@localhost", "name": "SAMPLE FULL NAME", "number": "320", "phone": "8683457800", "postal_code": "66260", "reference": "SAMPLE DISTRICT", "state": "NL", "street": "Obrero Mundial " }, "shipment": { "carrier": "fedex", "contentExplanation": "EXAMPEL CONTENT", "contentQuantity": 1, "ObjectId": "code", "price": 133.4, "service": "ground", "ShippingId": "N4", "satContent": "31181701" }, "insurance": 0, "packages": [ { "content": "ORNAMENTOS O DECORACIONES", "contentQuantity": 1, "declared_value": 0, "height": 10, "weight": 1, "width": 10, "length": 10, "type": "box", "name": "Paquete enviado de pruebas", "volumetric": 0.2, "main_weight": 1 } ], "service_id": "fedex_mx_D-C02_ground", "carriers": ["fedex"]}
Fields description
Field | Description | Type | Required |
---|---|---|---|
origin | Origin Address of shipment | Object AddressObject | true |
destination | Destination address of the shipment | Object AddressObject | true |
shipments | Shipment details | Object ShipmentObject | true |
packages | Packages | Array PackagesObject | true |
service_id | Id of the service selected | string | true |
insurance | The insurance of shipment (MXN for national, USD for international) | number | true |
carriers | Selected carrier(s) (Provided in the rate) | Array of strings | true |
Address (Object)
The last_name field is only used for 99Minutos shipments that contain the ShippingId as N11 and for all carriers with the A-P10 code in the service_id.
If the field is left optional, for shipments with the A-P10 code, it will automatically be filled with the company field. For all shipments that do not meet the mentioned conditions, the field should be ignored.
Field | Description | Type | Required |
---|---|---|---|
name | Name of the person making/receiving the shipment. | string | true |
last_name | Last Name of the person making/receiving the shipment. | string | false |
company | Company of the person making/receiving the shipment, if not provided will be NA. | string | true |
email | Email of the person making/receiving the shipment. | string | true |
phone | Phone number of the person making/receiving the shipment. | string | true |
street | Street of the person making/receiving the shipment. | string | true |
number | Number of building of the address. | string | true |
int_number | Interior Number of building of the address. | string | false |
district | District of the address. | string | true |
city | City of the address. | string | true |
country | Always MX until next major update. | string | true |
reference | A reference to help find the address, if not provided will be NA. | string | true |
state | 2 digit state code of the address, those can be found here. | StateCode Enum | true |
postalCode | 5 digit postal code of the address. | string | true |
Package (Object)
Field | Description | Type | Required |
---|---|---|---|
width | Width of the package in CM. | number | true |
height | Height of the package in CM. | number | true |
length | Length of the package in CM. | number | true |
weight | Weight of the package in KG. | number | true |
type | The type of the package. | Enum: box, envelope, pallet | true |
name | Content of the package. | string | true |
content | Content of the package. | string | true |
declared_value | Declared Value of the package. | number | true |
contentQuant ity | Amount of packages. | number | true |
StateCode (Enum)
Name | StateCode2Digit |
---|---|
Aguascalientes | AG |
Baja California | BC |
Baja California Sur | BS |
Campeche | CM |
Chiapas | CS |
Chihuahua | CH |
Ciudad de México | CX |
Coahuila | CO |
Colima | CL |
Durango | DG |
Guanajuato | GT |
Guerrero | GR |
Hidalgo | HG |
Jalisco | JA |
Estado de México | EM |
Michoacán | MI |
Morelos | MO |
Nayarit | NA |
Nuevo León | NL |
Oaxaca | OA |
Puebla | PU |
Querétaro | QT |
Quintana Roo | QR |
San Luis Potosí | SL |
Sinaloa | SI |
Sonora | SO |
Tabasco | TB |
Tamaulipas | TM |
Tlaxcala | TL |
Veracruz | VE |
Yucatán | YU |
Zacatecas | ZA |
Shipment (Object)
The satContent field is an identifier code for the type of product required by the SAT in Mexico, and it is obtained through the SAT Product Code Inquiry service.
If the mentioned service is not used, the generic package code can be placed in its place (e.g., satContent: ‘31181701’).
Field | Description | Type | Required |
---|---|---|---|
carrier | Provided in the rate | string | true |
ObjectId | Provided in the rate | string | true |
ShippingId | Provided in the rate | string | true |
service | Provided in the rate | string | true |
price | Provided in the rate | number | true |
contentExplanation | An explanation of the content of the shipment, must include fabrication materials | string | true |
contentQuantity | How many items are in the box | number | true |
satContent | Product type identification code that you are sending | string | true |
API response
{ "shipment_status": "Activa", "pickups_status": "En espera", "_id": "649f036f8b74c6f35e052902", "user": "auth0|5f60f5e21e076c00797eee99", "origin": { "_id": "649f036e8b74c6f35e0528ff", "name": "SAMPLE FULL NAME", "company": "SACR0 DESIGN", "email": "sample_sample@localhost", "phone": "8683457800", "street": "ANTONIO VIVALDI", "number": "282", "int_number": "2", "district": "MIRAVALLE", "city": "Monterrey", "state": "NL", "country": "MX", "postal_code": "66250", "reference": "SAMPLE DISTRICT", "title": "SAMPLE FULL NAMEdireccion", "user": "auth0|5f60f5e21e076c00797eee99" }, "destination": { "_id": "649f036e8b74c6f35e052900", "name": "SAMPLE FULL NAME", "company": "PARROQUIA DE NUESTRA SEÑORA DE LA PIEDAD", "email": "sample_sample@localhost", "phone": "8683457800", "street": "Obrero Mundial ", "number": "320", "int_number": "0", "district": "Piedad Narvarte", "city": "Monterrey", "state": "NL", "country": "MX", "postal_code": "66260", "reference": "SAMPLE DISTRICT", "title": "SAMPLE FULL NAMEdireccion", "user": "auth0|5f60f5e21e076c00797eee99" }, "packages": [ { "_id": "649f036e8b74c6f35e052901", "weight": 1, "height": 10, "width": 10, "length": 10, "declared_value": 0, "volumetric": 0.2, "type": "box", "content": "ORNAMENTOS O DECORACIONES", "name": "ORNAMENTOS O DECORACIONES", "main_weight": 1, "user": "auth0|5f60f5e21e076c00797eee99" } ], "label": "https://storage.googleapis.com/download/storage/v1/b/drenvio-8741f.appspot.com/o/fedex%2FUAT301007251337? generation=1688142703394521&alt=media", "shipping_id": "N4", "carrier": "fedex", "service": "ground", "service_id": "fedex_mx_D-C02_ground", "price": 133.4, "insurance": 0, "tracking": "UAT301007251337", "metadata": { "format": "PDF_4_6", "extended_area": false, }, "created_at": "2023-06-30T16:31:43.681Z"}