Skip to content

Melhor Envio Integration

Complete guide to configure the integration with Melhor Envio through Fanmarket.

📥 Postman Collection

Download Collection - Melhor Envio

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

  1. Access the Melhor Envio website:

  2. Create an account or log in

Step 2: Create Application

  1. In the side menu, access IntegrationsDev Area
  2. Click Register Application
  3. Fill out the form with the following data:
FieldValue
Platform NameFanmarket
Contact EmailYour contact email
Your environment URL for testing{fanmarket-homologacao}
Platform website{fanmarket-producao}
Your technical support emailSupport email
Redirect URL after authorizationProvided by Fanbase
Application descriptionYour application description
  1. 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.

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-shipping

Parameters

ParameterDescriptionExample
UrlMelhorEnvioMelhor Envio environment URLsandbox.melhorenvio.com.br (staging) or melhorenvio.com.br (production)
ClientIdClient ID generated in step 21010
UrlCallbackCallback URL provided by Fanbase{fanmarket-homologacao}/api/delivery/shipping/callback/teste
StateState value (can be any string)teste (staging) or prod (production)
scopeRequested permissionsshipping-calculate ecommerce-shipping

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-shipping

Production:

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-shipping

Step 5: Authorize Application

  1. Open the link generated in step 4 in the browser
  2. Log in to the Melhor Envio platform (if necessary)
  3. Authorize the requested permissions
  4. You will be automatically redirected to the callback URL
  5. 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.

Fanbase API Documentation