Decentralized Quick Start Guide
IMPORTANT: Forge is currently in beta and available to select customers. To check eligibility or join the waitlist, contact EasyPost Sales.
The Decentralized white-label option in Forge enables Platforms and Marketplaces to embed shipping capabilities without managing postage and other fees on behalf of their customers. This implementation option has unique onboarding requirements that can be found in this guide.
For this option, the sub account object type is ReferralCustomer
users.
IMPORTANT: Before starting, review the prerequisites section of the Get Started with Forge guide to understand white-label implementations with EasyPost.
Forge supports API-based onboarding for ReferralCustomer
users, allowing platforms to create independent sub-accounts with their own billing methods and wallets.
A ReferralCustomer
user is an independent sub account from the parent user that has its own billing methods and wallet.
To onboard ReferralCustomer
users via API:
- Use the POST /referral_customers API to create a
ReferralCustomer
account. - ReferalCustomer users can only be created in Production mode using the platform’s Forge API Key or through the Forge Dashboard Sub Accounts page.
- Securely store the API keys for future use. If lost, they can be retrieved from the Sub Account Details page.
- Upon creation,
ReferralCustomer
users are automatically enrolled in a pay-as-you-go EasyPost-managed subscription with EasyPost Standard Rates and ability to buy postage, insurance, and other shipping-related features.
IMPORTANT: When a ReferralCustomer
is created with your API key, you are certifying that the ReferralCustomer
agrees to the EasyPost Terms of Service.
1curl -X POST https://api.easypost.com/v2/referral_customers \
2 -u "$PARTNER_API_KEY": \
3 -H "Content-Type: application/json" \
4 -d '{
5 "user": {
6 "name": "Firstname Lastname",
7 "email": "email@example.com",
8 "phone_number": "8888888888"
9 }
10 }'
Platforms and marketplaces must build an interface that allows customers to:
- Set up Payment Methods
- Manage Wallet Settings within their application.
IMPORTANT: If Stripe Connect is already in use to collect customer payments, the Decentralized with Stripe Connect Guide provides an expedited integration process.
EasyPost uses the Stripe.js client to securely add payment methods for ReferralCustomer
users.
-
The Stripe Public Key must be retrieved before initializing Stripe.js.
GET /partners/stripe_public_key1curl -X GET https://api.easypost.com/v2/partners/stripe_public_key \ 2 -u "$PARTNER_API_KEY:"
-
Include Stripe.js in the user's browser:
<script src="https://js.stripe.com/v3/"></script>
-
Once the Stripe.js script is loaded in the DOM, the Stripe.js client can then be initialized using the public key retrieved above.
const stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx');
The Forge Decentralized option without Stripe Connect offers credit card and bank account payment methods. Each ReferralCustomer
user can
have one primary and one secondary payment method.
-
Retrieve a single-use unique
client_secret
usingEasyPost’s POST /beta/setup_intents
endpoint to be used with Stripe Elements.POST /beta/setup_intents1curl -X POST "https://api.easypost.com/beta/setup_intents" \ 2 -u "$REFERRAL_USER_API_KEY:" \ 3 -H "Content-Type: application/json"
-
Using the Stripe.js client, use Stripe Elements to create a secure form for collecting credit card details and mount it to the DOM. The appearance and layout of this element can be customized using the options available in the Stripe create_element documentation. An event listener is also needed for handling errors and collecting the Stripe payment method ID.
-
Initialize Stripe Elements and capture the payment method ID.
-
Attach the credit card to the
ReferralCustomer
user’s account using EasyPost’sPOST /credit_cards
endpoint with the payment method ID previously retrieved.POST /credit_cards1curl -X POST https://api.easypost.com/v2/credit_cards \ 2 -u "$REFERRAL_USER_API_KEY": \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "credit_card": { 6 "payment_method_id": "pm_...", 7 "priority": "primary" 8 } 9 }'
-
Retrieve a single-use unique client secret using EasyPost’s
POST /beta/financial_connections_sessions
endpoint to be used with Stripe Financial Connections.NOTE: The return URL specifies where the user will be redirected after completing the bank account addition process in Stripe Financial Connections.
POST /beta/financial_connections_sessions1curl -X POST "https://api.easypost.com/beta/financial_connections_sessions" \ 2 -u "$REFERRAL_USER_API_KEY:" \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "return_url": "https://www.yourwebsite.com/redirect" 6 }'
-
Have the user accept a mandate indicating consent to having their bank account automatically charged.
-
Open the Stripe Financial Connections modal in the user’s browser using the Stripe.js client with the client secret obtained during the previous step. See the official Stripe documentation.
NOTE: When the above promise is resolved successfully, the returned result will contain a list of accounts in
result.financialConnectionsSession.accounts
. Theid
for each of these accounts is what must be used to create the bank account using the EasyPost API endpoint. -
Create a bank account for the referral customer using EasyPost’s
POST /bank_accounts
endpoint once per ID retrieved in step c along with data for the mandate acceptance.NOTE: Payment methods can be deleted using EasyPost’s
DELETE /bank_accounts/:id
andDELETE /credit_cards/:id
endpoints.POST /bank_accounts1curl -X POST "https://api.easypost.com/v2/bank_accounts" \ 2 -u "$REFERRAL_USER_API_KEY:" \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "financial_connections_id": "fca_...", 6 "mandate_data": { 7 "ip_address": "127.0.0.1", 8 "user_agent": "Mozilla/5.0", 9 "accepted_at": 1722510730, 10 }, 11 "priority": "primary" 12}'
ReferralCustomer
users can deposit an initial amount into the EasyPost Wallet using EasyPost’s POST /bank_accounts/:id/charges
or POST /credit_cards/:id/charges
to start using services immediately.
1curl -X POST https://api.easypost.com/v2/credit_cards/card_.../charges \
2 -u "EASYPOST_API_KEY": \
3 -H 'Content-Type: application/json' \
4 -d '{
5 "amount": "2000"
6 }'
Once a payment method is established, EasyPost can automatically charge a recharge_amount
if a wallet balance falls below a recharge_threshold
. To ensure
uninterrupted service, platforms using the Decentralized white-label option should provide clear guidance on the recharge threshold and recharge amount system.
recharge_amount
is set to $100recharge_threshold
is set to zero
This means that the wallet will not automatically recharge unless the balance falls below zero. A negative balance can occur if shipment adjustments are applied due to inaccurately specified weights, dimensions, or other shipment details.
If a charge to the primary payment method fails, EasyPost will automatically attempt to charge the ReferralCustomer
’s secondary payment method, if one
is available. To avoid service interruptions, It is recommended that ReferralCustomers
have both a primary and secondary payment method configured.
Forge customers can configure the recharge_threshold
, recharge_amount
and secondary_recharge_amount
for a ReferralCustomer
using EasyPost’s PATCH /users
API.
These settings allow automatic maintenance of the wallet balance and prevent disruptions in service.
1# Update the authenticated user
2curl -X PATCH https://api.easypost.com/v2/users \
3 -u "EASYPOST_API_KEY": \
4 -H 'Content-Type: application/json' \
5 -d '{
6 "user": {
7 "recharge_threshold": "50.00"
8 }
9 }'
10
11# Update a child user
12curl -X PATCH https://api.easypost.com/v2/users/user_... \
13 -u "EASYPOST_API_KEY": \
14 -H 'Content-Type: application/json' \
15 -d '{
16 "user": {
17 "name": "Test Child"
18 }
19 }'
Upon creation, the ReferralCustomer
user automatically receives access to several EasyPost-Powered Carrier Accounts, which are billed through the platforms’ wallet.
To add additional carrier accounts for a ReferralCustomer
user, one of the following options can be used:
- API Integration: Use the Carrier Account API with the
ReferralCustomer
user’s Production API Key of the sub account to integrate additional carriers. - Forge Dashboard: Manually add carriers through the Carriers section of the Forge Dashboard.
Creating shipments for ReferralCustomer
users follows the same process as Parent Users, with key differences being the requirement to use the ReferralCustomer
user’s API Keys.
A Shipment Object
consists of:
- A valid
to_address
andfrom_address
- A
parcel
with shipping details - Any required
forms
for international deliveries
Once a shipment
is created, a Shipment Object
is used to retrieve shipping rates and purchase a label.
Please visit the Help Center for more information.