Files
medusa-store/docs/content/modules/taxes/admin/manage-tax-rates.mdx
Shahed Nasser 94907730d2 docs: refactor to use TypeScript, ESLint, and Tailwind CSS (#4136)
* docs(refactoring): configured eslint and typescript (#3511)

* docs: configured eslint and typescript

* fixed yarn.lock

* docs(refactoring): migrate components directory to typescript (#3517)

* docs: migrate components directory to typescript

* removed vscode settings

* fix following merge

* docs: refactored QueryNote component (#3576)

* docs: refactored first batch of theme components (#3579)

* docs: refactored second batch of theme components (#3580)

* added missing badge styles

* fix after merge

* docs(refactoring): migrated remaining component to TypeScript (#3770)

* docs(refactoring): configured eslint and typescript (#3511)

* docs: configured eslint and typescript

* fixed yarn.lock

* docs(refactoring): migrate components directory to typescript (#3517)

* docs: migrate components directory to typescript

* removed vscode settings

* fix following merge

* docs: refactored QueryNote component (#3576)

* docs: refactored first batch of theme components (#3579)

* docs: refactored second batch of theme components (#3580)

* added missing badge styles

* docs: refactoring second batch of theme components

* fix after merge

* refactored icons and other components

* docs: refactored all components

* docs(refactoring): set up and configured Tailwind Css (#3841)

* docs: added tailwind config

* docs: added more tailwind configurations

* add includes option

* added more tailwind configurations

* fix to configurations

* docs(refactoring): use tailwind css (#4134)

* docs: added tailwind config

* docs: added more tailwind configurations

* add includes option

* added more tailwind configurations

* fix to configurations

* docs(refactoring): refactored all styles to use tailwind css (#4132)

* refactored Badge component to use tailwind css

* refactored Bordered component to use tailwind css

* updated to latest docusaurus

* refactored BorderedIcon component to use tailwind css

* refactored Feedback component to use tailwind css

* refactored icons and footersociallinks to tailwind css

* start refactoring of large card

* refactored large card styling

* refactored until admonitions

* refactored until codeblock

* refactored until Tabs

* refactored Tabs (without testing

* finished refactoring styles to tailwind css

* upgraded to version 2.4.1

* general fixes

* adjusted eslint configurations

* fixed ignore files

* fixes to large card

* fix search styling

* fix npx command

* updated tabs to use isCodeTabs prop

* fixed os tabs

* removed os-tabs class in favor of general styling

* improvements to buttons

* fix for searchbar

* fixed redocly download button

* chore: added eslint code action (#4135)

* small change in commerce modules page
2023-05-19 14:56:48 +03:00

1089 lines
25 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: 'Learn how to manage tax rates of a region using the admin APIs. This includes managing tax rates and their associations with products, product types, or shipping options.'
addHowToData: true
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# How to Manage Tax Rates
In this document, youll learn how to manage tax rates of a region using the admin APIs.
## Overview
Tax rates are created per region. Each region has a default tax rate and code. However, you can create more tax rates for a region that have a different code or specific conditions. For example, you can override the default tax rate for a specific product type, product, or shipping option.
### Scenario
You want to add or use the following admin functionalities:
- Manage tax rates. This includes listing tax rates, and creating, updating, and deleting a tax rate.
- Add or delete a tax rates association with products, product types, or shipping options.
---
## Prerequisites
### Medusa Components
It is assumed that you already have a Medusa backend installed and set up. If not, you can follow the [quickstart guide](../../../development/backend/install.mdx) to get started.
### JS Client
This guide includes code snippets to send requests to your Medusa backend using Medusas JS Client, among other methods.
If you follow the JS Client code blocks, its assumed you already have [Medusas JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
### Medusa React
This guide also includes code snippets to send requests to your Medusa backend using Medusa React, among other methods.
If you follow the Medusa React code blocks, it's assumed you already have [Medusa React installed](../../../medusa-react/overview.md) and have [used MedusaProvider higher in your component tree](../../../medusa-react/overview.md#usage).
### Authenticated Admin User
You must be an authenticated admin user before following along with the steps in the tutorial.
You can learn more about [authenticating as an admin user in the API reference](/api/admin/#section/Authentication).
---
## List Tax Rates
You can list the tax rates by sending a request to the [List Tax Rates endpoint](/api/admin#tag/Tax-Rates/operation/GetTaxRates):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.list()
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminTaxRates } from "medusa-react"
const TaxRates = () => {
const { tax_rates, isLoading } = useAdminTaxRates()
return (
<div>
{isLoading && <span>Loading...</span>}
{tax_rates && !tax_rates.length && (
<span>No Tax Rates</span>
)}
{tax_rates && tax_rates.length > 0 && (
<ul>
{tax_rates.map((tax_rate) => (
<li key={tax_rate.id}>{tax_rate.code}</li>
))}
</ul>
)}
</div>
)
}
export default TaxRates
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/tax-rates`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/tax-rates' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</Tabs>
You can pass to this endpoint filter and search parameters as explained in the [API reference](/api/admin#tag/Tax-Rates/operation/GetTaxRates).
The endpoint returns an array of tax rate objects along with [pagination parameters](/api/admin#section/Pagination).
### Listing Tax Rates for a Region
You can retrieve the tax rate of a region by passing the `region_id` query parameter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.list({
region_id: "reg_123",
})
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminTaxRates } from "medusa-react"
const TaxRates = () => {
const { tax_rates, isLoading } = useAdminTaxRates({
region_id: "reg_123",
})
return (
<div>
{isLoading && <span>Loading...</span>}
{tax_rates && !tax_rates.length && (
<span>No Tax Rates</span>
)}
{tax_rates && tax_rates.length > 0 && (
<ul>
{tax_rates.map((tax_rate) => (
<li key={tax_rate.id}>{tax_rate.code}</li>
))}
</ul>
)}
</div>
)
}
export default TaxRates
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/tax-rates?region_id=reg_123`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/tax-rates?region_id=reg_123' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</Tabs>
In the example above, you pass the regions ID as the value of the `region_id` query parameter.
This query parameter also accepts an array of strings, allowing you to filter the tax rates by more than one region:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.list({
region_id: ["reg_123", "reg_456"],
})
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminTaxRates } from "medusa-react"
const TaxRates = () => {
const { tax_rates, isLoading } = useAdminTaxRates({
region_id: ["reg_123", "reg_456"],
})
return (
<div>
{isLoading && <span>Loading...</span>}
{tax_rates && !tax_rates.length && (
<span>No Tax Rates</span>
)}
{tax_rates && tax_rates.length > 0 && (
<ul>
{tax_rates.map((tax_rate) => (
<li key={tax_rate.id}>{tax_rate.code}</li>
))}
</ul>
)}
</div>
)
}
export default TaxRates
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/tax-rates?region_id[]=reg_123&region_id[]=reg_456`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/tax-rates?region_id[]=reg_123&region_id[]=reg_456' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</Tabs>
---
## Create Tax Rate
You can create a tax rate by sending a request to the [Create Tax Rate endpoint](/api/admin#tag/Tax-Rates/operation/PostTaxRates):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.create({
code: "TEST",
name: "New Tax Rate",
region_id,
rate: 10,
})
.then(({ tax_rate }) => {
console.log(tax_rate.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateTaxRate } from "medusa-react"
const CreateTaxRate = () => {
const createTaxRate = useAdminCreateTaxRate()
// ...
const handleCreate = () => {
createTaxRate.mutate({
code: "TEST",
name: "New Tax Rate",
region_id,
rate: 10,
})
}
// ...
}
export default CreateTaxRate
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/tax-rates`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
code: "TEST",
name: "New Tax Rate",
region_id,
rate: 10,
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/tax-rates' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"code": "TEST",
"name": "New Tax Rate",
"region_id": "<REGION_ID>",
"rate": 10
}'
```
</TabItem>
</Tabs>
This endpoint requires the following body parameters:
- `code`: a string indicating the tax code
- `name`: a string indicating the name of the tax rate
- `region_id`: a string indicating the region this tax rate belongs to
You can optionally pass other parameters, such as `rate`, which is a number that indicates the tax rate. Refer to the [API reference](/api/admin#tag/Tax-Rates/operation/PostTaxRates) for other optional parameters.
:::tip
You can specify here the products, product types, or shipping options that this tax rate is created for as explained in the API reference. In this guide, youll be using other endpoints to add or delete these conditions on a tax rate.
:::
The request returns the created tax rate as an object.
---
## Update Tax Rate
You can update a tax rate by sending a request to the [Update Tax Rate endpoint](/api/admin#tag/Tax-Rates/operation/PostTaxRatesTaxRate):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.update(taxRateId, {
name: "New Tax Rate",
})
.then(({ tax_rate }) => {
console.log(tax_rate.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateTaxRate } from "medusa-react"
const UpdateTaxRate = () => {
const updateTaxRate = useAdminUpdateTaxRate(taxRateId)
// ...
const handleUpdate = () => {
updateTaxRate.mutate({
name: "New Tax Rate",
})
}
// ...
}
export default UpdateTaxRate
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "New Tax Rate",
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "New Tax Rate"
}'
```
</TabItem>
</Tabs>
This endpoint requires the tax rate ID to be passed as a path parameter.
In the request body, you can pass any of the tax rates fields as a parameter. In the example above, you pass the `name` parameter to update the name of the tax rate. Refer to the [API reference](/api/admin#tag/Tax-Rates/operation/PostTaxRatesTaxRate) for other parameters you can pass in the request body.
The request returns the updated tax rate as an object.
---
## Manage Tax Rates Products
This section explains how you can add and remove products from a tax rate.
### Add Product to Tax Rate
You can add a product to a tax rate by sending a request to the [Add Products endpoint](/api/admin#tag/Tax-Rates/operation/PostTaxRatesTaxRateProducts):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.addProducts(taxRateId, {
products: [
productId1,
],
})
.then(({ tax_rate }) => {
console.log(tax_rate.products)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateProductTaxRates } from "medusa-react"
const AddProduct = () => {
const addProduct = useAdminCreateProductTaxRates(taxRateId)
// ...
const handleAdd = () => {
addProduct.mutate({
products: [
productId1,
],
})
}
// ...
}
export default AddProduct
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}/products/batch`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
products: [
productId1,
],
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.products)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>/products/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"products": [
"<PRODUCT_ID>"
]
}'
```
</TabItem>
</Tabs>
This endpoint requires the tax rates ID as a path parameter.
In the request body, the `products` parameter is required. Its an array of strings, each string being the ID of a product to add to the tax rate.
The request returns the updated tax rate as an object. You can access the tax rates products using the `products` property of the tax rate object.
### Remove Product from Tax Rate
You can remove a product from a tax rate by sending a request to the [Delete Products endpoint](/api/admin#tag/Tax-Rates/operation/DeleteTaxRatesTaxRateProducts):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.removeProducts(taxRateId, {
products: [
productId1,
],
})
.then(({ tax_rate }) => {
console.log(tax_rate.products)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteProductTaxRates } from "medusa-react"
const RemoveProduct = () => {
const removeProduct = useAdminDeleteProductTaxRates(taxRateId)
// ...
const handleRemove = () => {
removeProduct.mutate({
products: [
productId1,
],
})
}
// ...
}
export default RemoveProduct
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}/products/batch`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
products: [
productId1,
],
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.products)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>/products/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"products": [
"<PRODUCT_ID>"
]
}'
```
</TabItem>
</Tabs>
This endpoint requires the tax rates ID as a path parameter.
In the request body, the `products` parameter is required. Its an array of strings, each string being the ID of a product to remove from the tax rate.
The request returns the updated tax rate as an object. You can access the tax rates products using the `products` property of the tax rate object.
---
## Manage Tax Rates Product Types
This section explains how you can add and remove product types from a tax rate.
### Add Product Type to Tax Rate
You can add a product type to a tax rate by sending a request to the [Add Product Types endpoint](/api/admin#tag/Tax-Rates/operation/PostTaxRatesTaxRateProductTypes):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.addProductTypes(taxRateId, {
product_types: [
productTypeId,
],
})
.then(({ tax_rate }) => {
console.log(tax_rate.product_types)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import {
useAdminCreateProductTypeTaxRates,
} from "medusa-react"
const AddProductTypes = () => {
const addProductTypes = useAdminCreateProductTypeTaxRates(
taxRateId
)
// ...
const handleAdd = () => {
addProductTypes.mutate({
product_types: [
productTypeId,
],
})
}
// ...
}
export default AddProductTypes
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}/product-types/batch`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
product_types: [
productTypeId,
],
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.product_types)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>/product-types/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"product_types": [
"<PRODUCT_TYPE_ID>"
]
}'
```
</TabItem>
</Tabs>
This endpoint requires the tax rates ID as a path parameter.
In the request body, the `product_types` parameter is required. Its an array of strings, each string being the ID of a product type to add to the tax rate.
The request returns the updated tax rate as an object. You can access the tax rates product types using the `product_types` property of the tax rate object.
### Remove Product Type from Tax Rate
You can remove a product type from a tax rate by sending a request to the [Delete Product Types endpoint](/api/admin#tag/Tax-Rates/operation/DeleteTaxRatesTaxRateProductTypes):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.removeProductTypes(taxRateId, {
product_types: [
productTypeId,
],
})
.then(({ tax_rate }) => {
console.log(tax_rate.product_types)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import {
useAdminDeleteProductTypeTaxRates,
} from "medusa-react"
const RemoveProductTypes = () => {
const removeProductTypes = useAdminDeleteProductTypeTaxRates(
taxRateId
)
// ...
const handleRemove = () => {
removeProductTypes.mutate({
product_types: [
productTypeId,
],
})
}
// ...
}
export default RemoveProductTypes
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}/product-types/batch`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
product_types: [
productTypeId,
],
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>/product-types/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"product_types": [
"<PRODUCT_TYPE_ID>"
]
}'
```
</TabItem>
</Tabs>
This endpoint requires the tax rates ID as a path parameter.
In the request body, the `product_types` parameter is required. Its an array of strings, each string being the ID of a product type to remove from the tax rate.
The request returns the updated tax rate as an object. You can access the tax rates product types using the `product_types` property of the tax rate object.
---
## Manage Tax Rates Shipping Options
This section explains how you can add and remove shipping options from a tax rate.
### Add Shipping Option to Tax Rate
You can add a shipping option to a tax rate by sending a request to the [Add Shipping Option endpoint](/api/admin#tag/Tax-Rates/operation/PostTaxRatesTaxRateShippingOptions):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.addShippingOptions(taxRateId, {
shipping_options: [
shippingOptionId,
],
})
.then(({ tax_rate }) => {
console.log(tax_rate.shipping_options)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateShippingTaxRates } from "medusa-react"
const AddShippingOptions = () => {
const addShippingOption = useAdminCreateShippingTaxRates(
taxRateId
)
// ...
const handleAdd = () => {
addShippingOption.mutate({
shipping_options: [
shippingOptionId,
],
})
}
// ...
}
export default AddShippingOptions
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}/shipping-options/batch`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
shipping_options: [
shippingOptionId,
],
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.shipping_options)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>/shipping-options/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"shipping_options": [
"<SHIPPING_OPTION_ID>"
]
}'
```
</TabItem>
</Tabs>
This endpoint requires the tax rates ID as a path parameter.
In the request body, the `shipping_options` parameter is required. Its an array of strings, each string being the ID of a shipping option to add to the tax rate.
The request returns the updated tax rate as an object. You can access the tax rates shipping options using the `shipping_options` property of the tax rate object.
### Remove Shipping Options from Tax Rate
You can remove a shipping option from a tax rate by sending a request to the [Delete Shipping Options endpoint](/api/admin#tag/Tax-Rates/operation/DeleteTaxRatesTaxRateShippingOptions):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.removeShippingOptions(taxRateId, {
shipping_options: [
shippingOptionId,
],
})
.then(({ tax_rate }) => {
console.log(tax_rate.shipping_options)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteShippingTaxRates } from "medusa-react"
const RemoveShippingOptions = () => {
const removeShippingOptions = useAdminDeleteShippingTaxRates(
taxRateId
)
// ...
const handleRemove = () => {
removeShippingOptions.mutate({
shipping_options: [
shippingOptionId,
],
})
}
// ...
}
export default RemoveShippingOptions
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}/shipping-options/batch`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
shipping_options: [
shippingOptionId,
],
}),
})
.then((response) => response.json())
.then(({ tax_rate }) => {
console.log(tax_rate.shipping_options)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>/shipping-options/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"shipping_options": [
"<SHIPPING_OPTION_ID>"
]
}'
```
</TabItem>
</Tabs>
This endpoint requires the tax rates ID as a path parameter.
In the request body, the `shipping_options` parameter is required. Its an array of strings, each string being the ID of a shipping option to remove from the tax rate.
The request returns the updated tax rate as an object. You can access the tax rates shipping options using the `shipping_options` property of the tax rate object.
---
## Delete Tax Rate
You can delete a tax rate by sending a request to the [Delete Tax Rate endpoint](/api/admin#tag/Tax-Rates/operation/DeleteTaxRatesTaxRate):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.taxRates.delete(taxRateId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteTaxRate } from "medusa-react"
const DeleteTaxRate = () => {
const deleteTaxRate = useAdminDeleteTaxRate(taxRateId)
// ...
const handleDelete = () => {
deleteTaxRate.mutate()
}
// ...
}
export default DeleteTaxRate
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/tax-rates/${taxRateId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/tax-rates/<TAX_RATE_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</Tabs>
This endpoint requires the tax rates ID as a path parameter.
The request returns the following fields:
- `id`: The ID of the deleted tax rate.
- `object`: The type of object that was deleted. In this case, the value will be `tax-rate`.
- `deleted`: A boolean value indicating whether the tax rate was deleted.
---
## See Also
- [How to manage tax settings using admin APIs](./manage-tax-settings.mdx)