{
  "info": {
    "name": "ILS — Return-Request Mobile API",
    "_postman_id": "b3f1f9d2-9f1b-4d6d-9e1a-1c2a3b4c5d02",
    "description": "Mobile-app endpoints for the Indian Logistics Services return/exchange feature.\n\nSource: prfiles/return-request/api/\nDocs:   documentation/api/return/return.md  (or the rendered portal at /documentation/api/return/)\n\nAll endpoints share the same URL — `action` selects the operation.\nAuthentication: header `Auth-Token` + body `shop`.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": { "type": "noauth" },
  "variable": [
    { "key": "base_url",    "value": "https://ils.shopiapps.in/prfiles/return-request/api", "type": "string" },
    { "key": "shop",        "value": "examplestore.myshopify.com",                          "type": "string" },
    { "key": "auth_token",  "value": "REPLACE_WITH_MOBILE_APP_ACCESS_TOKEN",                "type": "string" },
    { "key": "email",       "value": "customer@example.com",                                "type": "string" },
    { "key": "order_name",  "value": "#1042",                                               "type": "string" },
    { "key": "order_id",    "value": "REPLACE_WITH_ENCRYPTED_ORDER_ID",                    "type": "string" },
    { "key": "customer_id", "value": "REPLACE_WITH_ENCRYPTED_CUSTOMER_ID",                 "type": "string" },
    { "key": "location_id", "value": "REPLACE_WITH_ENCRYPTED_LOCATION_ID",                 "type": "string" },
    { "key": "product_id",  "value": "REPLACE_WITH_ENCRYPTED_PRODUCT_ID",                  "type": "string" },
    { "key": "item_id",     "value": "REPLACE_WITH_ENCRYPTED_LINEITEM_ID",                 "type": "string" },
    { "key": "variant_id",  "value": "REPLACE_WITH_ENCRYPTED_VARIANT_ID",                  "type": "string" },
    { "key": "return_id",   "value": "REPLACE_WITH_ENCRYPTED_REVERSE_PICKUP_ID",           "type": "string" },
    { "key": "phone_number","value": "9876543210",                                          "type": "string" },
    { "key": "next_data",   "value": "",                                                    "type": "string" }
  ],
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.test('JSON envelope present', function () {",
          "    pm.response.to.be.json;",
          "    var body = pm.response.json();",
          "    pm.expect(body).to.have.property('success');",
          "    pm.expect(body).to.have.property('code');",
          "    pm.expect(body).to.have.property('message');",
          "});"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "01 — Get Return Settings",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",              "type": "text" },
            { "key": "action", "value": "get_return_settings",   "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Returns the merchant's return-page configuration: theme colours, copy, reason list, refund modes and behaviour flags.\n\nCall on app launch / when the user enters the return flow."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Returns 200 on valid shop+token', function () {",
              "    pm.response.to.have.status(200);",
              "    var body = pm.response.json();",
              "    pm.expect(body.success).to.eql(true);",
              "    pm.expect(body.data).to.have.property('return_reasons');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "02 — Get Order List (by email)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",      "value": "{{shop}}",        "type": "text" },
            { "key": "action",    "value": "get_order_list",  "type": "text" },
            { "key": "email",     "value": "{{email}}",       "type": "text" },
            { "key": "next_data", "value": "{{next_data}}",   "type": "text", "description": "Cursor from a previous response. Leave empty for the first page." }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Lists the customer's orders from the last 60 days. Cursor-paginated via `next_data`."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Stores next_data cursor for chained requests', function () {",
              "    var body = pm.response.json();",
              "    if (body.success && body.next_data) {",
              "        pm.collectionVariables.set('next_data', body.next_data);",
              "    }",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "03 — Get Order Details (by order # + email/phone)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",       "value": "{{shop}}",       "type": "text" },
            { "key": "action",     "value": "order_details",  "type": "text" },
            { "key": "order_name", "value": "{{order_name}}", "type": "text" },
            { "key": "email",      "value": "{{email}}",      "type": "text", "description": "Email OR 10-digit phone." }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Full order payload: delivery address, courier+AWB, line items with per-item returnable flag, allow_edit flags."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Stores encrypted order_id + customer_id', function () {",
              "    var body = pm.response.json();",
              "    if (body.success && body.data) {",
              "        if (body.data.order_id)    pm.collectionVariables.set('order_id',    body.data.order_id);",
              "        if (body.data.customer_id) pm.collectionVariables.set('customer_id', body.data.customer_id);",
              "    }",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "04 — Get Customer Shipping Addresses",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",        "value": "{{shop}}",                            "type": "text" },
            { "key": "action",      "value": "get_customer_shipping_addresses",     "type": "text" },
            { "key": "customer_id", "value": "{{customer_id}}",                     "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Lists all saved addresses for the customer (Shopify customer.addresses)."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Stores first location_id for chained requests', function () {",
              "    var body = pm.response.json();",
              "    if (body.success && body.data && body.data.length > 0) {",
              "        pm.collectionVariables.set('location_id', body.data[0].location_id);",
              "    }",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "05 — Edit Customer Shipping Address",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",        "value": "{{shop}}",                            "type": "text" },
            { "key": "action",      "value": "edit_customer_shipping_address",      "type": "text" },
            { "key": "order_id",    "value": "{{order_id}}",                        "type": "text" },
            { "key": "customer_id", "value": "{{customer_id}}",                     "type": "text" },
            { "key": "location_id", "value": "{{location_id}}",                     "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Replaces the order's shipping address with the customer-saved one identified by location_id."
      },
      "response": []
    },
    {
      "name": "06 — Edit Phone Number",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",         "value": "{{shop}}",                    "type": "text" },
            { "key": "action",       "value": "edit_customer_phone_number",  "type": "text" },
            { "key": "order_id",     "value": "{{order_id}}",                "type": "text" },
            { "key": "phone_number", "value": "{{phone_number}}",            "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Updates the phone number on the order's shipping address."
      },
      "response": []
    },
    {
      "name": "07 — Cancel Order",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",     "value": "{{shop}}",        "type": "text" },
            { "key": "action",   "value": "cancel_order",    "type": "text" },
            { "key": "order_id", "value": "{{order_id}}",    "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Cancels the Shopify order on the customer's behalf (reason: CUSTOMER, refund + restock + notify all true)."
      },
      "response": []
    },
    {
      "name": "08 — Get Exchange Variants",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",       "value": "{{shop}}",        "type": "text" },
            { "key": "action",     "value": "get_variant",     "type": "text" },
            { "key": "order_id",   "value": "{{order_id}}",    "type": "text" },
            { "key": "product_id", "value": "{{product_id}}",  "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Lists variants of a product the customer is exchanging into."
      },
      "response": []
    },
    {
      "name": "09 — Get Exchange Products (paginated search)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",       "value": "{{shop}}",       "type": "text" },
            { "key": "action",     "value": "get_products",   "type": "text" },
            { "key": "order_id",   "value": "{{order_id}}",   "type": "text" },
            { "key": "product_id", "value": "{{product_id}}", "type": "text" },
            { "key": "search",     "value": "{\"type\":\"\",\"cursor\":\"\",\"search_pro\":\"\"}", "type": "text", "description": "JSON: {type:next|previous, cursor, search_pro}" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Title-prefix product search for the exchange flow."
      },
      "response": []
    },
    {
      "name": "10 — Submit Return Request (refund / exchange)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "shop",          "value": "{{shop}}",                            "type": "text" },
            { "key": "action",        "value": "return_requests_submit",              "type": "text" },
            { "key": "order_id",      "value": "{{order_id}}",                        "type": "text" },
            { "key": "product_data",  "value": "[{\"item_id\":\"{{item_id}}\",\"quantity\":1,\"reason\":\"Wrong size\",\"customer_note\":\"Please send a size L instead\",\"return_option\":\"exchange\",\"replace_variant_id\":\"{{variant_id}}\",\"replace_product_id\":\"{{product_id}}\",\"exchange_quantity\":1,\"refund_mode\":\"\",\"refund_mode_details\":{}}]", "type": "text",
              "description": "JSON array of items. For pure refund, set return_option=refund and supply refund_mode + refund_mode_details (e.g. {upi_id:abc@bank}) and leave replace_* empty." },
            { "key": "return_address","value": "",                                    "type": "text",
              "description": "Optional JSON object — pickup address (each field base64-encoded server-side)." }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Submits the return.\n\nWhen attaching proof images, add a multipart file field per item: key=img_<decrypted lineitem id>, type=file. JPG / JPEG / PNG only. Images > 500 KB are resized to 600px wide.\n\nReturns 200 success on at least one row created; 409 if the order is not fulfilled or items already returned."
      },
      "response": []
    },
    {
      "name": "11 — Reschedule Pickup",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",            "type": "text" },
            { "key": "action", "value": "reschedule_pickup",   "type": "text" },
            { "key": "id",     "value": "{{return_id}}",       "type": "text", "description": "Encrypted reverse_pickup.id from return_data[].id" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Resets a declined / cancelled return request back to pending and fires the confirmation mails."
      },
      "response": []
    },
    {
      "name": "Negative — Missing Auth-Token",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",             "type": "text" },
            { "key": "action", "value": "get_return_settings",  "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Sanity check: a request without the Auth-Token header must return 401 UNAUTHORIZED."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Rejects with 401 UNAUTHORIZED', function () {",
              "    pm.response.to.have.status(401);",
              "    var body = pm.response.json();",
              "    pm.expect(body.success).to.eql(false);",
              "    pm.expect(body.code).to.eql('UNAUTHORIZED');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "Negative — Unknown action",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",        "type": "text" },
            { "key": "action", "value": "does_not_exist",  "type": "text" }
          ]
        },
        "url": { "raw": "{{base_url}}/", "host": [ "{{base_url}}" ], "path": [ "" ] },
        "description": "Unknown action must return 400 INVALID_INPUT."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Rejects with 400 INVALID_INPUT', function () {",
              "    pm.response.to.have.status(400);",
              "    var body = pm.response.json();",
              "    pm.expect(body.success).to.eql(false);",
              "    pm.expect(body.code).to.eql('INVALID_INPUT');",
              "});"
            ]
          }
        }
      ]
    }
  ]
}
