AdminRegionsResource
This class is used to send requests to Admin Region API Routes. All its method
are available in the JS Client under the medusa.admin.regions
property.
All methods in this class require authentication.
Regions are different countries or geographical regions that the commerce store serves customers in. Admins can manage these regions, their providers, and more.
Related Guide: How to manage regions.
Methods
create
Create a region.
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.regions.create({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
payment_providers: [
"manual"
],
fulfillment_providers: [
"manual"
],
countries: [
"DK"
]
})
.then(({ region }) => {
console.log(region.id);
})
Parameters
The region to create.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>Requiredupdate
Update a region's details.
Example
Parameters
id
stringRequiredThe attributes to update in the region.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>Requireddelete
Delete a region. Associated resources, such as providers or currencies are not deleted. Associated tax rates are deleted.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<DeleteResponse>RequiredResolves to the deletion operation's details.
ResponsePromise
ResponsePromise<DeleteResponse>Requiredretrieve
Retrieve a region's details.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Query params
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>Requiredlist
Retrieve a list of Regions. The regions can be filtered by fields such as created_at
passed in the query
parameter. The regions can also be paginated.
Example
To list regions:
By default, only the first 50
records are retrieved. You can control pagination by specifying the limit
and offset
properties:
Parameters
customHeaders
Record<string, any>RequiredDefault: {}
Filters and pagination configurations to apply on the retrieved regions.
Returns
ResponsePromise
ResponsePromise<AdminRegionsListRes>RequiredResolves to the list of regions with pagination fields.
ResponsePromise
ResponsePromise<AdminRegionsListRes>RequiredaddCountry
Add a country to the list of countries in a region.
Example
Parameters
id
stringRequiredThe country to add.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>RequireddeleteCountry
Delete a country from the list of countries in a region. The country will still be available in the system, and it can be used in other regions.
Example
Parameters
id
stringRequiredcountry_code
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredaddFulfillmentProvider
Add a fulfillment provider to the list of fulfullment providers in a region.
Example
Parameters
id
stringRequiredThe fulfillment provider to add.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>RequireddeleteFulfillmentProvider
Delete a fulfillment provider from a region. The fulfillment provider will still be available for usage in other regions.
Example
Parameters
id
stringRequiredprovider_id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredretrieveFulfillmentOptions
Retrieve a list of fulfillment options available in a region.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminGetRegionsRegionFulfillmentOptionsRes>RequiredResolves to the list of fulfillment options.
ResponsePromise
ResponsePromise<AdminGetRegionsRegionFulfillmentOptionsRes>RequiredaddPaymentProvider
Add a payment provider to the list of payment providers in a region.
Example
Parameters
id
stringRequiredThe payment provider to add.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>RequireddeletePaymentProvider
Delete a payment provider from a region. The payment provider will still be available for usage in other regions.
Example
Parameters
id
stringRequiredprovider_id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminRegionsRes>RequiredResolves to the region's details.
ResponsePromise
ResponsePromise<AdminRegionsRes>Required