Backend API
A return is an action normally requested by a customer to return products purchased from a store. They contain information about returning items that were previously fulfilled, the return shipment details if applicable, and return value to apply to an order, which in turn may prompt an administrator to issue a refund.
Fields
id
objectIdUnique identifier for the return.
order_id
objectIdrequiredID of the order this return was created for.
canceled
booleanIndicates the return was canceled.
carrier
stringID of a third-party carrier offering the service, if applicable.
carrier_name
stringName of a third-party carrier offering the service, if applicable.
credit_tax
currencyautoTotal amount of taxes credited to the order for the returned items.
credit_total
currencyautoTotal amount of additional credit applied to the order.
currency
stringrequiredThree-letter ISO currency code in uppercase. Defaults to the store's base currency.
date_created
dateautoDate and time the return was created.
date_estimated
dateDate the expected return shipment is meant to arrive at a warehouse, if applicable.
date_updated
dateautoDate and time the return was last updated.
destination
objectThe intended return destination.
destination.location
stringID of the intended return destination, if applicable.
extra_credit
currencyrequiredArbitrary amount to apply to the order as compensation for their inconvenience.
item_quantity_receivable
intautoTotal quantity of line items that can still be received in a return shipment.
item_quantity_received
intautoTotal quantity of line items that have been received in a return shipment.
item_quantity_restockable
intautoTotal quantity of line items that can still be restocked to product inventory.
item_quantity_restocked
intautoTotal quantity of line items that have been restocked to product inventory.
notes
stringInternal admin notes, not visible to the customer.
notifications
NotificationExpandable list of notifications sent on behalf of the products returned.
number
stringautoUnique incremental return number, assigned automatically.
order
OrderExpandable link to the order.
origin
objectThe customer's location of origin for the return shipment.
origin.name
stringrequiredOrigin customer name.
origin.country
stringrequiredTwo-letter ISO country code in uppercase.
origin.address1
stringrequiredOrigin address line 1: street address/PO box/company name.
origin.address2
stringOrigin address line 2: apartment/suite/unit/building.
origin.city
stringOrigin city/district/suburb/town/village.
origin.state
stringOrigin state/county/province/region.
origin.zip
stringOrigin zip/postal code.
origin.phone
stringOrigin phone number.
reason_code
stringCode indicating the reason for the return.
received
booleanautoIndicates that all items have been received in a return shipment.
restock_fee
currencyAmount to charge the customer for re-stocking the returned items.
service
stringID of a shipping service as configured in shipment settings.
service_name
stringName of the return shipping service.
shipment_tax
currencyautoAmount to apply to the order as a credit as compensation for the original shipping tax.
shipment_total
currencyAmount to apply to the order as a credit as compensation for the original shipping price.
tracking_code
stringTracking code used to identify the return shipment, if applicable.
The return model
{
"id": "60f199509111e70000000078",
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"order_item_id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"quantity_received": 0,
"quantity_receivable": 2,
"quantity_restocked": 0,
"quantity_restockable": 2
}
],
"order_id": "60f199509111e7000000007a",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.399Z",
"date_updated": "2021-07-16T14:36:00.399Z",
"origin": {
"name": "Jon Snow",
"address1": "1 Main Street",
"city": "Brooklyn",
"state": "NY",
"zip": 11201,
"country": "US",
"phone": "(555) 555-5555"
},
"received": false,
"service": "fedex_ground",
"tracking_code": "T192000000XYZ"
}
Create a new return. If you wish to generate your own unique ID for the record, it must use BSON ObjectID format for compatibility.
Arguments
items
array of objectrequiredList of line items describing the products returned.
order_item_id
objectIdrequiredID of the order item returned.
product_id
objectIdrequiredbundle_item_id
objectIdID of the order bundle item returned, if applicable.
options
array of objectOptions from the order item returned, if applicable.
id
stringUnique identifier for the object.
name
stringName of the product option.
value
stringName value of the product option.
quantity
intQuantity of the item returned. Defaults to 1.
quantity_received
intQuantity of the item received in a return shipment.
quantity_restocked
intQuantity of the item restocked to product inventory.
variant_id
objectIdID of the item variant, if applicable.
id
objectIdautoUnique identifier for the return item.
product
productExpandable link to the item product.
quantity_receivable
intQuantity of the item that can still be received in a return shipment.
quantity_restockable
intQuantity of the item that can still be restocked to product inventory.
variant
variantExpandable link to the item variant, if applicable.
order_id
objectIdrequiredID of the order this return was created for.
notes
stringInternal admin notes, not visible to the customer.
canceled
booleanIndicates the return was canceled.
carrier
stringID of a 3rd party carrier offering the service, if applicable.
carrier_name
stringName of a 3rd party carrier offering the service, if applicable.
currency
stringThree-letter ISO currency code in uppercase. Defaults to the store's base currency.
date_estimated
dateDate the expected return shipment is meant to arrive at a warehouse, if applicable.
destination
objectThe intended return destination.
destination.location
stringID of the intended return destination, if applicable.
extra_credit
currencyArbitrary amount to apply to the order as compensation for their inconvenience.
origin
objectThe customer's location of origin for the return shipment.
origin.address1
stringOrigin address line 1: street address/PO box/company name.
origin.address2
stringOrigin address line 2: apartment/suite/unit/building.
origin.city
stringOrigin city/district/suburb/town/village.
origin.country
stringTwo-letter ISO country code.
origin.name
stringOrigin customer name.
origin.phone
stringOrigin phone number.
origin.state
stringOrigin state/county/province/region.
origin.zip
stringOrigin zip/postal code.
reason_code
stringCode indicating the reason for the return.
restock_fee
currencyAmount to charge the customer for re-stocking the returned items.
service
stringID of a shipping service as configured in shipment settings.
service_name
stringName of the return shipping service.
shipment_total
currencyAmount to apply to the order as a credit as compensation for the original shipping price.
tracking_code
stringTracking code used to identify the return shipment, if applicable.
credit_tax
currencyautoTotal amount of taxes credited to the order for the returned items.
credit_total
currencyautoTotal amount of additional credit applied to the order.
item_quantity_receivable
intautoTotal quantity of line items that can still be received in a return shipment.
item_quantity_received
intautoTotal quantity of line items that have been received in a return shipment.
item_quantity_restockable
intautoTotal quantity of line items that can still be restocked to product inventory.
item_quantity_restocked
intautoTotal quantity of line items that have been restocked to product inventory.
notifications
NotificationExpandable list of notifications sent on behalf of the products returned.
number
stringautoUnique incremental return number, assigned automatically.
order
OrderExpandable link to the order.
received
booleanautoIndicates that all items have been received in a return shipment.
shipment_tax
currencyautoAmount to apply to the order as a credit as compensation for the original shipping tax.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/returns', {
order_id: '5a9ea7ba3f95740a914267f1',
items: [
{
order_item_id: '5a9ea7ba3f95740a914267f2',
product_id: '5cad15bc9b14d1990724663a',
quantity: 2,
}
],
notes: 'Damaged in transit',
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"number": "R10001",
"order_id": "5a9ea7ba3f95740a914267f1",
"items": [
{
"id": "5a9ea7ba3f95740a914267f2",
"order_item_id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"quantity_received": 0,
"quantity_receivable": 2,
"quantity_restocked": 0,
"quantity_restockable": 2,
...
}
],
"item_quantity_received": 0,
"item_quantity_receivable": 2,
"item_quantity_restocked": 0,
"item_quantity_restockable": 2,
"shipment_total": 0,
"shipment_tax": 0,
"extra_credit": 10,
"restock_fee": 0,
"credit_total": 10,
"credit_tax": 0,
"notes": "Damaged in transit",
...
}
Retrieve a return with the Swell Backend API.
Arguments
id
objectIdrequiredThe id of the refund to retrieve.
expand
stringExpanding link fields and child collections is performed using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
fields
stringReturn only the specified fields in the result. For example fields=name,slug would return only the fields name and slug in the response. Supports nested object and array fields using dot-notation, for example, items.product_id. The category id is always returned.
include
stringInclude one or more arbitrary queries in the response, possibly related to the main query.
See including for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/returns/{id}', {
});
The return model
{
"id": "60f199509111e70000000083",
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"order_item_id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"quantity_received": 0,
"quantity_receivable": 2,
"quantity_restocked": 0,
"quantity_restockable": 2
}
],
"order_id": "60f199509111e70000000084",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.399Z",
"date_updated": "2021-07-16T14:36:00.399Z",
"origin": {
"name": "Jon Snow",
"address1": "1 Main Street",
"city": "Brooklyn",
"state": "NY",
"zip": 11201,
"country": "US",
"phone": "(555) 555-5555"
},
"received": false,
"service": "fedex_ground",
"tracking_code": "T192000000XYZ"
}
Update an existing return using the ID that was obtained when it was created.
Arguments
id
objectIdrequiredUnique identifier for the return.
order_id
objectIdrequiredID of the order this return was created for.
service
stringID of a shipping service as configured in shipment settings.
tracking_code
stringTracking code used to identify the return shipment, if applicable.
canceled
booleanIndicates the return was canceled.
carrier
stringID of a 3rd party carrier offering the service, if applicable.
carrier_name
stringName of a 3rd party carrier offering the service, if applicable.
credit_tax
currencyautoTotal amount of taxes credited to the order for the returned items.
credit_total
currencyautoTotal amount of additional credit applied to the order.
currency
stringThree-letter ISO currency code in uppercase. Defaults to the store's base currency.
date_estimated
dateDate the expected return shipment is meant to arrive at a warehouse, if applicable.
destination
objectThe intended return destination.
destination.location
stringID of the intended return destination, if applicable.
extra_credit
currencyArbitrary amount to apply to the order as compensation for their inconvenience.
item_quantity_receivable
intautoTotal quantity of line items that can still be received in a return shipment.
item_quantity_received
intautoTotal quantity of line items that have been received in a return shipment.
item_quantity_restockable
intautoTotal quantity of line items that can still be restocked to product inventory.
item_quantity_restocked
intautoTotal quantity of line items that have been restocked to product inventory.
notes
stringInternal admin notes, not visible to the customer.
notifications
NotificationExpandable list of notifications sent on behalf of the products returned.
number
stringautoUnique incremental return number, assigned automatically.
order
OrderExpandable link to the order.
origin
objectThe customer's location of origin for the return shipment.
origin.address1
stringOrigin address line 1: street address/PO box/company name.
origin.address2
stringOrigin address line 2: apartment/suite/unit/building.
origin.city
stringOrigin city/district/suburb/town/village.
origin.country
stringTwo-letter ISO country code.
origin.name
stringOrigin customer name.
origin.phone
stringOrigin phone number.
origin.state
stringOrigin state/county/province/region.
origin.zip
stringOrigin zip/postal code.
reason_code
stringCode indicating the reason for the return.
received
booleanautoIndicates that all items have been received in a return shipment.
restock_fee
currencyAmount to charge the customer for re-stocking the returned items.
service_name
stringName of the return shipping service.
shipment_tax
currencyautoAmount to apply to the order as a credit as compensation for the original shipping tax.
shipment_total
currencyAmount to apply to the order as a credit as compensation for the original shipping price.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.put('/returns/{id}', {
id: '60f199509111e70000000078',
tracking_code: 'T192000000XYZ',
service: 'fedex_ground'
});
Response
{
"id": "60f199509111e70000000078",
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"order_item_id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"quantity_received": 0,
"quantity_receivable": 2,
"quantity_restocked": 0,
"quantity_restockable": 2
}
],
"order_id": "60f199509111e7000000007d",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.399Z",
"date_updated": "2021-07-16T14:36:00.399Z",
"origin": {
"name": "Jon Snow",
"address1": "1 Main Street",
"city": "Brooklyn",
"state": "NY",
"zip": 11201,
"country": "US",
"phone": "(555) 555-5555"
},
"received": false,
"service": "fedex_ground",
"tracking_code": "T192000000XYZ"
}
Return a list of... returns.
Arguments
expand
stringExpand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
fields
stringReturns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
include
objectInclude one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
limit
intLimit the number of records returned, ranging between 1 and 1000. Defaults to 15.
page
intThe page number of results to return given the specified or default limit.
search
stringA text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
sort
stringExpression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
where
objectAn object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/returns/{id}', {
id: '60f199509111e7000000007f'
});
Response
{
"count": 51,
"results": [
{
"id": "60f199509111e70000000078",
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"order_item_id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"quantity_received": 0,
"quantity_receivable": 2,
"quantity_restocked": 0,
"quantity_restockable": 2
}
],
"order_id": "60f199509111e70000000088",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.399Z",
"date_updated": "2021-07-16T14:36:00.399Z",
"origin": {
"name": "Jon Snow",
"address1": "1 Main Street",
"city": "Brooklyn",
"state": "NY",
"zip": 11201,
"country": "US",
"phone": "(555) 555-5555"
},
"received": false,
"service": "fedex_ground",
"tracking_code": "T192000000XYZ"
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}
Delete an existing Return.
Arguments
id
objectIdrequiredThe id of the return to delete.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.delete('/returns/{id}', {
});