--- displayed_sidebar: jsClientSidebar slug: /references/js-client/AdminSwapsResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # AdminSwapsResource This class is used to send requests to [Admin Swap API Routes](https://docs.medusajs.com/api/admin#swaps). All its method are available in the JS Client under the `medusa.admin.swaps` property. All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). A swap is created by a customer or an admin to exchange an item with a new one. Creating a swap implicitely includes creating a return for the item being exchanged. Related Guide: [How to manage swaps](https://docs.medusajs.com/modules/orders/admin/manage-swaps) ## Methods ### list Retrieve a list of swaps. The swaps can be paginated. #### Example To list swaps: ```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.swaps.list().then(({ swaps }) => { console.log(swaps.length) }) ``` By default, only the first `50` 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.swaps .list({ limit, offset, }) .then(({ swaps }) => { console.log(swaps.length) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "no_notification", "type": "`boolean`", "description": "If set to true, no notification will be sent related to this swap", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "order", "type": "[Order](../internal/classes/internal.Order.mdx)", "description": "The details of the order that the swap belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "order_id", "type": "`string`", "description": "The ID of the order that the swap belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "payment", "type": "[Payment](../internal/classes/internal.Payment.mdx)", "description": "The details of the additional payment authorized by the customer when `difference\\_due` is positive.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "payment_status", "type": "[SwapPaymentStatus](../internal/enums/internal.SwapPaymentStatus.mdx)", "description": "The status of the Payment of the Swap. The payment may either refer to the refund of an amount or the authorization of a new amount.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "return_order", "type": "[Return](../internal/classes/internal.Return.mdx)", "description": "The details of the return that belongs to the swap, which holds the details on the items being returned.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "shipping_address", "type": "[Address](../internal/classes/internal.Address.mdx)", "description": "The details of the shipping address that the new items should be sent to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "shipping_address_id", "type": "`string`", "description": "The Address to send the new Line Items to - in most cases this will be the same as the shipping address on the Order.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_methods", "type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]", "description": "The details of the shipping methods used to fulfill the additional items purchased.", "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 swap'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.swaps.retrieve(swapId).then(({ swap }) => { console.log(swap.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "no_notification", "type": "`boolean`", "description": "If set to true, no notification will be sent related to this swap", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "order", "type": "[Order](../internal/classes/internal.Order.mdx)", "description": "The details of the order that the swap belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "order_id", "type": "`string`", "description": "The ID of the order that the swap belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "payment", "type": "[Payment](../internal/classes/internal.Payment.mdx)", "description": "The details of the additional payment authorized by the customer when `difference\\_due` is positive.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "payment_status", "type": "[SwapPaymentStatus](../internal/enums/internal.SwapPaymentStatus.mdx)", "description": "The status of the Payment of the Swap. The payment may either refer to the refund of an amount or the authorization of a new amount.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "return_order", "type": "[Return](../internal/classes/internal.Return.mdx)", "description": "The details of the return that belongs to the swap, which holds the details on the items being returned.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "shipping_address", "type": "[Address](../internal/classes/internal.Address.mdx)", "description": "The details of the shipping address that the new items should be sent to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "shipping_address_id", "type": "`string`", "description": "The Address to send the new Line Items to - in most cases this will be the same as the shipping address on the Order.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_methods", "type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]", "description": "The details of the shipping methods used to fulfill the additional items purchased.", "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": [] } ] } ] } ] } ]} />