Skip to main content
Skip to main content
You're viewing the documentation for v1, which isn't the latest Medusa version.Latest documentation

AdminShippingProfilesResource

This class is used to send requests to Admin Shipping Profile API Routes. All its method are available in the JS Client under the medusa.admin.shippingProfiles property.

All methods in this class require user authentication.

A shipping profile is used to group products that can be shipped in the same manner. They are created by the admin and they're not associated with a fulfillment provider.

Related Guide: Shipping Profile architecture.

Methods​

create​

Create a shipping profile.

Example​

import { ShippingProfileType } from "@medusajs/medusa"
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.create({
name: "Large Products",
type: ShippingProfileType.DEFAULT
})
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})

Parameters​

The shipping profile to create.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns​

ResponsePromiseResponsePromise<AdminShippingProfilesRes>Required
Resolves to the shipping profile's details.

update​

Update a shipping profile's details.

Example​

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.update(shippingProfileId, {
name: 'Large Products'
})
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})

Parameters​

idstringRequired
The shipping profile's ID.
The attributes to update in the shipping profile.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns​

ResponsePromiseResponsePromise<AdminShippingProfilesRes>Required
Resolves to the shipping profile's details.

delete​

Delete a shipping profile. Associated shipping options are deleted as well.

Example​

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.delete(profileId)
.then(({ id, object, deleted }) => {
console.log(id);
})

Parameters​

idstringRequired
The shipping profile's ID.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns​

ResponsePromiseResponsePromise<DeleteResponse>Required
Resolves to the deletion operation's details.

retrieve​

Retrieve a shipping profile's details.

Example​

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.retrieve(profileId)
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})

Parameters​

idstringRequired
The shipping profile's ID.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns​

ResponsePromiseResponsePromise<AdminShippingProfilesRes>Required
Resolves to the shipping profile's details.

list​

Retrieve a list of shipping profiles.

Example​

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.list()
.then(({ shipping_profiles }) => {
console.log(shipping_profiles.length);
})

Parameters​

customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns​

ResponsePromiseResponsePromise<AdminShippingProfilesListRes>Required
Resolves to the list of shipping profiles.
Was this section helpful?