---
title: "Create a Return Against an Order"
source_url: https://docs.rapyd.net/en/create-a-return-against-an-order.html
lang: en
---

# Create a Return Against an Order

Make a return against an order. The maximum amount of the return is the amount of the order.

The order must be in **paid** status.

> **Note:**
>
> It is the responsibility of the merchant to validate the `quantity` of the items in the return against the `quantity` of the items in the order.

This method triggers the following webhooks:

- **Order Return Created** - This webhook contains the same information as the response.
- [Refund Completed Webhook](https://docs.rapyd.net/en/refund-completed-webhook.md "Refund Completed Webhook")

### Parameters

### Request Path Parameters

- - order
  - ID of the return. String starting with **orre_**.

### Request Header Parameters

- - access_key
  - Unique access key provided by Rapyd for each authorized user.

    See [Developers](https://docs.rapyd.net/en/developers.md "Developers").
- - Content-Type
  - Indicates that the data appears in JSON format. Set to **application/json**.
- - idempotency
  - A unique key that prevents the platform from creating the same object twice.

    See [Idempotency](https://docs.rapyd.net/en/idempotency.md "Idempotency").
- - salt
  - Random string. Recommended length: 8-16 characters.
- - signature
  - Signature calculated for each request individually.

    See [Request Signatures](https://docs.rapyd.net/en/request-signatures.md "Request Signatures").
- - timestamp
  - Timestamp for the request, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time") (seconds).

### Request Body Parameters

- items
- Array of objects that describe the goods.

  - - amount
    - In each item of type **sku**, the cost of one individual item, in units specified in `currency`. Decimal, including the correct number of decimal places for the currency exponent, as defined in ISO 2417:2015.
  - - parent
    - ID of the SKU object that represents the product. Each SKU can appear in this list only one time, for items of type '**sku**. Required when `type` is **sku**. Must be **null** when `type` is **shipping**. Required if `type` is **sku**. One of the following:

      - ID of the SKU object. String starting with **sku_**
      - ID of the coupon. If generated by Rapyd, a string starting with **coupon_**.
  - - quantity
    - Quantity of the product in the line item. Integer. Required when `type` is **sku**.
  - - type
    - Type of line item. One of the following:

      - **shipping**
      - **sku**

### Response Parameters

- - amount
  - Total amount of the order, the sum of the amount of the 'shipping' items, plus the `amount` of the tax, plus `amount` times `quantity` of each of the 'sku' items. Decimal.
- - created
  - When the order was created, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time"). Response only.
- - currency
  - Three-letter ISO 4217 code for the currency used in the 'item' objects.
- - id
  - ID of the return. String starting with **orre_**.
- - items
  - Each item describes one charge in the invoice.

    - - amount
      - Price of one SKU unit, in the currency defined in `currency`. Decimal, including the correct number of decimal places for the currency exponent, as defined in ISO 2417:2015.
    - - currency
      - Three-letter ISO 4217 code for the currency. Must be the same as the currency of the order and the currency of the customer's payment method.
    - - description
      - Description of the item.
    - - parent
      - ID of the SKU object that represents the product. One of the following:

        - ID of the SKU object. String starting with **sku_**
        - ID of the coupon. If generated by Rapyd, a string starting with **coupon_**.
    - - quantity
      - Quantity of the product in the line item. Integer. Required when `type` is **sku**.
    - - type
      - Type of line item. One of the following:

        - **discount**
        - **shipping**
        - **sku**
        - **tax**
- - order
  - ID of the order. String starting with **order_**.
- - refund
  - ID of the refund. String starting with **refund_**.

### Code Samples

- - .NET

    - ```csharp
      using System;
      using System.Text.Json;

      namespace RapydApiRequestSample
      {
          class Program
          {
              static void Main(string[] args)
              {
                  try
                  {
                      var items = new Object[]
                      {
                          new
                          {
                              parent = "sku_97f432994f033bd722486ab22fe242d2",
                              amount = 10,
                              type = "sku",
                              quantity = 1,
                          },
                      };

                      string order = "order_20bdf9df5841e57ba80e0a68085871ea";

                      var requestObj = new
                      {
                          items,
                      };

                      string request = JsonSerializer.Serialize(requestObj);

                      string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/orders/{order}/returns", request);

                      Console.WriteLine(result);
                  }
                  catch (Exception e)
                  {
                      Console.WriteLine("Error completing request: " + e.Message);
                  }
              }
          }
      }
      ```
- - JavaScript

    - ```javascript
      const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest;

      async function main() {
        try {
          const body = {
            items: [
              {
                parent: 'sku_97f432994f033bd722486ab22fe242d2',
                amount: '10',
                type: 'sku',
                quantity: '1'
              }
            ]
          };
          const result = await makeRequest(
            'POST',
            '/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea/returns',
            body
          );

          console.log(result);
        } catch (error) {
          console.error('Error completing request', error);
        }
      }
      ```
- - PHP

    - ```php
      <?php
      $path = $_SERVER['DOCUMENT_ROOT'];
      $path .= "/<path-to-your-utility-file>/utilities.php";
      include($path);

      $body = [
          "items" =>  array(
              array(
                  "parent" =>  "sku_97f432994f033bd722486ab22fe242d2",
                  "amount" =>  10,
                  "type" =>  "sku",
                  "quantity" =>  1
              )
          ),
      ];

      try {
          $object = make_request('post', '/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea/returns', $body);
          var_dump($object);
      } catch(Exception $e) {
          echo "Error =>  $e";
      }
      ?>
      ```
- - Python

    - ```python
      from pprint import pprint

      from utilities import make_request

      order = {
          "items": [
              {
                  "parent": "sku_97f432994f033bd722486ab22fe242d2",
                  "amount": "10",
                  "type": "sku",
                  "quantity": "1"
              }
          ]
      }
      result = make_request(method='post',
                            path='/v1/orders/order_20bdf9df5841e57ba80e0a68085871ea/returns',
                            body=order)
      pprint(result)
      ```

- /v1/orders/{order}/returns

- Create a Return Against an Order
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/orders/order_07f883eacb9bc126a60d7e147a58e057/returns' \
  -H 'access_key: your-access-key-here' \
  -H 'Content-Type: application/json' \
  -H 'idempotency: your-idempotency-parameter-here' \
  -H 'salt: your-random-string-here' \
  -H 'signature: your-calculated-signature-here' \
  -H 'timestamp: your-unix-timestamp-here' \
  --data-raw '{
      "items": [
          {
              "parent": "sku_6eb43887fd478baaf9223ec7ec17da21",
              "amount": "50",
              "type": "sku",
              "quantity": "1"
          }
      ]
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "d24ab9eb-1aeb-4982-b53a-709c37c5664e"
      },
      "data": {
          "id": "orre_8772f02783e103c39047ef34e7b4dab0",
          "amount": 50,
          "created": 1763534194,
          "currency": "USD",
          "items": [
              {
                  "amount": 50,
                  "currency": "USD",
                  "description": 0,
                  "parent": "sku_6eb43887fd478baaf9223ec7ec17da21",
                  "quantity": 1,
                  "type": "sku"
              }
          ],
          "order": "order_07f883eacb9bc126a60d7e147a58e057",
          "refund": "refund_4f4a3f3a758fa0f5e61b57aafc7c9e87"
      }
  }
  ```
