Skip to content

Latest commit

 

History

History
366 lines (267 loc) · 29.8 KB

File metadata and controls

366 lines (267 loc) · 29.8 KB

CarrierAccounts

(CarrierAccounts)

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

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

ListCarrierAccountsRequest req = new ListCarrierAccountsRequest() {};

var res = await sdk.CarrierAccounts.ListAsync(req);

// handle response

Parameters

Parameter Type Required Description
request ListCarrierAccountsRequest ✔️ The request object to use for the request.

Response

CarrierAccountPaginatedList

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

Create

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

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;
using System.Collections.Generic;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.CarrierAccounts.CreateAsync(
    connectExistingOwnAccountRequest: new ConnectExistingOwnAccountRequest() {
        AccountId = "321123",
        Carrier = "fedex",
        Metadata = "FEDEX Account",
        Parameters = ConnectExistingOwnAccountRequestParameters.CreateFedExConnectExistingOwnAccountParameters(
            new FedExConnectExistingOwnAccountParameters() {
                FirstName = "Loyal",
                LastName = "Collier",
                PhoneNumber = "(890) 307-8579",
                FromAddressSt = "<value>",
                FromAddressCity = "<value>",
                FromAddressState = "<value>",
                FromAddressZip = "<value>",
                FromAddressCountryIso2 = "<value>",
            }
        ),
        Test = false,
    },
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
ConnectExistingOwnAccountRequest ConnectExistingOwnAccountRequest ✔️ Examples.
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

CarrierAccount

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

Get

Returns an existing carrier account using an object ID.

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.CarrierAccounts.GetAsync(
    carrierAccountId: "<id>",
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
CarrierAccountId string ✔️ Object ID of the carrier account
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

CarrierAccount

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 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

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;
using System.Collections.Generic;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.CarrierAccounts.UpdateAsync(
    carrierAccountId: "<id>",
    shippoApiVersion: "2018-02-08",
    carrierAccountBase: new CarrierAccountBase() {
        AccountId = "****",
        Carrier = "usps",
        Parameters = CarrierAccountBaseParameters.CreateUPSConnectExistingOwnAccountParameters(
            new UPSConnectExistingOwnAccountParameters() {
                AccountNumber = "94567e",
                AiaCountryIso2 = "US",
                BillingAddressCity = "San Francisco",
                BillingAddressCountryIso2 = "US",
                BillingAddressState = "CA",
                BillingAddressStreet1 = "731 Market St",
                BillingAddressStreet2 = "STE 200",
                BillingAddressZip = "94103",
                CollecCountryIso2 = "US",
                CollecZip = "94103",
                Company = "Shippo",
                CurrencyCode = "USD",
                Email = "[email protected]",
                FullName = "Shippo Meister",
                HasInvoice = false,
                InvoiceControlid = "1234",
                InvoiceDate = "20210529",
                InvoiceNumber = "1112234",
                InvoiceValue = "11.23",
                Phone = "1112223333",
                Title = "Manager",
                UpsAgreements = false,
            }
        ),
    }
);

// handle response

Parameters

Parameter Type Required Description Example
CarrierAccountId string ✔️ Object ID of the carrier account
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08
CarrierAccountBase CarrierAccountBase Examples.

Response

CarrierAccount

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

InitiateOauth2Signin

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

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

InitiateOauth2SigninRequest req = new InitiateOauth2SigninRequest() {
    CarrierAccountObjectId = "<id>",
    RedirectUri = "https://enlightened-mortise.com/",
};

var res = await sdk.CarrierAccounts.InitiateOauth2SigninAsync(req);

// handle response

Parameters

Parameter Type Required Description
request InitiateOauth2SigninRequest ✔️ The request object to use for the request.

Response

InitiateOauth2SigninResponse

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.InitiateOauth2SigninResponseBody 400 application/json
Shippo.Models.Errors.InitiateOauth2SigninCarrierAccountsResponseBody 401 application/json
Shippo.Models.Errors.InitiateOauth2SigninCarrierAccountsResponseResponseBody 404 application/json
Shippo.Models.Errors.SDKException 4XX, 5XX */*

Register

Adds a Shippo carrier account

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.CarrierAccounts.RegisterAsync(
    requestBody: RegisterCarrierAccountRequestBody.CreateCarrierAccountCorreosCreateRequest(
        new CarrierAccountCorreosCreateRequest() {
            Carrier = "correos",
            Parameters = new CarrierAccountCorreosCreateRequestParameters() {},
        }
    ),
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
RequestBody RegisterCarrierAccountRequestBody ✔️ Examples.
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

CarrierAccount

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

GetRegistrationStatus

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

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.CarrierAccounts.GetRegistrationStatusAsync(
    carrier: Shippo.Models.Requests.Carrier.Usps,
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
Carrier Carrier ✔️ filter by specific carrier
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

CarrierAccountRegistrationStatus

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*