Skip to content

Latest commit

 

History

History
359 lines (242 loc) · 21.7 KB

File metadata and controls

359 lines (242 loc) · 21.7 KB

CarrierAccounts

(carrier_accounts)

Overview

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.

Available Operations

list

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.

Example Usage

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)

Parameters

Parameter Type Required Description
request operations.ListCarrierAccountsRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.CarrierAccountPaginatedList

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

create

Creates a new carrier account or connects an existing carrier account to the Shippo account.

Example Usage

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)

Parameters

Parameter Type Required Description
request components.ConnectExistingOwnAccountRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.CarrierAccount

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

get

Returns an existing carrier account using an object ID.

Example Usage

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)

Parameters

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.

Response

components.CarrierAccount

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

update

Updates an existing carrier account object. The account_id and carrier can't be updated. This is because they form the unique identifier together.

Example Usage

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)

Parameters

Parameter Type Required Description
carrier_account_id str ✔️ Object ID of the carrier account
carrier_account_base Optional[components.CarrierAccountBase] Examples.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.CarrierAccount

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

initiate_oauth2_signin

Used by client applications to setup or reconnect an existing carrier account with carriers that support OAuth 2.0

Example Usage

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)

Parameters

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.

Response

operations.InitiateOauth2SigninResponse

Errors

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 */*

register

Adds a Shippo carrier account

Example Usage

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)

Parameters

Parameter Type Required Description
request operations.RegisterCarrierAccountRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.CarrierAccount

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

get_registration_status

Returns the registration status for the given account for the given carrier

Example Usage

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)

Parameters

Parameter Type Required Description
carrier operations.Carrier ✔️ filter by specific carrier
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.CarrierAccountRegistrationStatus

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*