{
  "info": {
    "_postman_id": "tourmax-partner-api-v1",
    "name": "TourMAX Partner API v1",
    "description": "TourMAX Partner REST API. Tüm endpointler JWT Bearer ile korunur (OAuth hariç). Sandbox ve Live ortamlar aynı host üzerinde çalışır — istemcinin (client) modu hangi ortamda işlem yapılacağını belirler.\n\n**Base URL:** https://example.com/apiv2/partner-api/v1\n\n**Auth Flow:** OAuth2 Client Credentials → `/oauth/token` → 2 saatlik access_token → `Authorization: Bearer {token}`.\n\nDetaylı doküman: https://example.com/apiv2/partner-api/v1/docs",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "https://example.com/apiv2/partner-api/v1", "type": "string" },
    { "key": "client_id", "value": "cid_f36a59d50737c1a2616cc823d22697fc", "type": "string" },
    { "key": "client_secret", "value": "sk_test_4c2225b60ad7b9e1971d440b9056841a747ad2312663ebf7", "type": "string" },
    { "key": "access_token", "value": "", "type": "string" },
    { "key": "reservation_ref", "value": "BWZFKU", "type": "string" },
    { "key": "webhook_id", "value": "1", "type": "string" }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{access_token}}", "type": "string" }]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// Otomatik token yenileme: access_token boşsa veya expired ise /oauth/token çağırır",
          "const tok = pm.collectionVariables.get('access_token');",
          "const exp = pm.collectionVariables.get('access_token_exp');",
          "const now = Math.floor(Date.now()/1000);",
          "if (!tok || !exp || now >= parseInt(exp, 10) - 60) {",
          "  pm.sendRequest({",
          "    url: pm.collectionVariables.get('base_url') + '/oauth/token',",
          "    method: 'POST',",
          "    header: { 'Content-Type': 'application/json' },",
          "    body: { mode: 'raw', raw: JSON.stringify({",
          "      grant_type: 'client_credentials',",
          "      client_id: pm.collectionVariables.get('client_id'),",
          "      client_secret: pm.collectionVariables.get('client_secret'),",
          "      scope: 'hotels:read tours:read reservations:read reservations:write account:read content:read webhooks:read webhooks:write'",
          "    })}",
          "  }, (err, res) => {",
          "    if (!err && res.code === 200) {",
          "      const j = res.json();",
          "      pm.collectionVariables.set('access_token', j.data.access_token);",
          "      pm.collectionVariables.set('access_token_exp', String(Math.floor(Date.now()/1000) + (j.data.expires_in || 7200)));",
          "    }",
          "  });",
          "}"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "OAuth",
      "item": [
        {
          "name": "POST /oauth/token",
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"grant_type\": \"client_credentials\",\n  \"client_id\": \"{{client_id}}\",\n  \"client_secret\": \"{{client_secret}}\",\n  \"scope\": \"hotels:read tours:read reservations:read reservations:write account:read content:read webhooks:read webhooks:write\"\n}"
            },
            "url": { "raw": "{{base_url}}/oauth/token", "host": ["{{base_url}}"], "path": ["oauth", "token"] }
          }
        },
        {
          "name": "POST /oauth/revoke",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"token\": \"{{access_token}}\"\n}" },
            "url": { "raw": "{{base_url}}/oauth/revoke", "host": ["{{base_url}}"], "path": ["oauth", "revoke"] }
          }
        }
      ]
    },
    {
      "name": "Hotels",
      "item": [
        {
          "name": "POST /hotels/search",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"destination\": { \"type\": \"CITY\", \"id\": 1 },\n  \"check_in\": \"2026-06-01\",\n  \"check_out\": \"2026-06-05\",\n  \"rooms\": [ { \"adults\": 2, \"children_ages\": [] } ],\n  \"client_nationality\": \"TR\",\n  \"currency\": \"TRY\"\n}"
            },
            "url": { "raw": "{{base_url}}/hotels/search", "host": ["{{base_url}}"], "path": ["hotels", "search"] }
          }
        },
        {
          "name": "GET /hotels/{hid}",
          "request": {
            "method": "GET",
            "url": { "raw": "{{base_url}}/hotels/1", "host": ["{{base_url}}"], "path": ["hotels", "1"] }
          }
        },
        {
          "name": "GET /hotels/{hid}/price",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/hotels/1/price?check_in=2026-06-01&check_out=2026-06-05&adults=2",
              "host": ["{{base_url}}"], "path": ["hotels", "1", "price"],
              "query": [
                { "key": "check_in", "value": "2026-06-01" },
                { "key": "check_out", "value": "2026-06-05" },
                { "key": "adults", "value": "2" }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Tours",
      "item": [
        {
          "name": "POST /tours/search",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"destination\": { \"type\": \"CITY\", \"id\": 1 },\n  \"start_date\": \"2026-07-01\",\n  \"adults\": 2,\n  \"children\": 0,\n  \"currency\": \"TRY\"\n}" },
            "url": { "raw": "{{base_url}}/tours/search", "host": ["{{base_url}}"], "path": ["tours", "search"] }
          }
        },
        {
          "name": "GET /tours/{tid}",
          "request": {
            "method": "GET",
            "url": { "raw": "{{base_url}}/tours/1", "host": ["{{base_url}}"], "path": ["tours", "1"] }
          }
        }
      ]
    },
    {
      "name": "Reservations",
      "item": [
        {
          "name": "GET /reservations (list)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/reservations?per_page=20",
              "host": ["{{base_url}}"], "path": ["reservations"],
              "query": [
                { "key": "per_page", "value": "20" },
                { "key": "type", "value": "hotel", "disabled": true },
                { "key": "status", "value": "CONFIRMED", "disabled": true },
                { "key": "client_reference_id", "value": "BOOK-123", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "GET /reservations/{ref}",
          "request": {
            "method": "GET",
            "url": { "raw": "{{base_url}}/reservations/{{reservation_ref}}", "host": ["{{base_url}}"], "path": ["reservations", "{{reservation_ref}}"] }
          }
        },
        {
          "name": "POST /reservations/hotel",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Idempotency-Key", "value": "{{$guid}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"offer_id\": \"off_XXXX\",\n  \"client_reference_id\": \"BOOK-{{$timestamp}}\",\n  \"client_nationality\": \"TR\",\n  \"contact\": {\n    \"name\": \"Ahmet\",\n    \"surname\": \"Yılmaz\",\n    \"email\": \"ahmet@example.com\",\n    \"phone_country_code\": \"+90\",\n    \"phone_number\": \"5551234567\"\n  },\n  \"guests\": [\n    {\n      \"type\": \"ADULT\", \"name\": \"Ahmet\", \"surname\": \"Yılmaz\",\n      \"birth_date\": \"1985-01-15\", \"gender\": \"MALE\", \"nationality\": \"TR\",\n      \"identity\": { \"type\": \"TC\", \"number\": \"12345678901\" },\n      \"is_lead\": true\n    }\n  ],\n  \"payment\": { \"mode\": \"account\" },\n  \"additional_info\": \"Yüksek kat istenebilir\"\n}"
            },
            "url": { "raw": "{{base_url}}/reservations/hotel", "host": ["{{base_url}}"], "path": ["reservations", "hotel"] }
          }
        },
        {
          "name": "POST /reservations/tour",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Idempotency-Key", "value": "{{$guid}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"offer_id\": \"off_XXXX\",\n  \"client_reference_id\": \"TOUR-{{$timestamp}}\",\n  \"payment_mode\": \"account\",\n  \"lead_guest\": {\n    \"first_name\": \"Ayşe\", \"last_name\": \"Demir\",\n    \"email\": \"ayse@example.com\", \"phone\": \"+905551234567\",\n    \"tc\": \"12345678901\"\n  }\n}"
            },
            "url": { "raw": "{{base_url}}/reservations/tour", "host": ["{{base_url}}"], "path": ["reservations", "tour"] }
          }
        },
        {
          "name": "PATCH /reservations/{ref}",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"contact\": {\n    \"email\": \"yeni@example.com\",\n    \"phone_country_code\": \"+90\",\n    \"phone_number\": \"5559876543\"\n  },\n  \"client_reference_id\": \"BOOK-UPDATED\",\n  \"additional_info\": \"Güncellenmiş not\"\n}"
            },
            "url": { "raw": "{{base_url}}/reservations/{{reservation_ref}}", "host": ["{{base_url}}"], "path": ["reservations", "{{reservation_ref}}"] }
          }
        },
        {
          "name": "POST /reservations/{ref}/cancel",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"reason\": \"Partner test cancellation\"\n}" },
            "url": { "raw": "{{base_url}}/reservations/{{reservation_ref}}/cancel", "host": ["{{base_url}}"], "path": ["reservations", "{{reservation_ref}}", "cancel"] }
          }
        },
        {
          "name": "GET /reservations/{ref}/voucher",
          "request": {
            "method": "GET",
            "url": { "raw": "{{base_url}}/reservations/{{reservation_ref}}/voucher", "host": ["{{base_url}}"], "path": ["reservations", "{{reservation_ref}}", "voucher"] }
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "GET /webhooks",
          "request": {
            "method": "GET",
            "url": { "raw": "{{base_url}}/webhooks", "host": ["{{base_url}}"], "path": ["webhooks"] }
          }
        },
        {
          "name": "POST /webhooks/create",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Idempotency-Key", "value": "{{$guid}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://webhook.site/your-uuid\",\n  \"events\": [\"reservation.confirmed\", \"reservation.cancelled\"],\n  \"description\": \"Benim test webhook'um\"\n}"
            },
            "url": { "raw": "{{base_url}}/webhooks/create", "host": ["{{base_url}}"], "path": ["webhooks", "create"] }
          }
        },
        {
          "name": "GET /webhooks/{id}",
          "request": {
            "method": "GET",
            "url": { "raw": "{{base_url}}/webhooks/{{webhook_id}}", "host": ["{{base_url}}"], "path": ["webhooks", "{{webhook_id}}"] }
          }
        },
        {
          "name": "PATCH /webhooks/{id}",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"status\": \"paused\"\n}" },
            "url": { "raw": "{{base_url}}/webhooks/{{webhook_id}}", "host": ["{{base_url}}"], "path": ["webhooks", "{{webhook_id}}"] }
          }
        },
        {
          "name": "POST /webhooks/{id}/test",
          "request": {
            "method": "POST",
            "url": { "raw": "{{base_url}}/webhooks/{{webhook_id}}/test", "host": ["{{base_url}}"], "path": ["webhooks", "{{webhook_id}}", "test"] }
          }
        },
        {
          "name": "GET /webhooks/{id}/deliveries",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/webhooks/{{webhook_id}}/deliveries?per_page=20",
              "host": ["{{base_url}}"], "path": ["webhooks", "{{webhook_id}}", "deliveries"],
              "query": [{ "key": "per_page", "value": "20" }]
            }
          }
        },
        {
          "name": "DELETE /webhooks/{id}",
          "request": {
            "method": "DELETE",
            "url": { "raw": "{{base_url}}/webhooks/{{webhook_id}}", "host": ["{{base_url}}"], "path": ["webhooks", "{{webhook_id}}"] }
          }
        }
      ]
    },
    {
      "name": "Account",
      "item": [
        {
          "name": "GET /account",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/account", "host": ["{{base_url}}"], "path": ["account"] } }
        },
        {
          "name": "GET /account/balance",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/account/balance", "host": ["{{base_url}}"], "path": ["account", "balance"] } }
        },
        {
          "name": "GET /account/commissions",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/account/commissions", "host": ["{{base_url}}"], "path": ["account", "commissions"] } }
        }
      ]
    },
    {
      "name": "Content",
      "item": [
        {
          "name": "GET /content/currencies",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/content/currencies", "host": ["{{base_url}}"], "path": ["content", "currencies"] } }
        },
        {
          "name": "GET /content/countries",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/content/countries", "host": ["{{base_url}}"], "path": ["content", "countries"] } }
        },
        {
          "name": "GET /content/cities",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/content/cities?country_id=212",
              "host": ["{{base_url}}"], "path": ["content", "cities"],
              "query": [{ "key": "country_id", "value": "212" }]
            }
          }
        },
        {
          "name": "GET /content/hotel-concepts",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/content/hotel-concepts", "host": ["{{base_url}}"], "path": ["content", "hotel-concepts"] } }
        },
        {
          "name": "GET /content/tour-themes",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/content/tour-themes", "host": ["{{base_url}}"], "path": ["content", "tour-themes"] } }
        }
      ]
    }
  ]
}
