--- displayed_sidebar: jsClientSidebar slug: /references/js-client/AdminShippingOptionsResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # AdminShippingOptionsResource This class is used to send requests to [Admin Shipping Option API Routes](https://docs.medusajs.com/api/admin#shipping-options). All its method are available in the JS Client under the `medusa.admin.shippingOptions` property. All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). A shipping option is used to define the available shipping methods during checkout or when creating a return. Admins can create an unlimited number of shipping options, each associated with a shipping profile and fulfillment provider, among other resources. Related Guide: [Shipping Option architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-option). ## Methods ### create Create a shipping option. #### Example ```ts 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.shippingOptions .create({ name: "PostFake", region_id, provider_id, data: {}, price_type: "flat_rate", }) .then(({ shipping_option }) => { console.log(shipping_option.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs with additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "name", "type": "`string`", "description": "The name of the Shipping Option", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "price_type", "type": "`string`", "description": "The type of the Shipping Option price. `flat\\_rate` indicates fixed pricing, whereas `calculated` indicates that the price will be calculated each time by the fulfillment provider.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "profile_id", "type": "`string`", "description": "The ID of the Shipping Profile to add the Shipping Option to.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "provider_id", "type": "`string`", "description": "The ID of the Fulfillment Provider that handles the Shipping Option.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the Region in which the Shipping Option will be available.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "requirements", "type": "[OptionRequirement](../internal/classes/internal.OptionRequirement.mdx)[]", "description": "The requirements that must be satisfied for the Shipping Option to be available.", "optional": true, "defaultValue": "", "expandable": false, "children": [ { "name": "amount", "type": "`number`", "description": "The amount to compare with.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "type", "type": "`string`", "description": "The type of the requirement", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "The data needed for the Fulfillment Provider to identify the Shipping Option.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The shipping option's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "includes_tax", "type": "`boolean`", "description": "Whether the shipping option price include tax", "optional": false, "defaultValue": "false", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "is_return", "type": "`boolean`", "description": "Flag to indicate if the Shipping Option can be used for Return shipments.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "`Record`", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "name", "type": "`string`", "description": "The name given to the Shipping Option - this may be displayed to the Customer.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "price_type", "type": "[ShippingOptionPriceType](../internal/enums/internal.internal.ShippingOptionPriceType.mdx)", "description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat\\_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "profile", "type": "[ShippingProfile](../internal/classes/internal.ShippingProfile.mdx)", "description": "The details of the shipping profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "profile_id", "type": "`string`", "description": "The ID of the Shipping Profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "provider", "type": "[FulfillmentProvider](../internal/classes/internal.internal.FulfillmentProvider.mdx)", "description": "The details of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "provider_id", "type": "`string`", "description": "The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "requirements", "type": "[ShippingOptionRequirement](../internal/classes/internal.internal.ShippingOptionRequirement.mdx)[]", "description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### delete Delete a shipping option. Once deleted, it can't be used when creating orders or returns. #### Example ```ts 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.shippingOptions .delete(optionId) .then(({ id, object, deleted }) => { console.log(id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### list Retrieve a list of shipping options. The shipping options can be filtered by fields such as `region_id` or `is_return` passed in the `query` parameter. #### Example ```ts 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.shippingOptions.list().then(({ shipping_options, count }) => { console.log(shipping_options.length) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "The data needed for the Fulfillment Provider to identify the Shipping Option.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The shipping option's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "includes_tax", "type": "`boolean`", "description": "Whether the shipping option price include tax", "optional": false, "defaultValue": "false", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "is_return", "type": "`boolean`", "description": "Flag to indicate if the Shipping Option can be used for Return shipments.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "`Record`", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "name", "type": "`string`", "description": "The name given to the Shipping Option - this may be displayed to the Customer.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "price_type", "type": "[ShippingOptionPriceType](../internal/enums/internal.internal.ShippingOptionPriceType.mdx)", "description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat\\_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "profile", "type": "[ShippingProfile](../internal/classes/internal.ShippingProfile.mdx)", "description": "The details of the shipping profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "profile_id", "type": "`string`", "description": "The ID of the Shipping Profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "provider", "type": "[FulfillmentProvider](../internal/classes/internal.internal.FulfillmentProvider.mdx)", "description": "The details of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "provider_id", "type": "`string`", "description": "The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "requirements", "type": "[ShippingOptionRequirement](../internal/classes/internal.internal.ShippingOptionRequirement.mdx)[]", "description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### retrieve Retrieve a shipping option's details. #### Example ```ts 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.shippingOptions.retrieve(optionId).then(({ shipping_option }) => { console.log(shipping_option.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "The data needed for the Fulfillment Provider to identify the Shipping Option.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The shipping option's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "includes_tax", "type": "`boolean`", "description": "Whether the shipping option price include tax", "optional": false, "defaultValue": "false", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "is_return", "type": "`boolean`", "description": "Flag to indicate if the Shipping Option can be used for Return shipments.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "`Record`", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "name", "type": "`string`", "description": "The name given to the Shipping Option - this may be displayed to the Customer.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "price_type", "type": "[ShippingOptionPriceType](../internal/enums/internal.internal.ShippingOptionPriceType.mdx)", "description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat\\_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "profile", "type": "[ShippingProfile](../internal/classes/internal.ShippingProfile.mdx)", "description": "The details of the shipping profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "profile_id", "type": "`string`", "description": "The ID of the Shipping Profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "provider", "type": "[FulfillmentProvider](../internal/classes/internal.internal.FulfillmentProvider.mdx)", "description": "The details of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "provider_id", "type": "`string`", "description": "The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "requirements", "type": "[ShippingOptionRequirement](../internal/classes/internal.internal.ShippingOptionRequirement.mdx)[]", "description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### update Update a shipping option's details. #### Example ```ts 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.shippingOptions .update(optionId, { name: "PostFake", requirements: [ { id, type: "max_subtotal", amount: 1000, }, ], }) .then(({ shipping_option }) => { console.log(shipping_option.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs with additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "name", "type": "`string`", "description": "The name of the Shipping Option", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "requirements", "type": "[OptionRequirement](../internal/classes/internal.OptionRequirement-1.mdx)[]", "description": "The requirements that must be satisfied for the Shipping Option to be available.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "amount", "type": "`number`", "description": "The amount to compare with.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The ID of an existing requirement. If an ID is passed, the existing requirement's details are updated. Otherwise, a new requirement is created.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "type", "type": "`string`", "description": "The type of the requirement", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "The data needed for the Fulfillment Provider to identify the Shipping Option.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "deleted_at", "type": "``null`` \\| `Date`", "description": "The date with timezone at which the resource was deleted.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The shipping option's ID", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "includes_tax", "type": "`boolean`", "description": "Whether the shipping option price include tax", "optional": false, "defaultValue": "false", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "is_return", "type": "`boolean`", "description": "Flag to indicate if the Shipping Option can be used for Return shipments.", "optional": false, "defaultValue": "false", "expandable": false, "children": [] }, { "name": "metadata", "type": "`Record`", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "name", "type": "`string`", "description": "The name given to the Shipping Option - this may be displayed to the Customer.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "price_type", "type": "[ShippingOptionPriceType](../internal/enums/internal.internal.ShippingOptionPriceType.mdx)", "description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat\\_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "profile", "type": "[ShippingProfile](../internal/classes/internal.ShippingProfile.mdx)", "description": "The details of the shipping profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "profile_id", "type": "`string`", "description": "The ID of the Shipping Profile that the shipping option belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "provider", "type": "[FulfillmentProvider](../internal/classes/internal.internal.FulfillmentProvider.mdx)", "description": "The details of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "provider_id", "type": "`string`", "description": "The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this shipping option can be used in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "requirements", "type": "[ShippingOptionRequirement](../internal/classes/internal.internal.ShippingOptionRequirement.mdx)[]", "description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} />