(carrier_accounts)
Carriers are the companies who deliver your package. Shippo uses Carrier account objects as credentials to retrieve shipping rates and purchase labels from shipping Carriers.
Returns a list of all carrier accounts connected to your Shippo account. These carrier accounts include both Shippo carrier accounts and your own carrier accounts that you have connected to your Shippo account.
Additionally, you can get information about the service levels associated with each carrier account by passing in the ?service_levels=true query parameter.
Using it appends the property service_levels to each carrier account.
By default, if the query parameter is omitted, the service_levels property will not be included in the response.
from shippo import Shippo
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.carrier_accounts.list(request={})
assert res is not None
# Handle response
print(res)
components.CarrierAccountPaginatedList
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Creates a new carrier account or connects an existing carrier account to the Shippo account.
from shippo import Shippo
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.carrier_accounts.create(request={
"account_id": "321123",
"carrier": "fedex",
"parameters": {
"first_name": "Loyal",
"last_name": "Collier",
"phone_number": "(890) 307-8579",
"from_address_st": "<value>",
"from_address_city": "<value>",
"from_address_state": "<value>",
"from_address_zip": "<value>",
"from_address_country_iso2": "<value>",
},
"metadata": "FEDEX Account",
"test": False,
})
assert res is not None
# Handle response
print(res)
components.CarrierAccount
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Returns an existing carrier account using an object ID.
from shippo import Shippo
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.carrier_accounts.get(carrier_account_id="<id>")
assert res is not None
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
carrier_account_id |
str |
✔️ |
Object ID of the carrier account |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
components.CarrierAccount
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Updates an existing carrier account object. The account_id and carrier can't be updated. This is because they form the unique identifier together.
from shippo import Shippo
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.carrier_accounts.update(carrier_account_id="<id>", carrier_account_base={
"account_id": "****",
"carrier": "usps",
"parameters": {
"account_number": "94567e",
"aia_country_iso2": "US",
"billing_address_city": "San Francisco",
"billing_address_country_iso2": "US",
"billing_address_state": "CA",
"billing_address_street1": "731 Market St",
"billing_address_street2": "STE 200",
"billing_address_zip": "94103",
"collec_country_iso2": "US",
"collec_zip": "94103",
"company": "Shippo",
"currency_code": "USD",
"email": "hippo@shippo.com",
"full_name": "Shippo Meister",
"has_invoice": False,
"invoice_controlid": "1234",
"invoice_date": "20210529",
"invoice_number": "1112234",
"invoice_value": "11.23",
"phone": "1112223333",
"title": "Manager",
"ups_agreements": True,
},
})
assert res is not None
# Handle response
print(res)
components.CarrierAccount
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Used by client applications to setup or reconnect an existing carrier account with carriers that support OAuth 2.0
from shippo import Shippo
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.carrier_accounts.initiate_oauth2_signin(carrier_account_object_id="<id>", redirect_uri="https://enlightened-mortise.com/")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
carrier_account_object_id |
str |
✔️ |
The carrier account ID (UUID) to start a signin process. |
redirect_uri |
str |
✔️ |
Callback URL. The URL that tells the authorization server where to send the user back to after they approve the request. |
state |
Optional[str] |
➖ |
A random string generated by the consuming application and included in the request to prevent CSRF attacks. The consuming application checks that the same value is returned after the user authorizes Shippo. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
operations.InitiateOauth2SigninResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.UnauthorizedError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Adds a Shippo carrier account
from shippo import Shippo
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.carrier_accounts.register(request={
"parameters": {},
"carrier": "correos",
})
assert res is not None
# Handle response
print(res)
components.CarrierAccount
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Returns the registration status for the given account for the given carrier
from shippo import Shippo
from shippo.models import operations
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.carrier_accounts.get_registration_status(carrier=operations.Carrier.USPS)
assert res is not None
# Handle response
print(res)
components.CarrierAccountRegistrationStatus
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |