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

idobjectId

Unique identifier for the return.

order_idobjectIdrequired

ID of the order this return was created for.

canceledboolean

Indicates the return was canceled.

carrierstring

ID of a third-party carrier offering the service, if applicable.

carrier_namestring

Name of a third-party carrier offering the service, if applicable.

credit_taxcurrencyauto

Total amount of taxes credited to the order for the returned items.

credit_totalcurrencyauto

Total amount of additional credit applied to the order.

currencystringrequired

Three-letter ISO currency code in uppercase. Defaults to the store's base currency.

date_createddateauto

Date and time the return was created.

date_estimateddate

Date the expected return shipment is meant to arrive at a warehouse, if applicable.

date_updateddateauto

Date and time the return was last updated.

destinationobject

The intended return destination.

extra_creditcurrencyrequired

Arbitrary amount to apply to the order as compensation for their inconvenience.

item_quantity_receivableintauto

Total quantity of line items that can still be received in a return shipment.

item_quantity_receivedintauto

Total quantity of line items that have been received in a return shipment.

item_quantity_restockableintauto

Total quantity of line items that can still be restocked to product inventory.

item_quantity_restockedintauto

Total quantity of line items that have been restocked to product inventory.

notesstring

Internal admin notes, not visible to the customer.

notificationsNotification

Expandable list of notifications sent on behalf of the products returned.

numberstringauto

Unique incremental return number, assigned automatically.

orderOrder

Expandable link to the order.

originobject

The customer's location of origin for the return shipment.

reason_codestring

Code indicating the reason for the return.

receivedbooleanauto

Indicates that all items have been received in a return shipment.

restock_feecurrency

Amount to charge the customer for re-stocking the returned items.

servicestring

ID of a shipping service as configured in shipment settings.

service_namestring

Name of the return shipping service.

shipment_taxcurrencyauto

Amount to apply to the order as a credit as compensation for the original shipping tax.

shipment_totalcurrency

Amount to apply to the order as a credit as compensation for the original shipping price.

tracking_codestring

Tracking 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.

Arguments

itemsarray of objectrequired

List of line items describing the products returned.

order_idobjectIdrequired

ID of the order this return was created for.

notesstring

Internal admin notes, not visible to the customer.

POST/returns
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 an existing return using the ID that was obtained when it was created.

Arguments

idobjectIdrequired

The id of the refund to retrieve.

expandstring

Expanding 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.

fieldsstring

Return 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.

includestring

Include one or more arbitrary queries in the response, possibly related to the main query.

See including for more details.

GET/returns/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/returns/{id}', {
  id: '60f199509111e7000000007f'
});
Response
{
  "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

idobjectId

Unique identifier for the return.

itemsarray of objectrequired

List of line items describing the products returned.

order_idobjectId

ID of the order this return was created for.

servicestring

ID of a shipping service as configured in shipment settings.

tracking_codestring

Tracking code used to identify the return shipment, if applicable.

PUT/returns/:id
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

expandstring

Expand 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.

fieldsstring

Returns 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.
includeobject

Include one or more arbitrary queries in the response which are potentially related to the main query.

See including for more details.

limitint

Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.

pageint

The page number of results to return given the specified or default limit.

searchstring

A 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.

sortstring

Expression 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.

whereobject

An 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.

GET/returns
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
    }
  }
}