(service_groups)
A service group is a set of service levels grouped together.
Rates at checkout uses services groups to present available shipping options to customers in their shopping basket.
- list - List all service groups
- create - Create a new service group
- update - Update an existing service group
- delete - Delete a service group
Returns a list of service group objects.
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.service_groups.list(request={})
assert res is not None
# Handle response
print(res)
List[components.ServiceGroup]
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Creates a new service group.
from shippo import Shippo
from shippo.models import components
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.service_groups.create(request={
"description": "USPS shipping options",
"name": "USPS Shipping",
"type": components.ServiceGroupTypeEnum.FLAT_RATE,
"service_levels": [
{
"account_object_id": "80feb1633d4a43c898f0058506cfd82d",
"service_level_token": "ups_next_day_air_saver",
},
],
"flat_rate": "5",
"flat_rate_currency": "USD",
"free_shipping_threshold_currency": "USD",
"free_shipping_threshold_min": "5",
"rate_adjustment": 15,
})
assert res is not None
# Handle response
print(res)
components.ServiceGroup
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Updates an existing service group object.
The object_id cannot be updated as it is the unique identifier for the object.
from shippo import Shippo
from shippo.models import components
with Shippo(
api_key_header="<YOUR_API_KEY_HERE>",
shippo_api_version="2018-02-08",
) as s_client:
res = s_client.service_groups.update(request={
"description": "USPS shipping options",
"name": "USPS Shipping",
"type": components.ServiceGroupTypeEnum.FLAT_RATE,
"object_id": "80feb1633d4a43c898f005850",
"is_active": True,
"service_levels": [
{
"account_object_id": "80feb1633d4a43c898f0058506cfd82d",
"service_level_token": "ups_next_day_air_saver",
},
{
"account_object_id": "80feb1633d4a43c898f0058506cfd82d",
"service_level_token": "ups_next_day_air_saver",
},
{
"account_object_id": "80feb1633d4a43c898f0058506cfd82d",
"service_level_token": "ups_next_day_air_saver",
},
],
"flat_rate": "5",
"flat_rate_currency": "USD",
"free_shipping_threshold_currency": "USD",
"free_shipping_threshold_min": "5",
"rate_adjustment": 15,
})
assert res is not None
# Handle response
print(res)
components.ServiceGroup
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |
Deletes an existing service group 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:
s_client.service_groups.delete(service_group_id="<id>")
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
service_group_id |
str |
✔️ |
Object ID of the service group |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| errors.SDKError |
4XX, 5XX |
*/* |