Melhor Envio Integration
Complete guide to configure the integration with Melhor Envio through Fanmarket.
📥 Postman Collection
Prerequisites
Before starting, you will need:
- Melhor Envio account (staging or production)
- Access credentials provided by Fanbase
- Callback URL configured together with Fanbase
Environments
Staging:
- Melhor Envio URL:
https://sandbox.melhorenvio.com.br - Fanmarket URL:
{fanmarket-homologacao}=https://fanmarketapi.fantest.com.br
Production:
- Melhor Envio URL:
https://melhorenvio.com.br - Fanmarket URL:
{fanmarket-producao}=https://fanmarketapi.fanbase.com.br
Step 1: Create Account on Melhor Envio
Access the Melhor Envio website:
- Staging: https://sandbox.melhorenvio.com.br/login
- Production: https://melhorenvio.com.br/login
Create an account or log in
Step 2: Create Application
- In the side menu, access Integrations → Dev Area
- Click Register Application
- Fill out the form with the following data:
| Field | Value |
|---|---|
| Platform Name | Fanmarket |
| Contact Email | Your contact email |
| Your environment URL for testing | {fanmarket-homologacao} |
| Platform website | {fanmarket-producao} |
| Your technical support email | Support email |
| Redirect URL after authorization | Provided by Fanbase |
| Application description | Your application description |
- After creating, note the generated Client ID and Secret
Step 3: Get Credentials
After creating the application, you will receive:
- Client ID: Public identifier of the application
- Secret: Secret key (must be kept confidential)
Send these credentials to Fanbase for configuration.
Step 4: Grant Permissions
To grant freight quote permissions, you need to authorize the application through an authorization link.
Generate Authorization Link
The link should follow the format below:
https://{{UrlMelhorEnvio}}/oauth/authorize?client_id={{ClientId}}&redirect_uri={{UrlCallback}}&response_type=code&state={{State}}&scope=shipping-calculate ecommerce-shippingParameters
| Parameter | Description | Example |
|---|---|---|
UrlMelhorEnvio | Melhor Envio environment URL | sandbox.melhorenvio.com.br (staging) or melhorenvio.com.br (production) |
ClientId | Client ID generated in step 2 | 1010 |
UrlCallback | Callback URL provided by Fanbase | {fanmarket-homologacao}/api/delivery/shipping/callback/teste |
State | State value (can be any string) | teste (staging) or prod (production) |
scope | Requested permissions | shipping-calculate ecommerce-shipping |
Complete Link Example
Staging:
https://sandbox.melhorenvio.com.br/oauth/authorize?client_id=1010&redirect_uri={fanmarket-homologacao}/api/delivery/shipping/callback/teste&response_type=code&state=teste&scope=shipping-calculate ecommerce-shippingProduction:
https://melhorenvio.com.br/oauth/authorize?client_id=1010&redirect_uri={fanmarket-producao}/api/delivery/shipping/callback/prod&response_type=code&state=prod&scope=shipping-calculate ecommerce-shippingStep 5: Authorize Application
- Open the link generated in step 4 in the browser
- Log in to the Melhor Envio platform (if necessary)
- Authorize the requested permissions
- You will be automatically redirected to the callback URL
- The message should appear: "Token saved successfully"
Verification
After completing all steps, the token will be automatically saved by Fanbase. If any message other than "Token saved successfully" appears, contact Fanbase support.
Next Steps
After configuration, you can use Fanmarket endpoints to calculate and manage freight through Melhor Envio.
Support
If you have questions or problems during configuration, contact Fanbase technical support.
