description: "Learn how to manage claims using the admin REST APIs. This guide includes how to view an order's claims, "
addHowToData: true
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# How to Manage Claims
In this document, you’ll learn how to manage claims using the admin REST APIs.
## Overview
Using Medusa’s claim admin REST APIs, you can manage claims and perform related admin functionalities.
### Scenario
You want to add or use the following admin functionalities:
- View an order’s claims
- Manage claims, including creating, updating, and canceling claims.
- Manage a claim’s fulfillment, including creating a fulfillment, creating a shipment, and canceling a fulfillment.
:::note
You can learn about managing returns part of a claim in the [Manage Returns documentation](./manage-returns.mdx).
:::
---
## Prerequisites
### Medusa Components
It is assumed that you already have a Medusa backend installed and set up. If not, you can follow our [quickstart guide](../../../development/backend/install.mdx) to get started.
### JS Client
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s 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).
---
## View Order’s Claims
To view an order’s claims, you can retrieve the order using the [Get Order endpoint](/api/admin#tag/Orders/operation/GetOrdersOrder) and access the order’s claims:
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "refund",
"claim_items": [
{
"item_id": "<ITEM_ID>",
"quantity": 1
}
]
}'
```
</TabItem>
</Tabs>
This endpoint requires the order ID to be passed as a path parameter.
In the request body, the following parameters are required:
- `type`: a string indicating the type of claim to be created. Its value can either be `replace` or `refund`. If the type is `replace`, you can pass the `additional_items` parameter with an array of new items to send to the customer. If the type is `refund`, you can pass the `refund_amount` parameter if you want to specify a custom refund amount.
- `claim_items`: an array of objects, each object being the item in the order that the claim is being created for. In the object, you must pass the following properties:
- `item_id`: a string indicating the ID of the line item in the order.
- `quantity`: a number indicating the quantity of the claim.
There are other optional parameters that you can pass. You can also pass a return reason for each of the claim items. You can learn about the optional request body parameters in the [API reference](/api/admin#tag/Orders/operation/PostOrdersOrderClaims).
:::note
Learn how to manage return reasons in [this documentation](./manage-returns.mdx#manage-return-reasons).
:::
The request returns the updated order as an object. You can access the order’s claims using the `claims` property of the order object. The value of the `claims` property is an array of claim objects.
---
## Update a Claim
You can update a claim by sending a request to the [Update Claim endpoint](/api/admin#tag/Orders/operation/PostOrdersOrderClaimsClaim):
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"no_notification": true
}'
```
</TabItem>
</Tabs>
This endpoint requires the ID of the order and the claim to be passed as path parameters.
In the request body, you can pass any of the claim’s fields that you want to update as parameters. In the example above, the `no_notification` field is updated.
The request returns the updated order as an object. You can access the order’s claims using the `claims` property of the order object. The value of the `claims` property is an array of claim objects.
---
## Manage a Claim’s Fulfillments
### View Claim’s Fulfillments
Fulfillments are available on a claim object under the `fulfillments` property, which is an array of fulfillment objects.
### Create Fulfillment
You can create a fulfillment for a claim by sending a request to the [Create Claim Fulfillment endpoint](/api/admin#tag/Orders/operation/PostOrdersOrderClaimsClaimFulfillments):
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</Tabs>
This endpoint requires the order and claim IDs as path parameters.
In the request body, you can pass optional parameters such as `metadata` or `no_notification`. These parameters will be used to create the fulfillment. You can learn more about available request body parameters in the [API reference](/api/admin#tag/Orders/operation/PostOrdersOrderClaimsClaimFulfillments).
The request returns the updated order as an object. You can access the order’s claims using the `claims` property of the order object. The value of the `claims` property is an array of claim objects.
### Create a Shipment
You can create a shipment for a claim by sending a request to the [Create Claim Shipment endpoint](/api/admin#tag/Orders/operation/PostOrdersOrderClaimsClaimShipments):
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/shipments' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"fulfillment_id": "<FUL_ID>"
}'
```
</TabItem>
</Tabs>
This endpoint requires the order and claim IDs as path parameters.
In the request body, it’s required to pass the `fulfillment_id` parameter, which is the ID of the fulfillment the shipment is being created for. You can pass other optional parameters, such as an array of tracking numbers. You can learn more in the [API reference](/api/admin#tag/Orders/operation/PostOrdersOrderClaimsClaimShipments).
The request returns the updated order as an object. As mentioned before, a claim’s fulfillments can be accessed using the `fulfillments` property of a claim object. You can access the shipments, known as tracking links, of a fulfillment using the `tracking_links` property of a fulfillment object. The value of `tracking_links` is an array of tracking link objects.
You can alternatively access the tracking numbers using the `tracking_numbers` property of a fulfillment object, which is an array of strings.
You can access the status of a claim’s fulfillment using the `fulfillment_status` property of a claim object.
### Cancel Fulfillment
:::note
You can’t cancel a fulfillment that has a shipment
:::
You can cancel a fulfillment by sending a request to the [Cancel Fulfillment endpoint](/api/admin#tag/Orders/operation/PostOrdersClaimFulfillmentsCancel):
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/fulfillments/<FUL_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</Tabs>
This endpoint requires the order, claim, and fulfillment IDs to be passed as path parameters.
The request returns the updated order as an object. You can access the claims using the `claims` property of the order object, which is an array of claim objects.
You can check the fulfillment status of a claim using the `fulfillment_status` property of the claim object.
---
## Cancel Claim
:::note
You can’t cancel a claim that has been refunded. You must also cancel the claim’s fulfillments and return first.
:::
You can cancel a claim by sending a request to the [Cancel Claim endpoint](/api/admin#tag/Orders/operation/PostOrdersClaimCancel):
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/claims/<CLAIM_ID>/cancel' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</Tabs>
This endpoint requires the order and claim IDs as path parameters.
The request returns the updated order as an object. You can access the claims using the `claims` property of the order object, which is an array of claim objects.
@@ -453,7 +453,7 @@ The request returns the order as an object. In that object, you can access an ar
## View a Swap’s Return
You can retrieve a swap either using the Get Order endpoint as explained here, or using the [List Swaps](/api/admin#tag/Swaps/operation/GetSwaps) or [Get Swap endpoint](/api/admin#tag/Swaps/operation/GetSwapsSwap).
You can retrieve a swap either using the Get Order endpoint as explained [here](./manage-swaps.mdx#view-orders-swaps), or using the [List Swaps](/api/admin#tag/Swaps/operation/GetSwaps) or [Get Swap endpoint](/api/admin#tag/Swaps/operation/GetSwapsSwap).
In a swap object, the swap’s return is available under the `return_order` property.
@@ -461,7 +461,7 @@ In a swap object, the swap’s return is available under the `return_order` prop
## View a Claim’s Return
You can retrieve a claim using the Get Order endpoint and accessing the `claims` property of the order object, which is an array of claim objects. In a claim object, the claim’s return is available under the `return_order` property.
You can retrieve a claim using the Get Order endpoint as explained [here](./manage-claims#view-orders-claims). In a claim object, the claim’s return is available under the `return_order` property.
---
@@ -639,13 +639,14 @@ This endpoint requires the return ID to be passed as a path parameter.
The request returns one of the following object types:
- If a return belongs to a swap, a swap object is returned.
- If a return belongs to a claim, a claim object is returned.
- Otherwise, an order object is returned.
- If a return belongs to a swap, a swap object is returned. You can access the returns in the `return_order` property of the swap object.
- If a return belongs to a claim, a claim object is returned. You can access the returns in the `return_order` property of the claim object.
- Otherwise, an order object is returned. You can access the returns in the `returns` property of the order object.
---
## See Also
- [How to manage orders using the REST APIs](./manage-orders.mdx)
- [How to manage swaps using the REST APIs](./manage-returns.mdx)
- [How to manage swaps using the REST APIs](./manage-swaps.mdx)
- [How to manage claims using the REST APIs](./manage-claims.mdx)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.