{
  "info": {
    "_postman_id": "265cea8b-acf7-4a82-a76b-ef1df578f750",
    "name": "U-PIC - Serverless API - Standard",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "27254717"
  },
  "item": [
    {
      "name": "Auth",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const json = pm.response.json();",
              "pm.collectionVariables.set(\"token\", json.token);",
              "",
              "pm.collectionVariables.set(\"ship_date\", new Date().toISOString().slice(0, 10));"
            ]
          }
        }
      ],
      "request": {
        "auth": {
          "type": "noauth"
        },
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\r\n    \"api_key\": \"{{api_key}}\"\r\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://api.u-pic.com/auth",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "auth"
          ]
        }
      },
      "response": []
    },
    {
      "name": "Health",
      "request": {
        "auth": {
          "type": "noauth"
        },
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/health",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "health"
          ]
        }
      },
      "response": []
    },
    {
      "name": "Countries",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/countries",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "countries"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Client/Carriers",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/client/carriers",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "client",
            "carriers"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "// Capture a carrier that belongs to THIS account -- carrier ids are per-client,",
              "// so a hardcoded one only works on the account it came from.",
              "const arr = pm.response.json();",
              "const list = Array.isArray(arr) ? arr : (arr.carriers || []);",
              "const active = list.find(c => String(c.active) === \"1\") || list[0];",
              "if (active) {",
              "    pm.collectionVariables.set(\"client_carrier_id\", String(active.client_carrier_id));",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "Manifests (File)",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"carrier_id\": {{client_carrier_id}},\n  \"declared_value\": 245.54,\n  \"invoice\": \"UYT-543\",\n  \"shipped\": \"{{ship_date}}\",\n  \"tracking\": \"9400111899223456789001\",\n  \"shipper\": \"U-PIC Insurance Services, INC.\",\n  \"consignee\": \"Example Consignee\",\n  \"account\": \"776845\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://api.u-pic.com/manifests",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "manifests"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Manifests (Query)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/manifests?tracking=9400111899223456789001",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "manifests"
          ],
          "query": [
            {
              "key": "tracking",
              "value": "9400111899223456789001"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Claims (File)",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"claim\": {\n    \"consignee_name\": \"John Doe\",\n    \"consignee_zip\": \"90210\",\n    \"consignee_email\": \"john.doe@example.com\",\n    \"consignee_country\": 236,\n    \"ship_date\": \"{{ship_date}}\",\n    \"tracking\": \"9400111899223456789001\",\n    \"item_description\": \"Electronics - Laptop Computer\",\n    \"type\": 1,\n    \"payee\": 1,\n    \"invoice_value\": 245.54,\n    \"declared_value\": 245.54,\n    \"amount_recovered\": 0.00,\n    \"amount_paid_by_carrier\": 0.00,\n    \"repairable\": false,\n    \"shipper\": \"U-PIC Insurance Services, INC.\",\n    \"damage_description\": \"\",\n    \"shipper_reference\": \"ORDER-2024-10-001\"\n  },\n  \"claimant\": {\n    \"contact\": \"Jane Smith\",\n    \"address\": \"123 Main Street\",\n    \"address_2\": \"Suite 100\",\n    \"city\": \"Los Angeles\",\n    \"state\": \"CA\",\n    \"zip\": \"90210\",\n    \"country\": 236,\n    \"email\": \"jane.smith@example.com\",\n    \"company\": \"Example Company\",\n    \"phone\": \"3105551234\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://api.u-pic.com/claims",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "claims"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const json = pm.response.json();",
              "if (json && json.claim_id) {",
              "    pm.collectionVariables.set(\"claim_id\", String(json.claim_id));",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "Claims on Tracking",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/claims?tracking=9400111899223456789001",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "claims"
          ],
          "query": [
            {
              "key": "tracking",
              "value": "9400111899223456789001"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Claims",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/claims/{{claim_id}}",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "claims",
            "{{claim_id}}"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Claims Affidavit",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/claims/{{claim_id}}/affidavits",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "claims",
            "{{claim_id}}",
            "affidavits"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Claims Affidavit (Create)",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\r\n  \"email\": \"techsupport@u-pic.com\"\r\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://api.u-pic.com/claims/{{claim_id}}/affidavits",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "claims",
            "{{claim_id}}",
            "affidavits"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Claims Attachment",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "file",
              "type": "file",
              "value": null
            }
          ]
        },
        "url": {
          "raw": "https://api.u-pic.com/claims/{{claim_id}}/attachments",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "claims",
            "{{claim_id}}",
            "attachments"
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        }
      },
      "response": []
    },
    {
      "name": "Manifests (Delete)",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "// delete_manifests is granted separately from manifests, so a key that can",
              "// file and query may still not delete.",
              "if (pm.response.code === 200) {",
              "    console.log('deleted manifest ' + pm.response.json().manifest_id);",
              "} else if (pm.response.code === 403) {",
              "    console.log('This key does not carry delete_manifests.');",
              "} else if (pm.response.code === 400) {",
              "    // NO_MANIFEST covers both 'no such manifest' and 'a claim exists on it';",
              "    // the response deliberately does not distinguish the two.",
              "    const b = pm.response.json();",
              "    console.log(b.errcode + ': ' + b.error);",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "DELETE",
        "header": [],
        "url": {
          "raw": "https://api.u-pic.com/manifests?tracking=9400111899223456789001",
          "protocol": "https",
          "host": [
            "api",
            "u-pic",
            "com"
          ],
          "path": [
            "manifests"
          ],
          "query": [
            {
              "key": "tracking",
              "value": "9400111899223456789001"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{token}}",
              "type": "string"
            }
          ]
        },
        "description": "Deletes a manifest by tracking number, scoped to your own client.\n\nRequires the delete_manifests permission, which is granted separately from manifests. Without it the request returns 403. Your /auth response reports whether your key carries it.\n\nThe manifest is copied into an audit table before it is removed, so the record survives.\n\nRefused when a claim has been filed against that tracking number. Note the response does not distinguish that from 'no such manifest' - both return 400 NO_MANIFEST with the same message."
      },
      "response": []
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{token}}",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "api_key",
      "value": "REPLACE_WITH_YOUR_API_KEY",
      "type": "string"
    },
    {
      "key": "token",
      "value": "",
      "type": "string"
    },
    {
      "key": "claim_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "ship_date",
      "value": "",
      "type": "string"
    },
    {
      "key": "client_carrier_id",
      "value": "",
      "type": "string"
    }
  ]
}
