Skip to main content
Skip to main content

AdminStoresResource

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

All methods in this class require user authentication.

A store indicates the general configurations and details about the commerce store. By default, there's only one store in the Medusa backend. Admins can manage the store and its details or configurations.

Methods

update

Update the store'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.store.update({
name: "Medusa Store"
})
.then(({ store }) => {
console.log(store.id);
})

Parameters

payloadAdminPostStoreReqRequired
The attributes to update in the store.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminStoresRes>Required
Resolves to the store's details.

addCurrency

Add a currency code to the available currencies in a store. This doesn't create new currencies, as currencies are defined within the Medusa backend. To create a currency, you can create a migration that inserts the currency into the database.

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.store.addCurrency("eur")
.then(({ store }) => {
console.log(store.currencies);
})

Parameters

currency_codestringRequired
The code of the currency to add to the store.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminStoresRes>Required
Resolves to the store's details.

deleteCurrency

Delete a currency code from the available currencies in a store. This doesn't completely delete the currency and it can be added again later to the store.

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.store.deleteCurrency("eur")
.then(({ store }) => {
console.log(store.currencies);
})

Parameters

currency_codestringRequired
The code of the currency to delete from the store.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminStoresRes>Required
Resolves to the store's details.

retrieve

Retrieve the store'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.store.retrieve()
.then(({ store }) => {
console.log(store.id);
})

Parameters

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

Default: {}

Returns

ResponsePromiseResponsePromise<AdminExtendedStoresRes>Required
Resolves to the store's details.

listPaymentProviders

Retrieve a list of available payment providers in a store.

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.store.listPaymentProviders()
.then(({ payment_providers }) => {
console.log(payment_providers.length);
})

Parameters

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

Default: {}

Returns

ResponsePromiseResponsePromise<AdminPaymentProvidersList>Required
Resolves to the list of payment providers.

listTaxProviders

Retrieve a list of available tax providers in a store.

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.store.listTaxProviders()
.then(({ tax_providers }) => {
console.log(tax_providers.length);
})

Parameters

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

Default: {}

Returns

ResponsePromiseResponsePromise<AdminTaxProvidersList>Required
Resolves to the list of tax providers.
Was this section helpful?