docs: enhance how references are generated (#5805)

* adjusted configurations

* enhancements to tool and configurations

* change reference in docs

* fixed issue in workflows reference

* added project name

* more optimizations

* fix context error

* added a types reference

* resolved missing types

* fix reference reflection types not having children

* add an expand url parameter

* added new option to the README

* added details about new option
This commit is contained in:
Shahed Nasser authored and GitHub committed 2023-12-05 15:29:41 +02:00
1 parent a418e6cebc
commit 892d737c1f
4358 files changed
+947876 -534760

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -0,0 +1,358 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/Admin
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Admin
This class includes properties used to send requests to the [Admin API Routes](https://docs.medusajs.com/api/admin). All its properties
are available in the JS Client under the `medusa.admin` property.
## Properties
<ParameterTypes parameters={[
{
"name": "auth",
"type": "[AdminAuthResource](js_client.AdminAuthResource.mdx)",
"description": "An instance of [AdminAuthResource](js_client.AdminAuthResource.mdx) used to send requests to [Admin Auth API Routes](https://docs.medusajs.com/api/admin#auth).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "batchJobs",
"type": "[AdminBatchJobsResource](js_client.AdminBatchJobsResource.mdx)",
"description": "An instance of [AdminBatchJobsResource](js_client.AdminBatchJobsResource.mdx) used to send requests to [Admin Batch Job API Routes](https://docs.medusajs.com/api/admin#batch-jobs).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "collections",
"type": "[AdminCollectionsResource](js_client.AdminCollectionsResource.mdx)",
"description": "An instance of [AdminCollectionsResource](js_client.AdminCollectionsResource.mdx) used to send requests to [Admin Product Collection API Routes](https://docs.medusajs.com/api/admin#product-collections).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currencies",
"type": "[AdminCurrenciesResource](js_client.AdminCurrenciesResource.mdx)",
"description": "An instance of [AdminCurrenciesResource](js_client.AdminCurrenciesResource.mdx) used to send requests to [Admin Currency API Routes](https://docs.medusajs.com/api/admin#currencies\\_getcurrencies).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "custom",
"type": "[AdminCustomResource](js_client.AdminCustomResource.mdx)",
"description": "An instance of [AdminCustomResource](js_client.AdminCustomResource.mdx) used to send requests to custom API Routes.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerGroups",
"type": "[AdminCustomerGroupsResource](js_client.AdminCustomerGroupsResource.mdx)",
"description": "An instance of [AdminCustomerGroupsResource](js_client.AdminCustomerGroupsResource.mdx) used to send requests to [Admin Customer Group API Routes](https://docs.medusajs.com/api/admin#customer-groups).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customers",
"type": "[AdminCustomersResource](js_client.AdminCustomersResource.mdx)",
"description": "An instance of [AdminCustomersResource](js_client.AdminCustomersResource.mdx) used to send requests to [Admin Customer API Routes](https://docs.medusajs.com/api/admin#customers).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discounts",
"type": "[AdminDiscountsResource](js_client.AdminDiscountsResource.mdx)",
"description": "An instance of [AdminDiscountsResource](js_client.AdminDiscountsResource.mdx) used to send requests to [Admin Discount API Routes](https://docs.medusajs.com/api/admin#discounts).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draftOrders",
"type": "[AdminDraftOrdersResource](js_client.AdminDraftOrdersResource.mdx)",
"description": "An instance of [AdminDraftOrdersResource](js_client.AdminDraftOrdersResource.mdx) used to send requests to [Admin Draft Order API Routes](https://docs.medusajs.com/api/admin#draft-orders).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "giftCards",
"type": "[AdminGiftCardsResource](js_client.AdminGiftCardsResource.mdx)",
"description": "An instance of [AdminGiftCardsResource](js_client.AdminGiftCardsResource.mdx) used to send requests to [Admin Gift Card API Routes](https://docs.medusajs.com/api/admin#gift-cards).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "inventoryItems",
"type": "[AdminInventoryItemsResource](js_client.AdminInventoryItemsResource.mdx)",
"description": "An instance of [AdminInventoryItemsResource](js_client.AdminInventoryItemsResource.mdx) used to send requests to [Admin Inventory Item API Routes](https://docs.medusajs.com/api/admin#inventory-items).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "invites",
"type": "[AdminInvitesResource](js_client.AdminInvitesResource.mdx)",
"description": "An instance of [AdminInvitesResource](js_client.AdminInvitesResource.mdx) used to send requests to [Admin Invite API Routes](https://docs.medusajs.com/api/admin#invites).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "notes",
"type": "[AdminNotesResource](js_client.AdminNotesResource.mdx)",
"description": "An instance of [AdminNotesResource](js_client.AdminNotesResource.mdx) used to send requests to [Admin Note API Routes](https://docs.medusajs.com/api/admin#notes).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "notifications",
"type": "[AdminNotificationsResource](js_client.AdminNotificationsResource.mdx)",
"description": "An instance of [AdminNotificationsResource](js_client.AdminNotificationsResource.mdx) used to send requests to [Admin Notification API Routes](https://docs.medusajs.com/api/admin#notifications).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "orderEdits",
"type": "[AdminOrderEditsResource](js_client.AdminOrderEditsResource.mdx)",
"description": "An instance of [AdminOrderEditsResource](js_client.AdminOrderEditsResource.mdx) used to send requests to [Admin Order Edit API Routes](https://docs.medusajs.com/api/admin#order-edits).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "orders",
"type": "[AdminOrdersResource](js_client.AdminOrdersResource.mdx)",
"description": "An instance of [AdminOrdersResource](js_client.AdminOrdersResource.mdx) used to send requests to [Admin Order API Routes](https://docs.medusajs.com/api/admin#orders).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paymentCollections",
"type": "[AdminPaymentCollectionsResource](js_client.AdminPaymentCollectionsResource.mdx)",
"description": "An instance of [AdminPaymentCollectionsResource](js_client.AdminPaymentCollectionsResource.mdx) used to send requests to [Admin Payment Collection API Routes](https://docs.medusajs.com/api/admin#payment-collections).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payments",
"type": "[AdminPaymentsResource](js_client.AdminPaymentsResource.mdx)",
"description": "An instance of [AdminPaymentsResource](js_client.AdminPaymentsResource.mdx) used to send requests to [Admin Payment API Routes](https://docs.medusajs.com/api/admin#payments).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "priceLists",
"type": "[AdminPriceListResource](js_client.AdminPriceListResource.mdx)",
"description": "An instance of [AdminPriceListResource](js_client.AdminPriceListResource.mdx) used to send requests to [Admin Price List API Routes](https://docs.medusajs.com/api/admin#price-lists).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productCategories",
"type": "[AdminProductCategoriesResource](js_client.AdminProductCategoriesResource.mdx)",
"description": "An instance of [AdminProductCategoriesResource](js_client.AdminProductCategoriesResource.mdx) used to send requests to [Admin Product Category API Routes](https://docs.medusajs.com/api/admin#product-categories).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productTags",
"type": "[AdminProductTagsResource](js_client.AdminProductTagsResource.mdx)",
"description": "An instance of [AdminProductTagsResource](js_client.AdminProductTagsResource.mdx) used to send requests to [Admin Product Tag API Routes](https://docs.medusajs.com/api/admin#product-tags).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productTypes",
"type": "[AdminProductTypesResource](js_client.AdminProductTypesResource.mdx)",
"description": "An instance of [AdminProductTypesResource](js_client.AdminProductTypesResource.mdx) used to send requests to [Admin Product Type API Routes](https://docs.medusajs.com/api/admin#product-types).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "products",
"type": "[AdminProductsResource](js_client.AdminProductsResource.mdx)",
"description": "An instance of [AdminProductsResource](js_client.AdminProductsResource.mdx) used to send requests to [Admin Product API Routes](https://docs.medusajs.com/api/admin#products).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "publishableApiKeys",
"type": "[AdminPublishableApiKeyResource](js_client.AdminPublishableApiKeyResource.mdx)",
"description": "An instance of [AdminPublishableApiKeyResource](js_client.AdminPublishableApiKeyResource.mdx) used to send requests to [Admin Publishable API Key API Routes](https://docs.medusajs.com/api/admin#publishable-api-keys).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regions",
"type": "[AdminRegionsResource](js_client.AdminRegionsResource.mdx)",
"description": "An instance of [AdminRegionsResource](js_client.AdminRegionsResource.mdx) used to send requests to [Admin Region API Routes](https://docs.medusajs.com/api/admin#regions).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "reservations",
"type": "[AdminReservationsResource](js_client.AdminReservationsResource.mdx)",
"description": "An instance of [AdminReservationsResource](js_client.AdminReservationsResource.mdx) used to send requests to [Admin Reservation API Routes](https://docs.medusajs.com/api/admin#reservations).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "returnReasons",
"type": "[AdminReturnReasonsResource](js_client.AdminReturnReasonsResource.mdx)",
"description": "An instance of [AdminReturnReasonsResource](js_client.AdminReturnReasonsResource.mdx) used to send requests to [Admin Return Reason API Routes](https://docs.medusajs.com/api/admin#return-reasons).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "returns",
"type": "[AdminReturnsResource](js_client.AdminReturnsResource.mdx)",
"description": "An instance of [AdminReturnsResource](js_client.AdminReturnsResource.mdx) used to send requests to [Admin Return API Routes](https://docs.medusajs.com/api/admin#returns).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "salesChannels",
"type": "[AdminSalesChannelsResource](js_client.AdminSalesChannelsResource.mdx)",
"description": "An instance of [AdminSalesChannelsResource](js_client.AdminSalesChannelsResource.mdx) used to send requests to [Admin Sales Channel API Routes](https://docs.medusajs.com/api/admin#sales-channels).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingOptions",
"type": "[AdminShippingOptionsResource](js_client.AdminShippingOptionsResource.mdx)",
"description": "An instance of [AdminShippingOptionsResource](js_client.AdminShippingOptionsResource.mdx) used to send requests to [Admin Shipping Option API Routes](https://docs.medusajs.com/api/admin#shipping-options).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingProfiles",
"type": "[AdminShippingProfilesResource](js_client.AdminShippingProfilesResource.mdx)",
"description": "An instance of [AdminShippingProfilesResource](js_client.AdminShippingProfilesResource.mdx) used to send requests to [Admin Shipping Profile API Routes](https://docs.medusajs.com/api/admin#shipping-profiles).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "stockLocations",
"type": "[AdminStockLocationsResource](js_client.AdminStockLocationsResource.mdx)",
"description": "An instance of [AdminStockLocationsResource](js_client.AdminStockLocationsResource.mdx) used to send requests to [Admin Stock Location API Routes](https://docs.medusajs.com/api/admin#stock-locations).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "store",
"type": "[AdminStoresResource](js_client.AdminStoresResource.mdx)",
"description": "An instance of [AdminStoresResource](js_client.AdminStoresResource.mdx) used to send requests to [Admin Store API Routes](https://docs.medusajs.com/api/admin#store).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "swaps",
"type": "[AdminSwapsResource](js_client.AdminSwapsResource.mdx)",
"description": "An instance of [AdminSwapsResource](js_client.AdminSwapsResource.mdx) used to send requests to [Admin Swap API Routes](https://docs.medusajs.com/api/admin#swaps).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "taxRates",
"type": "[AdminTaxRatesResource](js_client.AdminTaxRatesResource.mdx)",
"description": "An instance of [AdminTaxRatesResource](js_client.AdminTaxRatesResource.mdx) used to send requests to [Admin Tax Rate API Routes](https://docs.medusajs.com/api/admin#tax-rates).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "uploads",
"type": "[AdminUploadsResource](js_client.AdminUploadsResource.mdx)",
"description": "An instance of [AdminUploadsResource](js_client.AdminUploadsResource.mdx) used to send requests to [Admin Upload API Routes](https://docs.medusajs.com/api/admin#uploads).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "users",
"type": "[AdminUsersResource](js_client.AdminUsersResource.mdx)",
"description": "An instance of [AdminUsersResource](js_client.AdminUsersResource.mdx) used to send requests to [Admin User API Routes](https://docs.medusajs.com/api/admin#users).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "variants",
"type": "[AdminVariantsResource](js_client.AdminVariantsResource.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
@@ -0,0 +1,528 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminAuthResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminAuthResource
This class is used to send requests to [Admin Auth API Routes](https://docs.medusajs.com/api/admin#auth\_getauth). All its method
are available in the JS Client under the `medusa.admin.auth` property.
The methods in this class allow admin users to manage their session, such as login or log out.
You can send authenticated requests for an admin user either using the Cookie header, their API token, or the JWT Token.
When you log the admin user in using the [createSession](js_client.AdminAuthResource.mdx#createsession) method, the JS client will automatically attach the
cookie header in all subsequent requests.
Related Guide: [How to implement user profiles](https://docs.medusajs.com/modules/users/admin/manage-profile).
## Methods
### createSession
Log a User in using their credentials. If the user is authenticated successfully, the cookie is automatically attached to subsequent requests sent with the JS Client.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.admin.AdminAuthResource.createSession({
email: "user@example.com",
password: "supersecret"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminPostAuthReq](../../medusa/classes/medusa.AdminPostAuthReq.mdx)",
"description": "The credentials of the user.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "email",
"type": "`string`",
"description": "The user's email.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "password",
"type": "`string`",
"description": "The user's password.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminAuthRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the user's details.",
"expandable": false,
"children": [
{
"name": "user",
"type": "Omit&#60;[User](../../entities/classes/entities.User.mdx), \"password_hash\"&#62;",
"description": "User details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "api_token",
"type": "`string`",
"description": "An API token associated with the user.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "email",
"type": "`string`",
"description": "The email of the User",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "first_name",
"type": "`string`",
"description": "The first name of the User",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The user's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "last_name",
"type": "`string`",
"description": "The last name of the User",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "role",
"type": "[UserRoles](../../entities/enums/entities.UserRoles.mdx)",
"description": "The user's role. These roles don't provide any different privileges.",
"optional": false,
"defaultValue": "member",
"expandable": false,
"children": [
{
"name": "ADMIN",
"type": "`\"admin\"`",
"description": "The user is an admin.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "DEVELOPER",
"type": "`\"developer\"`",
"description": "The user is a developer.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "MEMBER",
"type": "`\"member\"`",
"description": "The user is a team member.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### deleteSession
Log out the user and remove their authentication session. This will only work if you're using Cookie session for authentication. If the API token is still passed in the header,
the user is still authorized to perform admin functionalities in other API Routes.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in
medusa.admin.auth.deleteSession()
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves when user is logged out successfully.",
"expandable": false,
"children": []
}
]} />
___
### getSession
Get the currently logged in user's details. Can also be used to check if there is an authenticated user.
#### 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.auth.getSession()
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminAuthRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the logged-in user's details.",
"expandable": false,
"children": [
{
"name": "user",
"type": "Omit&#60;[User](../../entities/classes/entities.User.mdx), \"password_hash\"&#62;",
"description": "User details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "api_token",
"type": "`string`",
"description": "An API token associated with the user.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "email",
"type": "`string`",
"description": "The email of the User",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "first_name",
"type": "`string`",
"description": "The first name of the User",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The user's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "last_name",
"type": "`string`",
"description": "The last name of the User",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "role",
"type": "[UserRoles](../../entities/enums/entities.UserRoles.mdx)",
"description": "The user's role. These roles don't provide any different privileges.",
"optional": false,
"defaultValue": "member",
"expandable": false,
"children": [
{
"name": "ADMIN",
"type": "`\"admin\"`",
"description": "The user is an admin.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "DEVELOPER",
"type": "`\"developer\"`",
"description": "The user is a developer.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "MEMBER",
"type": "`\"member\"`",
"description": "The user is a team member.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### getToken
Authenticate the user and retrieve a JWT token to use for subsequent authenticated requests.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.admin.auth.getToken({
email: 'user@example.com',
password: 'supersecret'
})
.then(({ access_token }) => {
console.log(access_token);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminPostAuthReq](../../medusa/classes/medusa.AdminPostAuthReq.mdx)",
"description": "The credentials of the user.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "email",
"type": "`string`",
"description": "The user's email.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "password",
"type": "`string`",
"description": "The user's password.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminBearerAuthRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the access token of the user, if they're authenticated successfully.",
"expandable": false,
"children": [
{
"name": "access_token",
"type": "`string`",
"description": "Access token that can be used to send authenticated requests.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
@@ -0,0 +1,365 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminCurrenciesResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminCurrenciesResource
This class is used to send requests to [Admin Currency API Routes](https://docs.medusajs.com/api/admin#currencies). All its method
are available in the JS Client under the `medusa.admin.currencies` property.
All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession).
A store can use unlimited currencies, and each region must be associated with at least one currency.
Currencies are defined within the Medusa backend. The methods in this class allow admins to list and update currencies.
Related Guide: [How to manage currencies](https://docs.medusajs.com/modules/regions-and-currencies/admin/manage-currencies).
## Methods
### list
Retrieve a list of currencies. The currencies can be filtered by fields such as `code`. The currencies can also be sorted or paginated.
#### Example
To list currencies:
```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.currencies.list()
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```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.currencies.list({
limit,
offset
})
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[AdminGetCurrenciesParams](../../medusa/classes/medusa.AdminGetCurrenciesParams.mdx)",
"description": "Filters and pagination configurations to apply on retrieved currencies.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "code",
"type": "`string`",
"description": "Code to filter currencies by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Filter currencies by whether they include tax.",
"optional": true,
"defaultValue": "",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "20",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "`string`",
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.\nBy default, the returned currencies will be sorted by their `created_at` field.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminCurrenciesListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of currencies with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminCurrenciesListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "List of currencies with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currencies",
"type": "[Currency](../../entities/classes/entities.Currency.mdx)[]",
"description": "An array of currency details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "code",
"type": "`string`",
"description": "The 3 character ISO code for the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the currency prices include tax",
"optional": true,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The written name of the currency",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "symbol",
"type": "`string`",
"description": "The symbol used to indicate the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "symbol_native",
"type": "`string`",
"description": "The native symbol used to indicate the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### update
Update a Currency'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.currencies.update(code, {
includes_tax: true
})
.then(({ currency }) => {
console.log(currency.code);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "code",
"type": "`string`",
"description": "The code of the currency to update.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminPostCurrenciesCurrencyReq](../../medusa/classes/medusa.AdminPostCurrenciesCurrencyReq.mdx)",
"description": "The attributes to update in the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Tax included in prices of currency.",
"optional": true,
"defaultValue": "",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminCurrenciesRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the currency's details.",
"expandable": false,
"children": [
{
"name": "currency",
"type": "[Currency](../../entities/classes/entities.Currency.mdx)",
"description": "Currency details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "code",
"type": "`string`",
"description": "The 3 character ISO code for the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the currency prices include tax",
"optional": true,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The written name of the currency",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "symbol",
"type": "`string`",
"description": "The symbol used to indicate the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "symbol_native",
"type": "`string`",
"description": "The native symbol used to indicate the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
@@ -0,0 +1,331 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminCustomResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminCustomResource
This class is used to send requests custom API Routes. All its method
are available in the JS Client under the `medusa.admin.custom` property.
## Methods
### delete
Send a `DELETE` request to a custom API Route. The method accepts a type parameters `TResponse` indicating the type of response, which defaults to `any`.
#### 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.custom.delete(
`/blog/posts/${postId}`
)
.then(() => {
// deleted successfully
})
```
#### Type Parameters
<ParameterTypes parameters={[
{
"name": "TResponse",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Parameters
<ParameterTypes parameters={[
{
"name": "path",
"type": "`string`",
"description": "The path of the custom API Route.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "`RequestOptions`",
"description": "Configurations to apply on the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;TResponse&#62;",
"optional": false,
"defaultValue": "",
"description": "The response data.",
"expandable": false,
"children": [
{
"name": "TResponse",
"type": "`TResponse`",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]
}
]} />
___
### get
Send a `GET` request to a custom API Route. The method accepts a tuple of type parameters: the first `TQuery` is the type of accepted query parameters,
which defaults to `Record<string, any>`; the second `TResponse` is the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
type PostsResponse = {
posts: Post[]
}
// must be previously logged in or use api token
medusa.admin.custom.get<Record<string, any>, PostsResponse>(
"/blog/posts"
)
.then(({ posts }) => {
console.log(posts.length);
})
```
#### Type Parameters
<ParameterTypes parameters={[
{
"name": "TQuery",
"type": "`Record<string, any>`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "TResponse",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Parameters
<ParameterTypes parameters={[
{
"name": "path",
"type": "`string`",
"description": "The path of the custom API Route.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "query",
"type": "`TQuery`",
"description": "Query path parameters to pass in the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "`RequestOptions`",
"description": "Configurations to apply on the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;TResponse&#62;",
"optional": false,
"defaultValue": "",
"description": "The response data.",
"expandable": false,
"children": [
{
"name": "TResponse",
"type": "`TResponse`",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]
}
]} />
___
### post
Send a `POST` request to a custom API Route. The method accepts a tuple of type parameters: the first `TPayload` is the type of accepted body parameters,
which defaults to `Record<string, any>`; the second `TResponse` is the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
type PostRequest = {
title: string
}
type PostResponse = {
post: Post
}
// must be previously logged in or use api token
medusa.admin.custom.post<PostRequest, PostResponse>(
"/blog/posts",
{
title: "My post",
}
)
.then(({ post }) => {
console.log(post.id);
})
```
#### Type Parameters
<ParameterTypes parameters={[
{
"name": "TPayload",
"type": "`Record<string, any>`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "TResponse",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Parameters
<ParameterTypes parameters={[
{
"name": "path",
"type": "`string`",
"description": "The path of the custom API Route.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "`TPayload`",
"description": "Body parameters to pass in the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "`RequestOptions`",
"description": "Configurations to apply on the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;TResponse&#62;",
"optional": false,
"defaultValue": "",
"description": "The response data.",
"expandable": false,
"children": [
{
"name": "TResponse",
"type": "`TResponse`",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]
}
]} />
@@ -0,0 +1,510 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminInvitesResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminInvitesResource
This class is used to send requests to [Admin Invite API Routes](https://docs.medusajs.com/api/admin#invites). All its method
are available in the JS Client under the `medusa.admin.invites` property.
All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession).
An admin can invite new users to manage their team. This would allow new users to authenticate as admins and perform admin functionalities.
Related Guide: [How to manage invites](https://docs.medusajs.com/modules/users/admin/manage-invites).
## Methods
### accept
Accept an Invite. This will also delete the invite and create a new user that can log in and perform admin functionalities.
The user will have the email associated with the invite, and the password provided in the `payload` 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.invites.accept({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret"
}
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminPostInvitesInviteAcceptReq](../../medusa/classes/medusa.AdminPostInvitesInviteAcceptReq.mdx)",
"description": "The user accepting the invite.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "token",
"type": "`string`",
"description": "The token of the invite to accept. This is a unique token generated when the invite was created or resent.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "user",
"type": "[AdminPostInvitesInviteAcceptUserReq](../../medusa/classes/medusa.AdminPostInvitesInviteAcceptUserReq.mdx)",
"description": "The details of the user to create.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "first_name",
"type": "`string`",
"description": "The invite's first name.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "last_name",
"type": "`string`",
"description": "The invite's last name.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "password",
"type": "`string`",
"description": "The invite's password",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "`ResponsePromise`",
"optional": false,
"defaultValue": "",
"description": "Resolves when the invite is accepted successfully.",
"expandable": false,
"children": []
}
]} />
___
### create
Create an invite. This will generate a token associated with the invite and trigger an `invite.created` event. If you have a Notification Provider installed that handles this
event, a notification should be sent to the email associated with the invite to allow them to accept the invite.
#### 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.invites.create({
user: "user@example.com",
role: "admin"
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "`AdminPostInvitesPayload`",
"description": "The invite to be created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "`ResponsePromise`",
"optional": false,
"defaultValue": "",
"description": "Resolves when the invite is created successfully.",
"expandable": false,
"children": []
}
]} />
___
### delete
Delete an invite. Only invites that weren't accepted can be deleted.
#### 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.invites.delete(inviteId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The invite's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;DeleteResponse&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the deletion operation's details.",
"expandable": false,
"children": [
{
"name": "deleted",
"type": "`boolean`",
"description": "Whether the item was deleted successfully.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The ID of the deleted item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "object",
"type": "`string`",
"description": "The type of the deleted item.",
"optional": false,
"defaultValue": "product-collection",
"expandable": false,
"children": []
}
]
}
]} />
___
### list
Retrieve a list of invites.
#### 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.invites.list()
.then(({ invites }) => {
console.log(invites.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminListInvitesRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of invites.",
"expandable": false,
"children": [
{
"name": "invites",
"type": "[Invite](../../entities/classes/entities.Invite.mdx)[]",
"description": "An array of invites",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "accepted",
"type": "`boolean`",
"description": "Whether the invite was accepted or not.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "expires_at",
"type": "`Date`",
"description": "The date the invite expires at.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The invite's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "role",
"type": "[UserRoles](../../entities/enums/entities.UserRoles.mdx)",
"description": "The user's role. These roles don't change the privileges of the user.",
"optional": false,
"defaultValue": "member",
"expandable": false,
"children": [
{
"name": "ADMIN",
"type": "`\"admin\"`",
"description": "The user is an admin.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "DEVELOPER",
"type": "`\"developer\"`",
"description": "The user is a developer.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "MEMBER",
"type": "`\"member\"`",
"description": "The user is a team member.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "token",
"type": "`string`",
"description": "The token used to accept the invite.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "user_email",
"type": "`string`",
"description": "The email of the user being invited.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### resend
Resend an invite. This renews the expiry date by seven days and generates a new token for the invite. It also triggers the `invite.created` event,
so if you have a Notification Provider installed that handles this event, a notification should be sent to the email associated with the
invite to allow them to accept the invite.
#### 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.invites.resend(inviteId)
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The invite's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "`ResponsePromise`",
"optional": false,
"defaultValue": "",
"description": "Resolves when the invite is resent successfully.",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,337 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminProductTagsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminProductTagsResource
This class is used to send requests to [Admin Product Tag API Routes](https://docs.medusajs.com/api/admin#product-tags). All its method
are available in the JS Client under the `medusa.admin.productTags` property.
All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession).
Product tags are string values created when you create or update a product with a new tag.
Products can have more than one tag, and products can share tags. This allows admins to associate products to similar tags that can be used to filter products.
## Methods
### list
Retrieve a list of product tags. The product tags can be filtered by fields such as `q` or `value` passed in the `query` parameter. The product tags can also be sorted or paginated.
#### Example
To list product tags:
```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.productTags.list()
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```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.productTags.list({
limit,
offset
})
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[AdminGetProductTagsParams](../../medusa/classes/medusa.AdminGetProductTagsParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved product tags.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product tags' `created_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "discount_condition_id",
"type": "`string`",
"description": "Filter product tags by their associated discount condition's ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "IDs to filter product tags by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": false,
"defaultValue": "10",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": false,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "`string`",
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "Search term to search product tags' value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product tags' `updated_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "value",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "Values to search product tags by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminProductTagsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of product tags with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminProductTagsListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "The list of product tags with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "product_tags",
"type": "[ProductTag](../../entities/classes/entities.ProductTag.mdx)[]",
"description": "An array of product tag details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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 product tag's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`string`",
"description": "The value that the Product Tag represents",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
@@ -0,0 +1,347 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminProductTypesResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminProductTypesResource
This class is used to send requests to [Admin Product Type API Routes](https://docs.medusajs.com/api/admin#product-types). All its method
are available in the JS Client under the `medusa.admin.productTypes` property.
All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession).
Product types are string values created when you create or update a product with a new type.
Products can have one type, and products can share types. This allows admins to associate products with a type that can be used to filter products.
## Methods
### list
Retrieve a list of product types. The product types can be filtered by fields such as `q` or `value` passed in the `query` parameter.
The product types can also be sorted or paginated.
#### Example
To list product types:
```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.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```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.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[AdminGetProductTypesParams](../../medusa/classes/medusa.AdminGetProductTypesParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved product types.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product types' `created_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "discount_condition_id",
"type": "`string`",
"description": "Filter product types by their associated discount condition's ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "IDs to filter product types by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "20",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "`string`",
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "Search terms to search product types' value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product types' `updated_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "value",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "Values to filter product types by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminProductTypesListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of product types with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminProductTypesListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "The list of product types with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "product_types",
"type": "[ProductType](../../entities/classes/entities.ProductType.mdx)[]",
"description": "An array of product types details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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 product type's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`string`",
"description": "The value that the Product Type represents.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
@@ -0,0 +1,768 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminStockLocationsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminStockLocationsResource
This class is used to send requests to [Admin Stock Location API Routes](https://docs.medusajs.com/api/admin#stock-locations). To use these API Routes, make sure to install the
[@medusajs/stock-location](https://docs.medusajs.com/modules/multiwarehouse/install-modules#stock-location-module) module in your Medusa backend.
All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession). The methods
are available in the JS Client under the `medusa.admin.stockLocations` property.
A stock location, provided by the [Stock Location module](https://docs.medusajs.com/modules/multiwarehouse/stock-location-module), indicates a physical address that stock-kept items, such as physical products, can be stored in.
An admin can create and manage available stock locations.
Related Guide: [How to manage stock locations](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-stock-locations).
## Methods
### create
Create a stock location.
#### 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.stockLocations.create({
name: "Main Warehouse",
})
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminPostStockLocationsReq](../../medusa/classes/medusa.AdminPostStockLocationsReq.mdx)",
"description": "The stock location to be created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "address",
"type": "[StockLocationAddress](../../medusa/classes/medusa.StockLocationAddress.mdx)",
"description": "A new stock location address to create and associate with the stock location. Only required if `address\\_id` is not provided.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "address_1",
"type": "`string`",
"description": "Stock location address",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "address_2",
"type": "`string`",
"description": "Stock location address' complement",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "city",
"type": "`string`",
"description": "Stock location address' city",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "company",
"type": "`string`",
"description": "Stock location address' company",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "country_code",
"type": "`string`",
"description": "The two character ISO code for the country.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "phone",
"type": "`string`",
"description": "Stock location address' phone number",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "postal_code",
"type": "`string`",
"description": "Stock location address' postal code",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "province",
"type": "`string`",
"description": "Stock location address' province",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "address_id",
"type": "`string`",
"description": "the ID of an existing stock location address to associate with the stock location. Only required if `address` is not provided.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "the name of the stock location",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminStockLocationsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the stock location's details.",
"expandable": false,
"children": [
{
"name": "stock_location",
"type": "[StockLocationExpandedDTO](../../medusa/types/medusa.StockLocationExpandedDTO.mdx)",
"description": "Stock location details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channels",
"type": "`any`[]",
"description": "The associated sales channels.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### delete
Delete a stock location.
#### 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.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The stock location's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;[DeleteResponse](../../medusa/types/medusa.DeleteResponse-1.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the deletion operation's details.",
"expandable": false,
"children": [
{
"name": "deleted",
"type": "`boolean`",
"description": "Whether the item was deleted successfully.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The ID of the item that was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "object",
"type": "`string`",
"description": "The type of the item that was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
___
### list
Retrieve a list of stock locations. The stock locations can be filtered by fields such as `name` or `created_at` passed in the `query` parameter.
The stock locations can also be sorted or paginated.
#### Example
To list stock locations:
```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.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
To specify relations that should be retrieved within the stock locations:
```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.stockLocations.list({
expand: "address"
})
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```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.stockLocations.list({
expand: "address",
limit,
offset
})
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[AdminGetStockLocationsParams](../../medusa/classes/medusa.AdminGetStockLocationsParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved stock locations.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "address_id",
"type": "`string` \\| `string`[]",
"description": "Filter stock locations by the ID of their associated addresses.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[]",
"description": "IDs to filter stock locations by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "20",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string` \\| `string`[]",
"description": "Names to filter stock locations by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "sales_channel_id",
"type": "`string` \\| `string`[]",
"description": "Filter stock locations by the ID of their associated sales channels.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminStockLocationsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of stock locations with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminStockLocationsListRes",
"type": "[PaginatedResponse](../../medusa/types/medusa.PaginatedResponse-1.mdx) & `object`",
"description": "The list of stock locations with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "stock_locations",
"type": "[StockLocationExpandedDTO](../../medusa/types/medusa.StockLocationExpandedDTO.mdx)[]",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### retrieve
Retrieve a stock location'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.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "itemId",
"type": "`string`",
"description": "The stock location's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminStockLocationsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the stock location's details.",
"expandable": false,
"children": [
{
"name": "stock_location",
"type": "[StockLocationExpandedDTO](../../medusa/types/medusa.StockLocationExpandedDTO.mdx)",
"description": "Stock location details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channels",
"type": "`any`[]",
"description": "The associated sales channels.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### update
Update a stock location'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.stockLocations.update(stockLocationId, {
name: 'Main Warehouse'
})
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "stockLocationId",
"type": "`string`",
"description": "The stock location's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminPostStockLocationsLocationReq](../../medusa/classes/medusa.AdminPostStockLocationsLocationReq.mdx)",
"description": "The attributes to be updated in the stock location.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "address",
"type": "[StockLocationAddress](../../medusa/classes/medusa.StockLocationAddress-1.mdx)",
"description": "The data of an associated address to create or update.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "address_1",
"type": "`string`",
"description": "First line address.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "address_2",
"type": "`string`",
"description": "Second line address.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "city",
"type": "`string`",
"description": "City.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "company",
"type": "`string`",
"description": "Company.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "country_code",
"type": "`string`",
"description": "Country code.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "phone",
"type": "`string`",
"description": "Phone.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "postal_code",
"type": "`string`",
"description": "Postal code.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "province",
"type": "`string`",
"description": "Province.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "address_id",
"type": "`string`",
"description": "the stock location address ID",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "the name of the stock location",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminStockLocationsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the stock location's details.",
"expandable": false,
"children": [
{
"name": "stock_location",
"type": "[StockLocationExpandedDTO](../../medusa/types/medusa.StockLocationExpandedDTO.mdx)",
"description": "Stock location details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channels",
"type": "`any`[]",
"description": "The associated sales channels.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
@@ -0,0 +1,371 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminUploadsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminUploadsResource
This class is used to send requests to [Admin Upload API Routes](https://docs.medusajs.com/api/admin#uploads). All its method
are available in the JS Client under the `medusa.admin.uploads` property.
All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession).
The methods in this class are used to upload any type of resources. For example, they can be used to upload CSV files that are used to import products into the store.
Related Guide: [How to upload CSV file when importing a product](https://docs.medusajs.com/modules/products/admin/import-products#1-upload-csv-file).
## Methods
### \_createPayload
#### Parameters
<ParameterTypes parameters={[
{
"name": "file",
"type": "`AdminCreateUploadPayload`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "FormData",
"type": "`FormData`",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### create
Upload a file to a public bucket or storage. The file upload is handled by the file service installed on the Medusa backend.
#### 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.uploads.create(file)
.then(({ uploads }) => {
console.log(uploads.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "file",
"type": "`AdminCreateUploadPayload`",
"description": "The file to upload.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminUploadsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the uploaded file details.",
"expandable": false,
"children": [
{
"name": "uploads",
"type": "[FileServiceUploadResult](../../medusa/types/medusa.FileServiceUploadResult.mdx)[]",
"description": "Uploaded files details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "key",
"type": "`string`",
"description": "The key of the file that is identifiable by the file service. It can be used later to retrieve or manipulate the file.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "url",
"type": "`string`",
"description": "The URL of the uploaded file.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### createProtected
Upload a file to an ACL or a non-public bucket. The file upload is handled by the file service installed on the Medusa backend.
#### 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.uploads.createProtected(file)
.then(({ uploads }) => {
console.log(uploads.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "file",
"type": "`AdminCreateUploadPayload`",
"description": "The file to upload.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminUploadsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the uploaded file details.",
"expandable": false,
"children": [
{
"name": "uploads",
"type": "[FileServiceUploadResult](../../medusa/types/medusa.FileServiceUploadResult.mdx)[]",
"description": "Uploaded files details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "key",
"type": "`string`",
"description": "The key of the file that is identifiable by the file service. It can be used later to retrieve or manipulate the file.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "url",
"type": "`string`",
"description": "The URL of the uploaded file.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### delete
Delete an uploaded file from storage. The file is deleted using the installed file service on the Medusa backend.
#### 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.uploads.delete({
file_key
})
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminDeleteUploadsReq](../../medusa/classes/medusa.AdminDeleteUploadsReq.mdx)",
"description": "The uploaded file to delete.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "file_key",
"type": "`string`",
"description": "key of the file to delete. This is obtained when you first uploaded the file, or by the file service if you used it directly.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;DeleteResponse&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the deletion operation's details.",
"expandable": false,
"children": [
{
"name": "deleted",
"type": "`boolean`",
"description": "Whether the item was deleted successfully.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The ID of the deleted item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "object",
"type": "`string`",
"description": "The type of the deleted item.",
"optional": false,
"defaultValue": "product-collection",
"expandable": false,
"children": []
}
]
}
]} />
___
### getPresignedDownloadUrl
Create and retrieve a presigned or public download URL for a file. The URL creation is handled by the file service installed on the Medusa backend.
#### 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.uploads.getPresignedDownloadUrl({
file_key
})
.then(({ download_url }) => {
console.log(download_url);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminPostUploadsDownloadUrlReq](../../medusa/classes/medusa.AdminPostUploadsDownloadUrlReq.mdx)",
"description": "The uploaded file to get a presigned download URL for.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "file_key",
"type": "`string`",
"description": "key of the file to obtain the download link for. This is obtained when you first uploaded the file, or by the file service if you used it directly.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminUploadsDownloadUrlRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the download URL details.",
"expandable": false,
"children": [
{
"name": "download_url",
"type": "`string`",
"description": "The Download URL of the file",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
@@ -0,0 +1,491 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminVariantsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminVariantsResource
This class is used to send requests to [Admin Product Variant API Routes](https://docs.medusajs.com/api/admin#product-variants). All its method
are available in the JS Client under the `medusa.admin.variants` property.
All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession).
Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product.
Product variants can be managed through [AdminProductsResource](js_client.AdminProductsResource.mdx).
Related Guide: [How to manage product variants](https://docs.medusajs.com/modules/products/admin/manage-products#manage-product-variants).
## Methods
### getInventory
Retrieve the available inventory of a product variant.
#### 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.variants.getInventory(variantId)
.then(({ variant }) => {
console.log(variant.inventory, variant.sales_channel_availability)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "variantId",
"type": "`string`",
"description": "The product variant's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminGetVariantsVariantInventoryRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the inventory details of the product variant.",
"expandable": false,
"children": [
{
"name": "variant",
"type": "[VariantInventory](../../medusa/types/medusa.VariantInventory.mdx)",
"description": "The product variant's inventory details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "id",
"type": "`string`",
"description": "the ID of the variant",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "inventory",
"type": "[ResponseInventoryItem](../../medusa/types/medusa.ResponseInventoryItem.mdx)[]",
"description": "The inventory details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "sales_channel_availability",
"type": "`object`[]",
"description": "Details about the variant's inventory availability in sales channels.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "available_quantity",
"type": "`number`",
"description": "Available quantity in the sales channel",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "channel_id",
"type": "`string`",
"description": "Sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "channel_name",
"type": "`string`",
"description": "Sales channel's name",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### list
Retrieve a list of product variants. The product variant can be filtered by fields such as `id` or `title` passed in the `query` parameter. The product variant can also be paginated.
#### Example
To list product variants:
```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.variants.list()
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
To specify relations that should be retrieved within the product variants:
```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.variants.list({
expand: "options"
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```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.variants.list({
expand: "options",
limit,
offset
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[AdminGetVariantsParams](../../medusa/classes/medusa.AdminGetVariantsParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved product variants.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "cart_id",
"type": "`string`",
"description": "Retrieve prices for a cart ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "Retrieve prices for a currency code.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customer_id",
"type": "`string`",
"description": "Retrieve prices for a customer ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[]",
"description": "IDs to filter product variants by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "inventory_quantity",
"type": "`number` \\| [NumericalComparisonOperator](../../medusa/classes/medusa.NumericalComparisonOperator.mdx)",
"description": "Number filters to apply on product variants' `inventory_quantity` field.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "20",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "Search term to search product variants' IDs.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "Retrieve prices for a region ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "title",
"type": "`string` \\| `string`[]",
"description": "Titles to filter product variants by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminVariantsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of product variants with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminVariantsListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "The list of variants with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "variants",
"type": "[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)[]",
"description": "An array of product variant details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### retrieve
Retrieve a product variant's details.
#### Example
A simple example that retrieves a product variant by its ID:
```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.variants.retrieve(variantId)
.then(({ variant }) => {
console.log(variant.id);
})
```
To specify relations that should be retrieved:
```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.variants.retrieve(variantId, {
expand: "options"
})
.then(({ variant }) => {
console.log(variant.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The product variant's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "query",
"type": "[AdminGetVariantParams](../../medusa/classes/medusa.AdminGetVariantParams.mdx)",
"description": "Configurations to apply on the retrieved product variant.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;AdminVariantsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the product variant's details.",
"expandable": false,
"children": [
{
"name": "variant",
"type": "[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)",
"description": "Product variant's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,779 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/CollectionsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# CollectionsResource
This class is used to send requests to [Store Product Collection API Routes](https://docs.medusajs.com/api/store#product-collections). All its method
are available in the JS Client under the `medusa.collections` property.
A product collection is used to organize products for different purposes such as marketing or discount purposes. For example, you can create a Summer Collection.
Using the methods in this class, you can list or retrieve a collection's details and products.
## Methods
### list
Retrieve a list of product collections. The product collections can be filtered by fields such as `handle` or `created_at` passed in the `query` parameter.
The product collections can also be paginated.
#### Example
To list product collections:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.list()
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.list({
limit,
offset
})
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[StoreGetCollectionsParams](../../medusa/classes/medusa.StoreGetCollectionsParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved product collections.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product collections' `created_at` date",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "handle",
"type": "`string`[]",
"description": "Handles to filter product collections by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "10",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product collections' `updated_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreCollectionsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of product collections with pagination fields.",
"expandable": false,
"children": [
{
"name": "StoreCollectionsListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "The list of product collections with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "collections",
"type": "[ProductCollection](../../entities/classes/entities.ProductCollection.mdx)[]",
"description": "An array of product collections details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "handle",
"type": "`string`",
"description": "A unique string that identifies the Product Collection - can for example be used in slug structures.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The product collection's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "products",
"type": "[Product](../../entities/classes/entities.Product.mdx)[]",
"description": "The details of the products that belong to this product collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "title",
"type": "`string`",
"description": "The title that the Product Collection is identified by.",
"optional": false,
"defaultValue": "",
"expandable": false,
"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 product collection's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.retrieve(collectionId)
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the product collection.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreCollectionsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the collection's details.",
"expandable": false,
"children": [
{
"name": "collection",
"type": "[ProductCollection](../../entities/classes/entities.ProductCollection.mdx)",
"description": "Product collection details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "handle",
"type": "`string`",
"description": "A unique string that identifies the Product Collection - can for example be used in slug structures.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The product collection's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "products",
"type": "[Product](../../entities/classes/entities.Product.mdx)[]",
"description": "The details of the products that belong to this product collection.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "categories",
"type": "[ProductCategory](../../entities/classes/entities.ProductCategory.mdx)[]",
"description": "The details of the product categories that this product belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"featureFlag": "product_categories",
"children": []
},
{
"name": "collection",
"type": "[ProductCollection](../../entities/classes/entities.ProductCollection.mdx)",
"description": "The details of the product collection that the product belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "collection_id",
"type": "`null` \\| `string`",
"description": "The ID of the product collection that the product belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "description",
"type": "`null` \\| `string`",
"description": "A short description of the Product.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discountable",
"type": "`boolean`",
"description": "Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to `false`.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "external_id",
"type": "`null` \\| `string`",
"description": "The external ID of the product",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "handle",
"type": "`null` \\| `string`",
"description": "A unique identifier for the Product (e.g. for slug structure).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "height",
"type": "`null` \\| `number`",
"description": "The height of the Product Variant. May be used in shipping rate calculations.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "hs_code",
"type": "`null` \\| `string`",
"description": "The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The product's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "images",
"type": "[Image](../../entities/classes/entities.Image.mdx)[]",
"description": "The details of the product's images.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "is_giftcard",
"type": "`boolean`",
"description": "Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "length",
"type": "`null` \\| `number`",
"description": "The length of the Product Variant. May be used in shipping rate calculations.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "material",
"type": "`null` \\| `string`",
"description": "The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "mid_code",
"type": "`null` \\| `string`",
"description": "The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "[ProductOption](../../entities/classes/entities.ProductOption.mdx)[]",
"description": "The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "origin_country",
"type": "`null` \\| `string`",
"description": "The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "profile",
"type": "[ShippingProfile](../../entities/classes/entities.ShippingProfile.mdx)",
"description": "The details of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "profile_id",
"type": "`string`",
"description": "The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "profiles",
"type": "[ShippingProfile](../../entities/classes/entities.ShippingProfile.mdx)[]",
"description": "Available if the relation `profiles` is expanded.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "sales_channels",
"type": "[SalesChannel](../../entities/classes/entities.SalesChannel.mdx)[]",
"description": "The details of the sales channels this product is available in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "status",
"type": "[ProductStatus](../../entities/enums/entities.ProductStatus.mdx)",
"description": "The status of the product",
"optional": false,
"defaultValue": "draft",
"expandable": false,
"children": []
},
{
"name": "subtitle",
"type": "`null` \\| `string`",
"description": "An optional subtitle that can be used to further specify the Product.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tags",
"type": "[ProductTag](../../entities/classes/entities.ProductTag.mdx)[]",
"description": "The details of the product tags used in this product.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "thumbnail",
"type": "`null` \\| `string`",
"description": "A URL to an image file that can be used to identify the Product.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "title",
"type": "`string`",
"description": "A title that can be displayed for easy identification of the Product.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "type",
"type": "[ProductType](../../entities/classes/entities.ProductType.mdx)",
"description": "The details of the product type that the product belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "type_id",
"type": "`null` \\| `string`",
"description": "The ID of the product type that the product belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "variants",
"type": "[ProductVariant](../../entities/classes/entities.ProductVariant.mdx)[]",
"description": "The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "weight",
"type": "`null` \\| `number`",
"description": "The weight of the Product Variant. May be used in shipping rate calculations.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "width",
"type": "`null` \\| `number`",
"description": "The width of the Product Variant. May be used in shipping rate calculations.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "title",
"type": "`string`",
"description": "The title that the Product Collection is identified by.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,903 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/GiftCardsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# GiftCardsResource
This class is used to send requests to [Store Gift Card API Routes](https://docs.medusajs.com/api/store#gift-cards). All its method
are available in the JS Client under the `medusa.giftCards` property.
Customers can use gift cards during checkout to deduct the gift card's balance from the checkout total.
The methods in this class allow retrieving a gift card's details by its code. A gift card can be applied to a cart using [CartsResource](js_client.CartsResource.mdx).
Related Guide: [How to use gift cards in a storefront](https://docs.medusajs.com/modules/gift-cards/storefront/use-gift-cards).
## Methods
### retrieve
Retrieve a Gift Card's details by its associated unique code.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.giftCards.retrieve(code)
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "code",
"type": "`string`",
"description": "The code of the gift card.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreGiftCardsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the details of the gift card.",
"expandable": false,
"children": [
{
"name": "gift_card",
"type": "[GiftCard](../../entities/classes/entities.GiftCard.mdx)",
"description": "Gift card details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "balance",
"type": "`number`",
"description": "The remaining value on the Gift Card.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "code",
"type": "`string`",
"description": "The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "ends_at",
"type": "`Date`",
"description": "The time at which the Gift Card can no longer be used.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The gift card's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "[Order](../../entities/classes/entities.Order.mdx)",
"description": "The details of the order that the gift card was purchased in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "billing_address",
"type": "[Address](../../entities/classes/entities.Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "billing_address_id",
"type": "`string`",
"description": "The ID of the billing address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "canceled_at",
"type": "`Date`",
"description": "The date the order was canceled on.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cart",
"type": "[Cart](../../entities/classes/entities.Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "cart_id",
"type": "`string`",
"description": "The ID of the cart associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "claims",
"type": "[ClaimOrder](../../entities/classes/entities.ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../../entities/classes/entities.Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The 3 character currency code that is used in the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customer",
"type": "[Customer](../../entities/classes/entities.Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "customer_id",
"type": "`string`",
"description": "The ID of the customer associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discount_total",
"type": "`number`",
"description": "The total of discount rounded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discounts",
"type": "[Discount](../../entities/classes/entities.Discount.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "display_id",
"type": "`number`",
"description": "The order's display ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draft_order",
"type": "[DraftOrder](../../entities/classes/entities.DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "draft_order_id",
"type": "`string`",
"description": "The ID of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "edits",
"type": "[OrderEdit](../../entities/classes/entities.OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "email",
"type": "`string`",
"description": "The email associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "external_id",
"type": "`null` \\| `string`",
"description": "The ID of an external order.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillment_status",
"type": "[FulfillmentStatus](../../entities/enums/entities.FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
"expandable": false,
"children": []
},
{
"name": "fulfillments",
"type": "[Fulfillment](../../entities/classes/entities.Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_card_tax_total",
"type": "`number`",
"description": "The total of gift cards with taxes",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_total",
"type": "`number`",
"description": "The total of gift cards",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_transactions",
"type": "[GiftCardTransaction](../../entities/classes/entities.GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_cards",
"type": "[GiftCard](../../entities/classes/entities.GiftCard.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The order's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "idempotency_key",
"type": "`string`",
"description": "Randomly generated key used to continue the processing of the order in case of failure.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "item_tax_total",
"type": "`null` \\| `number`",
"description": "The tax total applied on items",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "items",
"type": "[LineItem](../../entities/classes/entities.LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "no_notification",
"type": "`boolean`",
"description": "Flag for describing whether or not notifications related to this should be send.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "object",
"type": "`\"order\"`",
"description": "",
"optional": false,
"defaultValue": "\"order\"",
"expandable": false,
"children": []
},
{
"name": "paid_total",
"type": "`number`",
"description": "The total amount paid",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_status",
"type": "[PaymentStatus](../../entities/enums/entities.PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
"expandable": false,
"children": []
},
{
"name": "payments",
"type": "[Payment](../../entities/classes/entities.Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "raw_discount_total",
"type": "`number`",
"description": "The total of discount",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refundable_amount",
"type": "`number`",
"description": "The amount that can be refunded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunded_total",
"type": "`number`",
"description": "The total amount refunded if the order is returned.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunds",
"type": "[Refund](../../entities/classes/entities.Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region",
"type": "[Region](../../entities/classes/entities.Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "returnable_items",
"type": "[LineItem](../../entities/classes/entities.LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "returns",
"type": "[Return](../../entities/classes/entities.Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel",
"type": "[SalesChannel](../../entities/classes/entities.SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel_id",
"type": "`null` \\| `string`",
"description": "The ID of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_address",
"type": "[Address](../../entities/classes/entities.Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_address_id",
"type": "`string`",
"description": "The ID of the shipping address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_methods",
"type": "[ShippingMethod](../../entities/classes/entities.ShippingMethod.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_tax_total",
"type": "`null` \\| `number`",
"description": "The tax total applied on shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_total",
"type": "`number`",
"description": "The total of shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[OrderStatus](../../entities/enums/entities.OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
"expandable": false,
"children": []
},
{
"name": "subtotal",
"type": "`number`",
"description": "The subtotal of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "swaps",
"type": "[Swap](../../entities/classes/entities.Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_rate",
"type": "`null` \\| `number`",
"description": "The order's tax rate",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_total",
"type": "`null` \\| `number`",
"description": "The total of tax",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "total",
"type": "`number`",
"description": "The total amount of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "order_id",
"type": "`string`",
"description": "The ID of the order that the gift card was purchased in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region",
"type": "[Region](../../entities/classes/entities.Region.mdx)",
"description": "The details of the region this gift card is available in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "automatic_taxes",
"type": "`boolean`",
"description": "Whether taxes should be automated in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "countries",
"type": "[Country](../../entities/classes/entities.Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../../entities/classes/entities.Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The three character currency code used in the region.",
"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": "fulfillment_providers",
"type": "[FulfillmentProvider](../../entities/classes/entities.FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_cards_taxable",
"type": "`boolean`",
"description": "Whether the gift cards are taxable or not in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The region's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the prices for the region include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_providers",
"type": "[PaymentProvider](../../entities/classes/entities.PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_code",
"type": "`string`",
"description": "The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_provider",
"type": "[TaxProvider](../../entities/classes/entities.TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_provider_id",
"type": "`null` \\| `string`",
"description": "The ID of the tax provider used in this region",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rate",
"type": "`number`",
"description": "The tax rate that should be charged on purchases in the Region.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rates",
"type": "`null` \\| [TaxRate](../../entities/classes/entities.TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"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": []
}
]
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this gift card is available in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rate",
"type": "`null` \\| `number`",
"description": "The gift card's tax rate that will be applied on calculating totals",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`number`",
"description": "The value that the Gift Card represents.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,89 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/PaymentMethodsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# PaymentMethodsResource
This class is used to send requests to Payment Method API Routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\_postcustomers). All its method
are available in the JS Client under the `medusa.customers.paymentMethods` property.
All methods in this class require [customer authentication](js_client.AuthResource.mdx#authenticate).
## Methods
### list
Retrieve the logged-in customer's saved payment methods. This method only works with payment providers created with the deprecated Payment Service interface.
The payment methods are saved using the Payment Service's third-party service, and not on the Medusa backend. So, they're retrieved from the third-party service.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.paymentMethods.list()
.then(({ payment_methods }) => {
console.log(payment_methods.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreCustomersListPaymentMethodsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the customer's payment methods.",
"expandable": false,
"children": [
{
"name": "payment_methods",
"type": "`object`[]",
"description": "The details of the saved payment methods.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "data",
"type": "`object`",
"description": "The data needed for the Payment Provider to use the saved payment method.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "provider_id",
"type": "`string`",
"description": "The ID of the Payment Provider where the payment method is saved.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
@@ -0,0 +1,342 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/ProductTagsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ProductTagsResource
This class is used to send requests to [Store Product Tag API Routes](https://docs.medusajs.com/api/store#product-tags). All its method
are available in the JS Client under the `medusa.productTags` property.
Product tags are string values that can be used to filter products by.
Products can have more than one tag, and products can share tags.
## Methods
### list
Retrieve a list of product tags. The product tags can be filtered by fields such as `id` or `q` passed in the `query` parameter. The product tags can also be sorted or paginated.
#### Example
To list product tags:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productTags.list()
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productTags.list({
limit,
offset
})
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[StoreGetProductTagsParams](../../medusa/classes/medusa.StoreGetProductTagsParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved product tags.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply to the product tags' `created_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "discount_condition_id",
"type": "`string`",
"description": "Filter product tags by the ID of their associated discount condition.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "IDs to filter product tags by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "20",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "`string`",
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "Search term to search product tags' values.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply to the product tags' `updated_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "value",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "Values to filter product tags by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreProductTagsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of product tags with pagination fields.",
"expandable": false,
"children": [
{
"name": "StoreProductTagsListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "The list of product tags with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "product_tags",
"type": "[ProductTag](../../entities/classes/entities.ProductTag.mdx)[]",
"description": "An array of product tags details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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 product tag's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`string`",
"description": "The value that the Product Tag represents",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
@@ -0,0 +1,344 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/ProductTypesResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ProductTypesResource
This class is used to send requests to [Store Product Type API Routes](https://docs.medusajs.com/api/store#product-types). All its method
are available in the JS Client under the `medusa.productTypes` property.
Product types are string values that can be used to filter products by.
Products can have more than one tag, and products can share types.
## Methods
### list
Retrieve a list of product types. The product types can be filtered by fields such as `value` or `q` passed in the `query` parameter. The product types can also be sorted or paginated.
#### Example
To list product types:
```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.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```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.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[StoreGetProductTypesParams](../../medusa/classes/medusa.StoreGetProductTypesParams.mdx)",
"description": "Filters and pagination configurations to apply on retrieved product types.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product types' `created_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "discount_condition_id",
"type": "`string`",
"description": "Filter product types by the ID of their associated discount condition.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "IDs to filter product types by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "20",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "`string`",
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "Search term to search product types' values.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the product types' `updated_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "value",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../../medusa/classes/medusa.StringComparisonOperator.mdx)",
"description": "Values to filter product types by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreProductTypesListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of product types with pagination fields.",
"expandable": false,
"children": [
{
"name": "StoreProductTypesListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "product_types",
"type": "[ProductType](../../entities/classes/entities.ProductType.mdx)[]",
"description": "An array of product types details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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 product type's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`string`",
"description": "The value that the Product Type represents.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
@@ -0,0 +1,294 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/ProductVariantsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ProductVariantsResource
This class is used to send requests to [Store Product Variant API Routes](https://docs.medusajs.com/api/store#product-variants). All its method
are available in the JS Client under the `medusa.product.variants` property.
Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product.
## Methods
### list
Retrieves a list of product variants. The product variants can be filtered by fields such as `id` or `title` passed in the `query` parameter. The product variants can also be paginated.
For accurate and correct pricing of the product variants based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only variants of products available in the specified sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
To list product variants:
```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.product.variants.list()
.then(({ variants }) => {
console.log(variants.length);
})
```
To specify relations that should be retrieved within the product variants:
```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.product.variants.list({
expand: "product"
})
.then(({ variants }) => {
console.log(variants.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```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.product.variants.list({
expand: "product",
limit,
offset
})
.then(({ variants }) => {
console.log(variants.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[StoreGetVariantsParams](../../medusa/classes/medusa.StoreGetVariantsParams.mdx)",
"description": "Filters and pagination configurations applied on the retrieved product variants.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "cart_id",
"type": "`string`",
"description": "Retrieve prices for a cart ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "Retrieve prices for a currency code.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[]",
"description": "IDs to filter product variants by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "ids",
"type": "`string`",
"description": "ID to filter the product variants by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "inventory_quantity",
"type": "`number` \\| [NumericalComparisonOperator](../../medusa/classes/medusa.NumericalComparisonOperator.mdx)",
"description": "Number filters to apply on the product variants' `inventory_quantity` field.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "100",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "Retrieve prices for a region ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "sales_channel_id",
"type": "`string`",
"description": "Filter product variants by the ID of their associated sales channel.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "title",
"type": "`string` \\| `string`[]",
"description": "Titles to filter product variants by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreVariantsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of product variants.",
"expandable": false,
"children": [
{
"name": "variants",
"type": "[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)[]",
"description": "An array of product variant descriptions.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
___
### retrieve
Retrieve a Product Variant's details. For accurate and correct pricing of the product variant based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only variants of products available in the current sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### 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.product.variants.retrieve(productVariantId)
.then(({ variant }) => {
console.log(variant.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the product variant.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreVariantsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the product variant's details.",
"expandable": false,
"children": [
{
"name": "variant",
"type": "[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)",
"description": "Product variant description.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
@@ -0,0 +1,636 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/ProductsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ProductsResource
This class is used to send requests to [Store Product API Routes](https://docs.medusajs.com/api/store#products). All its method
are available in the JS Client under the `medusa.products` property.
Products are saleable items in a store. This also includes [saleable gift cards](https://docs.medusajs.com/modules/gift-cards/storefront/use-gift-cards) in a store.
Using the methods in this class, you can filter products by categories, collections, sales channels, and more.
Related Guide: [How to show products in a storefront](https://docs.medusajs.com/modules/products/storefront/show-products).
## Properties
<ParameterTypes parameters={[
{
"name": "variants",
"type": "[ProductVariantsResource](js_client.ProductVariantsResource.mdx)",
"description": "An instance of [ProductVariantsResource](js_client.ProductVariantsResource.mdx) used to send requests to [Store Product Variant API Routes](https://docs.medusajs.com/api/store#product-variants\\_getvariants).",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
___
## Methods
### list
Retrieves a list of products. The products can be filtered by fields such as `id` or `q` passed in the `query` parameter. The products can also be sorted or paginated.
This method can also be used to retrieve a product by its handle.
For accurate and correct pricing of the products based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only products available in the specified sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
To list products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list()
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
To specify relations that should be retrieved within the products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list({
expand: "variants"
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list({
expand: "variants",
limit,
offset
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[StoreGetProductsParams](../../medusa/classes/medusa.StoreGetProductsParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved products.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "cart_id",
"type": "`string`",
"description": "Retrieve prices for a cart ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "category_id",
"type": "`string`[]",
"description": "Filter products by their associated product category's ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "collection_id",
"type": "`string`[]",
"description": "Filter products by their associated product collection's ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the products' `created_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "currency_code",
"type": "`string`",
"description": "Retrieve prices for a currency code.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`string`",
"description": "Description to filter products by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "handle",
"type": "`string`",
"description": "Handle to filter products by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string` \\| `string`[]",
"description": "IDs to filter products by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "include_category_children",
"type": "`boolean`",
"description": "Whether to include product category children in the response.",
"optional": true,
"defaultValue": "",
"expandable": false,
"featureFlag": "product_categories",
"children": []
},
{
"name": "is_giftcard",
"type": "`boolean`",
"description": "Filter products by whether they're gift cards.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "100",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "`string`",
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "Search term to search products' title, description, variants' title and sku, and collections' title.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "Retrieve prices for a region ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "sales_channel_id",
"type": "`string`[]",
"description": "Filter products by their associated sales channels' ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tags",
"type": "`string`[]",
"description": "Filter products by their associated tags' value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "title",
"type": "`string`",
"description": "Title to filter products by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "type_id",
"type": "`string`[]",
"description": "Filter products by their associated product type's ID.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../../medusa/classes/medusa.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the products' `created_at` date.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreProductsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of products with pagination fields.",
"expandable": false,
"children": [
{
"name": "StoreProductsListRes",
"type": "[PaginatedResponse](../../medusa/interfaces/medusa.PaginatedResponse.mdx) & `object`",
"description": "The list of products with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "products",
"type": "[PricedProduct](../../medusa/types/medusa.PricedProduct.mdx)[]",
"description": "An array of products details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### retrieve
Retrieve a Product's details. For accurate and correct pricing of the product based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only products available in the current sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.retrieve(productId)
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The product's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreProductsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the product's details.",
"expandable": false,
"children": [
{
"name": "product",
"type": "[PricedProduct](../../medusa/types/medusa.PricedProduct.mdx)",
"description": "Product details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "variants",
"type": "[PricedVariant](../../medusa/types/medusa.PricedVariant.mdx)[]",
"description": "The product variants and their prices.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### search
Run a search query on products using the search service installed on the Medusa backend. The searching is handled through the search service, so the returned data's
format depends on the search service you're using.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.search({
q: "Shirt"
})
.then(({ hits }) => {
console.log(hits.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "searchOptions",
"type": "[StorePostSearchReq](../../medusa/classes/medusa.StorePostSearchReq.mdx)",
"description": "Fields to search products.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "filter",
"type": "`unknown`",
"description": "Pass filters based on the search service.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of products returned.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of products to skip when retrieving the products.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "The search query.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StorePostSearchRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of search results. The format of the items depends on the search engine installed on the Medusa backend.",
"expandable": false,
"children": [
{
"name": "StorePostSearchRes",
"type": "`object` & `Record<string, unknown>`",
"description": "The list of search results.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "hits",
"type": "`unknown`[]",
"description": "Array of search results. The format of the items depends on the search engine installed on the Medusa backend.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
@@ -0,0 +1,695 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/RegionsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# RegionsResource
This class is used to send requests to [Store Region API Routes](https://docs.medusajs.com/api/store#regions\_getregions). All its method
are available in the JS Client under the `medusa.regions` property.
Regions are different countries or geographical regions that the commerce store serves customers in.
Customers can choose what region they're in, which can be used to change the prices shown based on the region and its currency.
Related Guide: [How to use regions in a storefront](https://docs.medusajs.com/modules/regions-and-currencies/storefront/use-regions)
## Methods
### list
Retrieve a list of regions. This method is useful to show the customer all available regions to choose from.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.regions.list()
.then(({ regions, count, limit, offset }) => {
console.log(regions.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreRegionsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of regions with pagination fields.",
"expandable": false,
"children": [
{
"name": "StoreRegionsListRes",
"type": "[PaginatedResponse](../../medusa/types/medusa.PaginatedResponse-1.mdx) & `object`",
"description": "The list of regions with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regions",
"type": "[Region](../../entities/classes/entities.Region.mdx)[]",
"description": "An array of regions details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "automatic_taxes",
"type": "`boolean`",
"description": "Whether taxes should be automated in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "countries",
"type": "[Country](../../entities/classes/entities.Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../../entities/classes/entities.Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The three character currency code used in the region.",
"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": "fulfillment_providers",
"type": "[FulfillmentProvider](../../entities/classes/entities.FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_cards_taxable",
"type": "`boolean`",
"description": "Whether the gift cards are taxable or not in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The region's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the prices for the region include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_providers",
"type": "[PaymentProvider](../../entities/classes/entities.PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_code",
"type": "`string`",
"description": "The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_provider",
"type": "[TaxProvider](../../entities/classes/entities.TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_provider_id",
"type": "`null` \\| `string`",
"description": "The ID of the tax provider used in this region",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rate",
"type": "`number`",
"description": "The tax rate that should be charged on purchases in the Region.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rates",
"type": "`null` \\| [TaxRate](../../entities/classes/entities.TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"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 Region's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.regions.retrieve(regionId)
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The region's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreRegionsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the region's details.",
"expandable": false,
"children": [
{
"name": "region",
"type": "[Region](../../entities/classes/entities.Region.mdx)",
"description": "Region details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "automatic_taxes",
"type": "`boolean`",
"description": "Whether taxes should be automated in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "countries",
"type": "[Country](../../entities/classes/entities.Country.mdx)[]",
"description": "The details of the countries included in this region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "display_name",
"type": "`string`",
"description": "The country name appropriate for display.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`number`",
"description": "The country's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "iso_2",
"type": "`string`",
"description": "The 2 character ISO code of the country in lower case",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "iso_3",
"type": "`string`",
"description": "The 2 character ISO code of the country in lower case",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The normalized country name in upper case.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "num_code",
"type": "`number`",
"description": "The numerical ISO code for the country.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region",
"type": "[Region](../../entities/classes/entities.Region.mdx)",
"description": "The details of the region the country is associated with.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`null` \\| `string`",
"description": "The region ID this country is associated with.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../../entities/classes/entities.Currency.mdx)",
"description": "The details of the currency used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "code",
"type": "`string`",
"description": "The 3 character ISO code for the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the currency prices include tax",
"optional": true,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The written name of the currency",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "symbol",
"type": "`string`",
"description": "The symbol used to indicate the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "symbol_native",
"type": "`string`",
"description": "The native symbol used to indicate the currency.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "currency_code",
"type": "`string`",
"description": "The three character currency code used in the region.",
"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": "fulfillment_providers",
"type": "[FulfillmentProvider](../../entities/classes/entities.FulfillmentProvider.mdx)[]",
"description": "The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "id",
"type": "`string`",
"description": "The ID of the fulfillment provider as given by the fulfillment service.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_installed",
"type": "`boolean`",
"description": "Whether the fulfillment service is installed in the current version. If a fulfillment service is no longer installed, the `is\\_installed` attribute is set to `false`.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
}
]
},
{
"name": "gift_cards_taxable",
"type": "`boolean`",
"description": "Whether the gift cards are taxable or not in this region.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The region's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the prices for the region include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_providers",
"type": "[PaymentProvider](../../entities/classes/entities.PaymentProvider.mdx)[]",
"description": "The details of the payment providers that can be used to process payments in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "id",
"type": "`string`",
"description": "The ID of the payment provider as given by the payment service.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_installed",
"type": "`boolean`",
"description": "Whether the payment service is installed in the current version. If a payment service is no longer installed, the `is\\_installed` attribute is set to `false`.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
}
]
},
{
"name": "tax_code",
"type": "`string`",
"description": "The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_provider",
"type": "[TaxProvider](../../entities/classes/entities.TaxProvider.mdx)",
"description": "The details of the tax provider used in the region.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "id",
"type": "`string`",
"description": "The ID of the tax provider as given by the tax service.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_installed",
"type": "`boolean`",
"description": "Whether the tax service is installed in the current version. If a tax service is no longer installed, the `is\\_installed` attribute is set to `false`.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
}
]
},
{
"name": "tax_provider_id",
"type": "`null` \\| `string`",
"description": "The ID of the tax provider used in this region",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rate",
"type": "`number`",
"description": "The tax rate that should be charged on purchases in the Region.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rates",
"type": "`null` \\| [TaxRate](../../entities/classes/entities.TaxRate.mdx)[]",
"description": "The details of the tax rates used in the region, aside from the default rate.",
"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": []
}
]
}
]
}
]} />
@@ -0,0 +1,532 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/ReturnReasonsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ReturnReasonsResource
This class is used to send requests to [Store Return Reason API Routes](https://docs.medusajs.com/api/store#return-reasons). All its method
are available in the JS Client under the `medusa.returnReasons` property.
Return reasons are key-value pairs that are used to specify why an order return is being created.
## Methods
### list
Retrieve a list of Return Reasons. This is useful when implementing a Create Return flow in the storefront.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreReturnReasonsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of return reasons.",
"expandable": false,
"children": [
{
"name": "return_reasons",
"type": "[ReturnReason](../../entities/classes/entities.ReturnReason.mdx)[]",
"description": "An array of return reasons details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "description",
"type": "`string`",
"description": "A description of the Reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The return reason's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "label",
"type": "`string`",
"description": "A text that can be displayed to the Customer as a reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "parent_return_reason",
"type": "`null` \\| [ReturnReason](../../entities/classes/entities.ReturnReason.mdx)",
"description": "The details of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "parent_return_reason_id",
"type": "`null` \\| `string`",
"description": "The ID of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "return_reason_children",
"type": "[ReturnReason](../../entities/classes/entities.ReturnReason.mdx)[]",
"description": "The details of the child reasons.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "description",
"type": "`string`",
"description": "A description of the Reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The return reason's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "label",
"type": "`string`",
"description": "A text that can be displayed to the Customer as a reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "parent_return_reason",
"type": "`null` \\| [ReturnReason](../../entities/classes/entities.ReturnReason.mdx)",
"description": "The details of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "parent_return_reason_id",
"type": "`null` \\| `string`",
"description": "The ID of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "return_reason_children",
"type": "[ReturnReason](../../entities/classes/entities.ReturnReason.mdx)[]",
"description": "The details of the child reasons.",
"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": []
},
{
"name": "value",
"type": "`string`",
"description": "The value to identify the reason by.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`string`",
"description": "The value to identify the reason by.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
___
### retrieve
Retrieve a Return Reason's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returnReasons.retrieve(reasonId)
.then(({ return_reason }) => {
console.log(return_reason.id);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the return reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreReturnReasonsRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the return reason's details.",
"expandable": false,
"children": [
{
"name": "return_reason",
"type": "[ReturnReason](../../entities/classes/entities.ReturnReason.mdx)",
"description": "Return reason details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "description",
"type": "`string`",
"description": "A description of the Reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The return reason's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "label",
"type": "`string`",
"description": "A text that can be displayed to the Customer as a reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "parent_return_reason",
"type": "`null` \\| [ReturnReason](../../entities/classes/entities.ReturnReason.mdx)",
"description": "The details of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "parent_return_reason_id",
"type": "`null` \\| `string`",
"description": "The ID of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "return_reason_children",
"type": "[ReturnReason](../../entities/classes/entities.ReturnReason.mdx)[]",
"description": "The details of the child reasons.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"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": "description",
"type": "`string`",
"description": "A description of the Reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The return reason's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "label",
"type": "`string`",
"description": "A text that can be displayed to the Customer as a reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "parent_return_reason",
"type": "`null` \\| [ReturnReason](../../entities/classes/entities.ReturnReason.mdx)",
"description": "The details of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "parent_return_reason_id",
"type": "`null` \\| `string`",
"description": "The ID of the parent reason.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "return_reason_children",
"type": "[ReturnReason](../../entities/classes/entities.ReturnReason.mdx)[]",
"description": "The details of the child reasons.",
"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": []
},
{
"name": "value",
"type": "`string`",
"description": "The value to identify the reason by.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "value",
"type": "`string`",
"description": "The value to identify the reason by.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]} />
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,171 @@
---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/ShippingOptionsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ShippingOptionsResource
This class is used to send requests to [Store Shipping Option API Routes](https://docs.medusajs.com/api/store#shipping-options). All its method
are available in the JS Client under the `medusa.shippingOptions` property.
A shipping option is used to define the available shipping methods during checkout or when creating a return.
Related Guide: [Shipping Option architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-option).
## Methods
### list
Retrieve a list of shipping options. The shipping options can be filtered using the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.list()
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[StoreGetShippingOptionsParams](../../medusa/classes/medusa.StoreGetShippingOptionsParams.mdx)",
"description": "The filters to apply on the shipping options.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "is_return",
"type": "`string`",
"description": "Filter the shipping options by whether they're return shipping options.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "product_ids",
"type": "`string`",
"description": "Product ID that is used to filter shipping options by whether they can be used to ship that product.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "Filter the shipping options by the ID of their associated region.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreShippingOptionsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of shipping options.",
"expandable": false,
"children": [
{
"name": "shipping_options",
"type": "[PricedShippingOption](../../medusa/types/medusa.PricedShippingOption.mdx)[]",
"description": "An array of shipping options details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
___
### listCartOptions
Retrieve a list of shipping options available for a cart.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.listCartOptions(cartId)
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart_id",
"type": "`string`",
"description": "The cart's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "ResponsePromise&#60;StoreShippingOptionsListRes&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of shipping options.",
"expandable": false,
"children": [
{
"name": "shipping_options",
"type": "[PricedShippingOption](../../medusa/types/medusa.PricedShippingOption.mdx)[]",
"description": "An array of shipping options details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]} />
File diff suppressed because it is too large. Load diff