Online integrated shipping
You can use the Trustap API to generate and purchase shipping labels. Trustap uses Shippo to generate shipping labels. These shipping labels can be printed by sellers, attached to parcels, and used to transport items to a buyer.
Use the following flow to add shipping to an online transaction.
Step 1: Create buyers, sellers, and calculate charges
- Create a guest seller (
seller_id
) - Create a guest buyer (
buyer_id
) - Calculate charges
Step 2: Create a transaction
To enable shipping for a transaction, include use_shippo
and require_seller_acceptance
in features
when creating the transaction.
"features": ["use_shippo", "require_seller_acceptance"]
curl --location 'https://dev.stage.trustap.com/api/v1/me/transactions/create_with_guest_user' \
--header 'Trustap-User: 1-886e3c26-b585-4c92-a93b-e3c84b9b32e9' \
--header 'Content-Type: application/json' \
--user '<API_KEY>:' \
--data '{
"seller_id": "1-886e3c26-b585-4c92-a93b-e3c84b9b32e9",
"buyer_id": "1-615a70d4-b624-4243-95be-a8367b7953ea",
"creator_role": "seller",
"currency": "gbp",
"description": "Online no deposit",
"price": 20000,
"charge": 720,
"charge_calculator_version": 5,
"features": ["use_shippo", "require_seller_acceptance"]
}'
Step 3: Add sender address
Add your sender`s address. To receive an accurate shipping rate estimation, it is important to use an accurate address.
For country
, use ISO 3166-1 alpha-2 country codes.
curl --location 'https://dev.stage.trustap.com/api/v1/transactions/25439/shippo_address' \
--user '<API_KEY>:' \
--header 'Content-Type: application/json' \
--data '{
"city": "London",
"country": "GB",
"full_name": "Sarah Garcia",
"phone": "4215559099",
"state": "London",
"street_1": "12 Abercrombie Rd",
"zip_code": "E20 3AB",
"is_sender_address": true
}'
Step 4: Add recipient address
Add your recipient`s address. It is important to use an accurate address to avoid issues in shipping rate estimation and parcel delivery.
For country
, use ISO 3166-1 alpha-2 country codes.
curl --location 'https://dev.stage.trustap.com/api/v1/transactions/25439/shippo_address' \
--user '<API_KEY>:' \
--header 'Content-Type: application/json' \
--data '{
"city": "Manchester",
"country": "GB",
"full_name": "Bert Gray",
"phone": "123456789",
"zip_code": "M11 4DQ",
"state": "Manchester",
"street_1": "42 Stuart St",
"is_sender_address": false
}'
Step 5: Add parcel details
Add parcel details. These are the physical characteristics of your parcel. It's important to use accurate parcel details as they are used to determine the most appropriate shipping options for your parcel.
curl --location 'https://dev.stage.trustap.com/api/v1/transactions/25439/shippo_parcel_details' \
--user '<API_KEY>:' \
--header 'Content-Type: application/json' \
--data '{
"distance_unit": "cm",
"height": 10,
"length": 10,
"mass_unit": "lb",
"weight": 10,
"width": 10,
"shipment_date": "2025-11-18T00:35:03.463Z"
}'
Step 6: Declare customs for shipment
A customs declaration is a record of the details about the contents of a parcel. For international shipping, this is required. It ensures compliance with import and export regulations and helps determine duties, taxes, and restrictions.
curl --location 'https://dev.stage.trustap.com/api/v1/transactions/25439/shippo_customs_declaration' \
--user '<API_KEY>:' \
--header 'Content-Type: application/json' \
--data '{
"certify": true,
"certify_signer": "Bert Gray",
"description": "T-Shirt",
"incoterm": "DDU",
"mass_unit": "lb",
"net_weight": 10,
"non_delivery_option": "return",
"origin_country": "GB",
"quantity": 1,
"value_amount": "200",
"value_currency": "GBP"
}'
curl --location 'https://dev.stage.trustap.com/api/v1/transactions/25439/shippo_shipping_rates' \
--user '<API_KEY>:'
Step 8: Select shipping option and add to transaction
Select a rate returned from shippo_shipping_rates
using the id
of your preferred rate.
curl --location --globoff 'https://dev.stage.trustap.com/api/v1/transactions/25439/shippo_shipping_rate' \
--header 'Trustap-User: 1-886e3c26-b585-4c92-a93b-e3c84b9b32e9' \
--header 'Content-Type: application/json' \
--user '<API_KEY>:'\
--data '{
"rate_id": "417bb46e734c457e97316122081cf99f"
}'
Step 9: Buyer transfers funds
After a transaction is created, the buyer should be redirected to the payment page to pay for it. The cost of the transaction includes both the Trustap fee and shipping fee.
The payment URL that you send to the buyer depends on your type of integration.
In the following examples, replace <CALLBACK_PAYMENT>
with the redirect URI you set in authentication. This is the location where the buyer will be redirected to following payment.
Test environment | Production environment | |
---|---|---|
Guest buyer | https://actions.stage.trustap.com/online/transactions/{transaction_id}/guest_pay?redirect_uri=<CALLBACK_PAYMENT> | https: //actions.trustap.com/online/transactions/{transaction_id}/guest_pay?<CALLBACK_PAYMENT> |
Full user buyer | https: //actions.stage.trustap.com/online/transactions/{transaction_id}/pay?redirect_uri=<CALLBACK_PAYMENT> | https://actions.trustap.com/online/transactions/{transaction_id}/pay?<CALLBACK_PAYMENT> |
For example:
https://actions.stage.trustap.com/online/transactions/25439/guest_pay?redirect_uri=https://www.example.com
The payment screen looks like the following.
Step 10: Seller accepts payment
The seller must accept the payment. At this point, the shipping label is purchased.
curl --location --globoff --request POST 'https://dev.stage.trustap.com/api/v1/transactions/25439/accept_payment_with_guest_seller' \
--header 'Trustap-User: 1-886e3c26-b585-4c92-a93b-e3c84b9b32e9' \
--user '<API_KEY>:'
Step 11: Get Shipping label
The shipping label is available to download, print, and attach to the parcel using label_url
. Tracking details are also available through tracking_code
and tracking_url
.
curl --location --globoff 'https://dev.stage.trustap.com/api/v1/transactions/25372/shippo_shipping_label' \
--header 'Trustap-User: 1-615a70d4-b624-4243-95be-a8367b7953ea' \
--user '<API_KEY>:'
Step 12: Delivery to buyer is confirmed
When the Trustap API receives confirmation from the carrier that the parcel has been delivered, delivery will automatically be confirmed.
Optionally, the buyer or the seller can manually confirm delivery.
curl --location --globoff --request POST 'https://dev.stage.trustap.com/api/v1/transactions/25372/confirm_delivery_with_guest_buyer' \
--header 'Trustap-User: 1-615a70d4-b624-4243-95be-a8367b7953ea' \
--user '<API_KEY>:' \