{
    "info": {
        "_postman_id": "b51da3a0-7e9c-4a3e-9e0b-shipper-open-api",
        "name": "Shipper Open API",
        "description": "Collection for creating and fetching orders using Shipper OrganizationApi tokens.",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "item": [
        {
            "name": "List Countries",
            "request": {
                "auth": {
                    "type": "bearer",
                    "bearer": [
                        {
                            "key": "token",
                            "value": "{{api_key}}",
                            "type": "string"
                        }
                    ]
                },
                "method": "GET",
                "header": [
                    {
                        "key": "Accept",
                        "value": "application/json"
                    }
                ],
                "url": {
                    "raw": "{{base_url}}/api/v1/countries",
                    "host": [
                        "{{base_url}}"
                    ],
                    "path": [
                        "api",
                        "v1",
                        "countries"
                    ]
                },
                "description": "List all supported countries with their geographic structure (division levels and labels)."
            },
            "response": [
                {
                    "name": "200 OK - Example",
                    "originalRequest": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/countries",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "countries"
                            ]
                        }
                    },
                    "status": "OK",
                    "code": 200,
                    "_postman_previewlanguage": "json",
                    "header": [
                        {
                            "key": "Content-Type",
                            "value": "application/json"
                        }
                    ],
                    "body": "[\n  {\n    \"code\": \"TN\",\n    \"name\": \"Tunisia\",\n    \"geo_structure\": {\n      \"fields\": [\n        {\n          \"id\": \"division_1_id\",\n          \"label\": \"Governorate\",\n          \"level\": 1,\n          \"required\": true,\n          \"depends_on\": null\n        },\n        {\n          \"id\": \"division_2_id\",\n          \"label\": \"Delegation\",\n          \"level\": 2,\n          \"required\": true,\n          \"depends_on\": \"division_1_id\"\n        }\n      ]\n    }\n  }\n]"
                }
            ]
        },
        {
            "name": "Get Country Divisions",
            "request": {
                "auth": {
                    "type": "bearer",
                    "bearer": [
                        {
                            "key": "token",
                            "value": "{{api_key}}",
                            "type": "string"
                        }
                    ]
                },
                "method": "GET",
                "header": [
                    {
                        "key": "Accept",
                        "value": "application/json"
                    }
                ],
                "url": {
                    "raw": "{{base_url}}/api/v1/countries/TN/divisions?level=1",
                    "host": [
                        "{{base_url}}"
                    ],
                    "path": [
                        "api",
                        "v1",
                        "countries",
                        "TN",
                        "divisions"
                    ],
                    "query": [
                        {
                            "key": "level",
                            "value": "1",
                            "description": "Division level (default: 1 = top level)"
                        },
                        {
                            "key": "parent_id",
                            "value": "",
                            "description": "Filter by parent division ID to get children",
                            "disabled": true
                        }
                    ]
                },
                "description": "Get division names for a country. Use this to know valid values for address.division_1, address.division_2, etc. when creating orders."
            },
            "response": [
                {
                    "name": "200 OK - Example",
                    "originalRequest": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/countries/TN/divisions?level=1",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "countries",
                                "TN",
                                "divisions"
                            ],
                            "query": [
                                {
                                    "key": "level",
                                    "value": "1"
                                }
                            ]
                        }
                    },
                    "status": "OK",
                    "code": 200,
                    "_postman_previewlanguage": "json",
                    "header": [
                        {
                            "key": "Content-Type",
                            "value": "application/json"
                        }
                    ],
                    "body": "{\n  \"country\": \"TN\",\n  \"geo_structure\": {\n    \"fields\": [\n      {\n        \"id\": \"division_1_id\",\n        \"label\": \"Governorate\",\n        \"level\": 1,\n        \"required\": true,\n        \"depends_on\": null\n      },\n      {\n        \"id\": \"division_2_id\",\n        \"label\": \"Delegation\",\n        \"level\": 2,\n        \"required\": true,\n        \"depends_on\": \"division_1_id\"\n      }\n    ]\n  },\n  \"divisions\": [\n    { \"id\": 1, \"name\": \"Tunis\", \"level\": 1, \"parent_id\": null },\n    { \"id\": 2, \"name\": \"Sfax\", \"level\": 1, \"parent_id\": null },\n    { \"id\": 3, \"name\": \"Sousse\", \"level\": 1, \"parent_id\": null }\n  ]\n}"
                }
            ]
        },
        {
            "name": "Create Order",
            "request": {
                "auth": {
                    "type": "bearer",
                    "bearer": [
                        {
                            "key": "token",
                            "value": "{{api_key}}",
                            "type": "string"
                        }
                    ]
                },
                "method": "POST",
                "header": [
                    {
                        "key": "Accept",
                        "value": "application/json"
                    },
                    {
                        "key": "Content-Type",
                        "value": "application/json"
                    }
                ],
                "body": {
                    "mode": "raw",
                    "raw": "{\n    \"address\": {\n        \"name\": \"test client\",\n        \"division_1\": null,\n        \"division_2\": null,\n        \"phone1\": \"28177188\",\n        \"phone2\": null,\n        \"address1\": \"Ave test\",\n        \"address2\": null,\n        \"country\": \"TN\"\n    },\n    \"items\": [\n        {\n            \"quantity\": 1,\n            \"id\": \"2e97b37a-3118-4905-842c-19706bcf1455\",\n            \"total_price\": 190\n        }\n    ],\n    \"shipping_total\": 9,\n    \"is_cod\": true,\n    \"auto_fulfill\": true,\n    \"with_confirmation\": true,\n    \"store_name\": \"abc store\",\n    \"external_order_id\": \"ORD-12345\",\n    \"external_order_url\": \"https://mystore.com/orders/12345\"\n}"
                },
                "url": {
                    "raw": "{{base_url}}/api/v1/orders",
                    "host": [
                        "{{base_url}}"
                    ],
                    "path": [
                        "api",
                        "v1",
                        "orders"
                    ]
                },
                "description": "Creates a new order in Shipper via the Open API. Returns the internal order ID. Optionally pass external_order_id and external_order_url to link back to your system."
            },
            "response": [
                {
                    "name": "201 Created - Example",
                    "originalRequest": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"address\": {\n        \"name\": \"test client\",\n        \"division_1\": null,\n        \"division_2\": null,\n        \"phone1\": \"28177188\",\n        \"phone2\": null,\n        \"address1\": \"Ave test\",\n        \"address2\": null,\n        \"country\": \"TN\"\n    },\n    \"items\": [\n        {\n            \"quantity\": 1,\n            \"id\": \"2e97b37a-3118-4905-842c-19706bcf1455\",\n            \"total_price\": 190\n        }\n    ],\n    \"shipping_total\": 9,\n    \"is_cod\": true,\n    \"auto_fulfill\": true,\n    \"with_confirmation\": true,\n    \"store_name\": \"abc store\",\n    \"external_order_id\": \"ORD-12345\",\n    \"external_order_url\": \"https://mystore.com/orders/12345\"\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/orders",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "orders"
                            ]
                        }
                    },
                    "status": "Created",
                    "code": 201,
                    "_postman_previewlanguage": "json",
                    "header": [
                        {
                            "key": "Content-Type",
                            "value": "application/json"
                        }
                    ],
                    "body": "{\n  \"id\": 555\n}"
                }
            ]
        },
        {
            "name": "Get Order",
            "request": {
                "auth": {
                    "type": "bearer",
                    "bearer": [
                        {
                            "key": "token",
                            "value": "{{api_key}}",
                            "type": "string"
                        }
                    ]
                },
                "method": "GET",
                "header": [
                    {
                        "key": "Accept",
                        "value": "application/json"
                    }
                ],
                "url": {
                    "raw": "{{base_url}}/api/v1/orders/{{order_id}}",
                    "host": [
                        "{{base_url}}"
                    ],
                    "path": [
                        "api",
                        "v1",
                        "orders",
                        "{{order_id}}"
                    ]
                },
                "description": "Fetch a single order by its internal Shipper order ID."
            },
            "response": [
                {
                    "name": "200 OK - Example",
                    "originalRequest": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/orders/{{order_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "orders",
                                "{{order_id}}"
                            ]
                        }
                    },
                    "status": "OK",
                    "code": 200,
                    "_postman_previewlanguage": "json",
                    "header": [
                        {
                            "key": "Content-Type",
                            "value": "application/json"
                        }
                    ],
                    "body": "{\n  \"id\": 555,\n  \"status\": \"Paid\",\n  \"contact_task_status\": \"called\",\n  \"shipments\": [\n    {\n      \"uuid\": \"11111111-2222-3333-4444-555555555555\",\n      \"status\": \"delivered\",\n      \"tracking_numbers\": [\n        {\n          \"number\": \"99999999999\",\n          \"logs\": [\n            {\n              \"status\": \"at_carrier_origin_facility\",\n              \"details\": \"comment: null\",\n              \"created_at\": \"2025-01-15T02:02:59.000000Z\",\n              \"external_timestamp\": \"2025-01-14 22:48:00\"\n            },\n            {\n              \"status\": \"in_transit\",\n              \"details\": \"comment: null\",\n              \"created_at\": \"2025-01-15T02:02:59.000000Z\",\n              \"external_timestamp\": \"2025-01-14 23:05:00\"\n            },\n            {\n              \"status\": \"delivered\",\n              \"details\": \"comment: null\",\n              \"created_at\": \"2025-01-18T02:09:19.000000Z\",\n              \"external_timestamp\": \"2025-01-17 14:16:00\"\n            }\n          ]\n        }\n      ]\n    }\n  ],\n  \"address\": {\n    \"first_name\": \"Omar\",\n    \"last_name\": \"Test\",\n    \"phone1\": \"+21690000000\",\n    \"phone2\": \"\",\n    \"address1\": \"Rue de l'Indépendance\",\n    \"address2\": \"\",\n    \"division_1\": \"Tunis\",\n    \"division_2\": null,\n    \"country\": \"TN\"\n  }\n}"
                }
            ]
        },
        {
            "name": "List Products",
            "request": {
                "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }] },
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                    "raw": "{{base_url}}/api/v1/products?per_page=20&search=",
                    "host": ["{{base_url}}"],
                    "path": ["api", "v1", "products"],
                    "query": [
                        { "key": "per_page", "value": "20" },
                        { "key": "search", "value": "", "disabled": true }
                    ]
                },
                "description": "List your products with UUIDs needed for creating orders."
            },
            "response": []
        },
        {
            "name": "Get Product",
            "request": {
                "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }] },
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                    "raw": "{{base_url}}/api/v1/products/{{product_uuid}}",
                    "host": ["{{base_url}}"],
                    "path": ["api", "v1", "products", "{{product_uuid}}"]
                },
                "description": "Get a single product by UUID with variants and stock info."
            },
            "response": []
        },
        {
            "name": "List Orders",
            "request": {
                "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }] },
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                    "raw": "{{base_url}}/api/v1/orders?per_page=20",
                    "host": ["{{base_url}}"],
                    "path": ["api", "v1", "orders"],
                    "query": [
                        { "key": "per_page", "value": "20" },
                        { "key": "status", "value": "", "disabled": true },
                        { "key": "start_date", "value": "", "disabled": true },
                        { "key": "end_date", "value": "", "disabled": true },
                        { "key": "search", "value": "", "disabled": true }
                    ]
                },
                "description": "List orders with pagination and optional filters."
            },
            "response": []
        },
        {
            "name": "Cancel Order",
            "request": {
                "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }] },
                "method": "POST",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                    "raw": "{{base_url}}/api/v1/orders/{{order_id}}/cancel",
                    "host": ["{{base_url}}"],
                    "path": ["api", "v1", "orders", "{{order_id}}", "cancel"]
                },
                "description": "Cancel an order's shipments. Works for orders in confirmation or awaiting packaging."
            },
            "response": []
        },
        {
            "name": "Register Webhook",
            "request": {
                "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }] },
                "method": "POST",
                "header": [{ "key": "Accept", "value": "application/json" }, { "key": "Content-Type", "value": "application/json" }],
                "body": {
                    "mode": "raw",
                    "raw": "{\n    \"url\": \"https://mystore.com/webhooks/shipper\",\n    \"events\": [\"order.status_changed\", \"shipment.status_changed\"],\n    \"secret\": \"my-webhook-secret-key\"\n}"
                },
                "url": {
                    "raw": "{{base_url}}/api/v1/webhooks",
                    "host": ["{{base_url}}"],
                    "path": ["api", "v1", "webhooks"]
                },
                "description": "Register a webhook URL to receive order/shipment status change notifications."
            },
            "response": []
        },
        {
            "name": "List Webhooks",
            "request": {
                "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }] },
                "method": "GET",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                    "raw": "{{base_url}}/api/v1/webhooks",
                    "host": ["{{base_url}}"],
                    "path": ["api", "v1", "webhooks"]
                },
                "description": "List all registered webhooks for the current API key."
            },
            "response": []
        },
        {
            "name": "Delete Webhook",
            "request": {
                "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }] },
                "method": "DELETE",
                "header": [{ "key": "Accept", "value": "application/json" }],
                "url": {
                    "raw": "{{base_url}}/api/v1/webhooks/1",
                    "host": ["{{base_url}}"],
                    "path": ["api", "v1", "webhooks", "1"]
                },
                "description": "Delete a webhook by ID."
            },
            "response": []
        }
    ],
    "variable": [
        {
            "key": "base_url",
            "value": "https://server.shipper.network"
        },
        {
            "key": "api_key",
            "value": "",
            "description": "Your OrganizationApi Bearer token."
        },
        {
            "key": "order_id",
            "value": "555",
            "description": "Example order ID to test the GET /orders/{id} endpoint."
        },
        {
            "key": "product_uuid",
            "value": "",
            "description": "Product UUID to test the GET /products/{uuid} endpoint."
        }
    ]
}
