E-commerce
Melhor Envio in your product and your AI agents, through one API
The Melhor Envio toolkit covers shipping quotes between CEPs, the label cart, paying and generating labels, printing, label search and cancellation, and the wallet balance. Your customer connects Melhor Envio once with OAuth, and your store, marketplace tool or AI agent runs each operation through Connect, which stores and renews the credentials and logs every execution.
15 days to try it. No credit card.
POST https://connect.reportei.com/api/tools/melhor_envio_calculate_shipping/execute
Authorization: Bearer <merchant token>
x-customer-token: <customer token>
Content-Type: application/json
Accept: application/json
{
"customer_toolkit": "<connection UUID>",
"arguments": {
"from": {},
"to": {},
"products": []
}
}How it works
From a connected customer to the first Melhor Envio call.
- 1
Your customer connects the account
Your system opens a Connect session for the toolkit and your customer connects their Melhor Envio account. You get the connection id.
- 2
Your product calls the tool
A POST to /api/tools/{tool}/execute with the connection id and arguments. On success, Connect preserves the app's response status and body.
- 3
Connect handles the rest
It stores the credential encrypted, renews tokens for OAuth connections that support renewal and records executions in an audit trail available through the API.
Use cases
What your product does with Melhor Envio.
Shipping quotes at checkout
Call Calculate shipping with the products and the two CEPs to show each carrier's price and delivery time before the buyer pays.
Fulfil an order end to end
Create a cart item, purchase it with the wallet, generate the label and print it, all from your own order screen.
Agent answers where is my order
An AI agent finds a label by tracking code or CPF and reads its status and posting and delivery dates.
Tools
12 Melhor Envio tools
- Calculate shippingPOSTQuotes the shipping of products between two CEPs and returns one entry per service, with id, carrier, price, delivery time, the packages and an error when the service does not serve the route. custom_price and custom_delivery_time include the fees and discounts of the account. Only the services enabled for the integration in the Melhor Envio panel are quoted.
- Create cart itemPOSTAdds a shipping label to the cart of the account and returns it. Its id is the id of the label in the other tools. Nothing is paid until Purchase labels. Correios, J&T and Loggi take one volume per call: for more packages, add one item per package.
- List cart itemsGETLists the labels in the cart that were not paid yet, with id, service, price, sender, recipient and volumes. Labels stay in the cart for 20 days. 10 per page: pass page for the next ones, up to last_page.
- Delete cart itemDELETERemoves a label that was not paid yet from the cart.
- Purchase labelsPOSTPays labels in the cart with the balance of the Melhor Envio wallet and returns the purchase, with the total and the labels, now released. The wallet needs enough balance: check it with Get balance. Paid labels still need Generate labels.
- Generate labelsPOSTGenerates paid labels, which is required before Print labels, and returns the result for each id. A generated label must be posted within 20 days, or 7 days with Correios.
- Print labelsPOSTReturns a link to print generated labels. A private link opens only for someone signed in to the Melhor Envio account; a public link opens for anyone who has it.
- List labelsGETLists the labels of the account with id, protocol, status, service, price, tracking code and the dates of payment, generation, posting and delivery. 10 per page: pass page for the next ones, up to last_page.
- Get labelGETReturns one label with status, service, price, sender, recipient, volumes, tracking code and the dates of payment, generation, posting and delivery.
- Search labelsGETFinds labels by one exact value: the id, the protocol, the tracking code, the authorization code, or the CPF or CNPJ of the sender or the recipient.
OAuth with your product's app
You register your product's OAuth app once, with POST /api/merchants/credentials/melhor_envio, and your customer authorizes the account on a consent screen. Connect renews the token when it is about to expire.
Questions about the Melhor Envio toolkit
Do I need to build against the Melhor Envio API?
No. Connect ships 12 Melhor Envio tools, described and ready. Your customer connects the account and your system calls every tool through the same endpoint, with the same request format.
How does my customer connect their Melhor Envio account?
With the mode the toolkit accepts: OAuth with your product's app. Connect stores the credential encrypted and never returns it to your system.
Does it work with AI agents?
Yes. Each tool's input is described in JSON Schema, which your agent uses directly as a tool definition. The agent picks the tool and the arguments, and your system makes the call to Connect.
Does my customer need a Reportei account?
No. Your customer connects the account on a Connect screen, or your system sends the credential through the API, and they keep using only your product.
See Connect applied to your product.
Try it for 15 days with no card, or walk our team through your use case.
