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 user 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
addCountry
Add a country to the list of countries in a region.
Example
Parameters
id
stringRequiredThe country to add.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
Resolves to the region's details.
addFulfillmentProvider
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
Resolves to the region's details.
addPaymentProvider
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
Resolves to the region's details.
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
Resolves to the region's details.
delete
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
Resolves to the deletion operation's details.
deleteCountry
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
Resolves to the region's details.
deleteFulfillmentProvider
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
Resolves to the region's details.
deletePaymentProvider
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
Resolves to the region's details.
list
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
Filters and pagination configurations to apply on the retrieved regions.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
Resolves to the list of regions with pagination fields.
retrieve
Retrieve a region's details.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
Resolves to the region's details.
retrieveFulfillmentOptions
Retrieve a list of fulfillment options available in a region.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
Resolves to the list of fulfillment options.
update
Update a region's details.
Example
Parameters
id
stringRequiredThe attributes to update in the region.
customHeaders
Record<string, any>RequiredDefault: {}