Files
medusa-store/www/apps/docs/content/references/js-client/classes/AdminCustomerGroupsResource.mdx
github-actions[bot] cdd42dbdcd chore(docs): Generated References (#5743)
Generated the following references:
- `entities`
- `inventory`
- `js-client`
- `pricing`
- `product`
- `services`
- `stock-location`
- `workflows`

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2023-11-27 18:58:52 +00:00

1641 lines
51 KiB
Plaintext

---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminCustomerGroupsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminCustomerGroupsResource
This class is used to send requests to [Admin Customer Group API Routes](https://docs.medusajs.com/api/admin#customer-groups). All its method
are available in the JS Client under the `medusa.admin.customerGroups` property.
All methods in this class require [user authentication](AdminAuthResource.mdx#createsession).
Customer Groups can be used to organize customers that share similar data or attributes into dedicated groups.
This can be useful for different purposes such as setting a different price for a specific customer group.
Related Guide: [How to manage customer groups](https://docs.medusajs.com/modules/customers/admin/manage-customer-groups).
## Methods
#### addCustomers
Add a list of customers to a customer group.
##### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminPostCustomerGroupsGroupCustomersBatchReq](../internal/classes/internal.AdminPostCustomerGroupsGroupCustomersBatchReq.mdx)",
"description": "The customers to add to the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "customer_ids",
"type": "[CustomerGroupsBatchCustomer](../internal/classes/internal.CustomerGroupsBatchCustomer.mdx)[]",
"description": "The ids of the customers to add",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "id",
"type": "`string`",
"description": "ID of the customer",
"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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminCustomerGroupsRes](../internal/types/internal.AdminCustomerGroupsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the customer group's details.",
"expandable": false,
"children": [
{
"name": "AdminCustomerGroupsRes",
"type": "`object`",
"description": "The customer group's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "customer_group",
"type": "[CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)",
"description": "Customer group 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": "customers",
"type": "[Customer](../internal/classes/internal.Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"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 customer group'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": "name",
"type": "`string`",
"description": "The name of the customer group",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_lists",
"type": "[PriceList](../internal/classes/internal.PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"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": []
}
]
}
]
}
]
}
]} />
___
#### create
Create a customer group.
##### 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.customerGroups
.create({
name: "VIP",
})
.then(({ customer_group }) => {
console.log(customer_group.id)
})
```
##### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminPostCustomerGroupsReq](../internal/classes/internal.AdminPostCustomerGroupsReq.mdx)",
"description": "The data of the customer group to create.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "Metadata of the customer group.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "Name of the customer group",
"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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminCustomerGroupsRes](../internal/types/internal.AdminCustomerGroupsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the customer group's details.",
"expandable": false,
"children": [
{
"name": "AdminCustomerGroupsRes",
"type": "`object`",
"description": "The customer group's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "customer_group",
"type": "[CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)",
"description": "Customer group 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": "customers",
"type": "[Customer](../internal/classes/internal.Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"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 customer group'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": "name",
"type": "`string`",
"description": "The name of the customer group",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_lists",
"type": "[PriceList](../internal/classes/internal.PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
#### delete
Delete a customer group. This doesn't delete the customers associated with the customer group.
##### 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.customerGroups
.delete(customerGroupId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
##### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the customer group.",
"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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[DeleteResponse](../internal/interfaces/internal.DeleteResponse.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the deletion operation 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 customer groups. The customer groups can be filtered by fields such as `name` or `id`. The customer groups can also be sorted or paginated.
##### Example
To list customer groups:
```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.customerGroups
.list()
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length)
})
```
To specify relations that should be retrieved within the customer groups:
```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.customerGroups
.list({
expand: "customers",
})
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.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.customerGroups
.list({
expand: "customers",
limit,
offset,
})
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length)
})
```
##### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[AdminGetCustomerGroupsParams](../internal/classes/internal.AdminGetCustomerGroupsParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved customer groups.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "[DateComparisonOperator](../internal/classes/internal.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the customer groups' `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 customer groups by their associated discount condition's 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": "id",
"type": "`string` \\| `string`[] \\| [StringComparisonOperator](../internal/classes/internal.StringComparisonOperator.mdx)",
"description": "IDs to filter customer groups by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`[]",
"description": "Names to filter customer groups 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": "",
"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 customer groups by their name.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../internal/classes/internal.DateComparisonOperator.mdx)",
"description": "Date filters to apply on the customer groups' `update_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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminCustomerGroupsListRes](../internal/types/internal.AdminCustomerGroupsListRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of customer groups with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminCustomerGroupsListRes",
"type": "[PaginatedResponse](../internal/interfaces/internal.PaginatedResponse.mdx) & ``{ customer_groups: [CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)[] }``",
"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": "customer_groups",
"type": "[CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)[]",
"description": "An array of customer group 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": "customers",
"type": "[Customer](../internal/classes/internal.Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"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 customer group'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": "name",
"type": "`string`",
"description": "The name of the customer group",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_lists",
"type": "[PriceList](../internal/classes/internal.PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"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": []
}
]
}
]
}
]
}
]} />
___
#### listCustomers
Retrieve a list of customers in a customer group. The customers can be filtered by the `q` field. The customers can also be paginated.
##### 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.customerGroups
.listCustomers(customerGroupId)
.then(({ customers }) => {
console.log(customers.length)
})
```
##### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "query",
"type": "[AdminGetCustomersParams](../internal/classes/internal.AdminGetCustomersParams.mdx)",
"description": "Filters and pagination configurations to apply on the retrieved customers.",
"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": "groups",
"type": "`string`[]",
"description": "Filter customers by the customer's customer groups.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "has_account",
"type": "`boolean`",
"description": "Filter customers by whether they have an account.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": false,
"defaultValue": "50",
"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": "q",
"type": "`string`",
"description": "Search term used to search customers' email, first name, last name.",
"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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminCustomersListRes](../internal/types/internal.AdminCustomersListRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of customers with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminCustomersListRes",
"type": "[PaginatedResponse](../internal/interfaces/internal.PaginatedResponse.mdx) & ``{ customers: [Customer](../internal/classes/internal.Customer.mdx)[] }``",
"description": "The list of customers 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": "customers",
"type": "[Customer](../internal/classes/internal.Customer.mdx)[]",
"description": "An array of customer details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "billing_address",
"type": "[Address](../internal/classes/internal.Address.mdx)",
"description": "The details of the billing address associated with the customer.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "billing_address_id",
"type": "`null` \\| `string`",
"description": "The customer's billing address ID",
"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 customer's email",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "first_name",
"type": "`string`",
"description": "The customer's first name",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "groups",
"type": "[CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)[]",
"description": "The customer groups the customer belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "has_account",
"type": "`boolean`",
"description": "Whether the customer has an account or not",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The customer's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "last_name",
"type": "`string`",
"description": "The customer's last name",
"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": "orders",
"type": "[Order](../internal/classes/internal.Order.mdx)[]",
"description": "The details of the orders this customer placed.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "phone",
"type": "`string`",
"description": "The customer's phone number",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_addresses",
"type": "[Address](../internal/classes/internal.Address.mdx)[]",
"description": "The details of the shipping addresses associated with the customer.",
"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": []
}
]
}
]
}
]
}
]} />
___
#### removeCustomers
Remove a list of customers from a customer group. This doesn't delete the customer, only the association between the customer and the customer group.
##### 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.customerGroups
.removeCustomers(customerGroupId, {
customer_ids: [
{
id: customerId,
},
],
})
.then(({ customer_group }) => {
console.log(customer_group.id)
})
```
##### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminDeleteCustomerGroupsGroupCustomerBatchReq](../internal/classes/internal.AdminDeleteCustomerGroupsGroupCustomerBatchReq.mdx)",
"description": "The customers to remove from the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "customer_ids",
"type": "[CustomerGroupsBatchCustomer](../internal/classes/internal.CustomerGroupsBatchCustomer.mdx)[]",
"description": "The ids of the customers to remove",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "id",
"type": "`string`",
"description": "ID of the customer",
"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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminCustomerGroupsRes](../internal/types/internal.AdminCustomerGroupsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the customer group's details.",
"expandable": false,
"children": [
{
"name": "AdminCustomerGroupsRes",
"type": "`object`",
"description": "The customer group's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "customer_group",
"type": "[CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)",
"description": "Customer group 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": "customers",
"type": "[Customer](../internal/classes/internal.Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"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 customer group'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": "name",
"type": "`string`",
"description": "The name of the customer group",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_lists",
"type": "[PriceList](../internal/classes/internal.PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"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 customer group by its ID. You can expand the customer group's relations or select the fields that should be returned.
##### 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.customerGroups
.retrieve(customerGroupId)
.then(({ customer_group }) => {
console.log(customer_group.id)
})
```
##### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "query",
"type": "[AdminGetCustomerGroupsGroupParams](../internal/classes/internal.AdminGetCustomerGroupsGroupParams.mdx)",
"description": "Configurations to apply on the retrieved customer group.",
"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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminCustomerGroupsRes](../internal/types/internal.AdminCustomerGroupsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the customer group's details.",
"expandable": false,
"children": [
{
"name": "AdminCustomerGroupsRes",
"type": "`object`",
"description": "The customer group's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "customer_group",
"type": "[CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)",
"description": "Customer group 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": "customers",
"type": "[Customer](../internal/classes/internal.Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"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 customer group'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": "name",
"type": "`string`",
"description": "The name of the customer group",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_lists",
"type": "[PriceList](../internal/classes/internal.PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
#### update
Update a customer group's details.
##### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The ID of the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminPostCustomerGroupsGroupReq](../internal/classes/internal.AdminPostCustomerGroupsGroupReq.mdx)",
"description": "The attributes to update in the customer group.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "Metadata of the customer group.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "Name of the customer group",
"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": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminCustomerGroupsRes](../internal/types/internal.AdminCustomerGroupsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the customer group's details.",
"expandable": false,
"children": [
{
"name": "AdminCustomerGroupsRes",
"type": "`object`",
"description": "The customer group's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "customer_group",
"type": "[CustomerGroup](../internal/classes/internal.CustomerGroup.mdx)",
"description": "Customer group 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": "customers",
"type": "[Customer](../internal/classes/internal.Customer.mdx)[]",
"description": "The details of the customers that belong to the customer group.",
"optional": false,
"defaultValue": "",
"expandable": true,
"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 customer group'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": "name",
"type": "`string`",
"description": "The name of the customer group",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_lists",
"type": "[PriceList](../internal/classes/internal.PriceList.mdx)[]",
"description": "The price lists that are associated with the customer group.",
"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": []
}
]
}
]
}
]
}
]} />