{
  "name": "Loyal-Merchant — только у операций, где он объявлен, и только у клиента, выбравшего мерчанта",
  "description": "Клиент партнёра с forMerchant(): операции мерчанта (merchant = true) получают Loyal-Merchant, операции партнёра вне мерчантов (listMerchants, listEventTypes) — нет. Параметр запроса со значением null не отправляется. Токен получен один раз.",
  "client": {
    "api": "management",
    "credential": {
      "clientCredentials": {
        "clientId": "lc_test_4b9ac4f5d6cc6783a2044a5a",
        "clientSecret": "lcs_test__A75hCwHKWYA61AD1WKWOkjtKvU2hRnSKCx_YVFfVos"
      }
    },
    "baseUrl": "https://api.example.com",
    "merchant": "01929c1e-0020-7020-8020-000000000020"
  },
  "calls": [
    {
      "operation": "listMerchants",
      "args": {"limit": 1},
      "expect": {
        "result": {
          "data": [
            {
              "id": "01929c1e-0020-7020-8020-000000000020",
              "name": "Кофейня «Зерно»",
              "status": "active",
              "timezone": "Europe/Moscow",
              "country_code": "RU",
              "external_id": "crm-1",
              "created_at": "2026-10-01T09:00:00.000000Z"
            }
          ],
          "next_cursor": "eyJpZCI6MX0="
        }
      }
    },
    {
      "operation": "listPrograms",
      "args": {},
      "expect": {
        "result": {
          "data": [
            {
              "id": "01929c1e-0010-7010-8010-000000000010",
              "name": "Зерно+",
              "status": "active",
              "timezone": "Europe/Moscow",
              "currency": "RUB"
            }
          ],
          "next_cursor": null
        }
      }
    },
    {
      "operation": "lookupMembers",
      "args": {"program": "01929c1e-0010-7010-8010-000000000010", "phone": "+79000000001", "card": null},
      "expect": {
        "result": {
          "data": [
            {
              "id": "01929c1e-0040-7040-8040-000000000040",
              "program_id": "01929c1e-0010-7010-8010-000000000010",
              "status": "active",
              "masked_phone": "+7 *** ***-00-01",
              "masked_email": "a***@example.com",
              "first_name": "Анна",
              "last_name": null,
              "external_id": null,
              "registration_channel": "pos",
              "registered_at": "2026-10-11T11:58:30.000000Z",
              "referral_code": "ANNA-7K2P",
              "tier": null
            }
          ],
          "next_cursor": null
        }
      }
    },
    {
      "operation": "listEventTypes",
      "args": {},
      "expect": {
        "result": {"data": [{"type": "member.enrolled", "version": 1}, {"type": "receipt.confirmed", "version": 1}]}
      }
    },
    {
      "operation": "listAuditEntries",
      "args": {"action": "merchants.store"},
      "expect": {
        "error": {
          "class": "permission_denied",
          "status": 403,
          "code": "scope_missing",
          "requestId": "01929c20-0006-7000-8000-000000000006",
          "problem": {
            "type": "urn:loyal:problem:scope_missing",
            "title": "The credentials lack a scope.",
            "status": 403,
            "code": "scope_missing",
            "request_id": "01929c20-0006-7000-8000-000000000006",
            "scope": "audit"
          }
        }
      }
    }
  ],
  "exchanges": [
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0001-7000-8000-000000000001",
          "Loyal-Environment": "sandbox",
          "Cache-Control": "no-store",
          "Pragma": "no-cache"
        },
        "json": {
          "access_token": "lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "token_type": "Bearer",
          "expires_in": 3600,
          "scope": "merchants programs organization members webhooks reports"
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/merchants?limit=1",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0002-7000-8000-000000000002",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "data": [
            {
              "id": "01929c1e-0020-7020-8020-000000000020",
              "name": "Кофейня «Зерно»",
              "status": "active",
              "timezone": "Europe/Moscow",
              "country_code": "RU",
              "external_id": "crm-1",
              "created_at": "2026-10-01T09:00:00.000000Z"
            }
          ],
          "next_cursor": "eyJpZCI6MX0="
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/programs",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0003-7000-8000-000000000003",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "data": [
            {
              "id": "01929c1e-0010-7010-8010-000000000010",
              "name": "Зерно+",
              "status": "active",
              "timezone": "Europe/Moscow",
              "currency": "RUB"
            }
          ],
          "next_cursor": null
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/programs/01929c1e-0010-7010-8010-000000000010/members?phone=%2B79000000001",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0004-7000-8000-000000000004",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "data": [
            {
              "id": "01929c1e-0040-7040-8040-000000000040",
              "program_id": "01929c1e-0010-7010-8010-000000000010",
              "status": "active",
              "masked_phone": "+7 *** ***-00-01",
              "masked_email": "a***@example.com",
              "first_name": "Анна",
              "last_name": null,
              "external_id": null,
              "registration_channel": "pos",
              "registered_at": "2026-10-11T11:58:30.000000Z",
              "referral_code": "ANNA-7K2P",
              "tier": null
            }
          ],
          "next_cursor": null
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/event-types",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0005-7000-8000-000000000005",
          "Loyal-Environment": "sandbox"
        },
        "json": {"data": [{"type": "member.enrolled", "version": 1}, {"type": "receipt.confirmed", "version": 1}]}
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/audit-entries?action=merchants.store",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        }
      },
      "response": {
        "status": 403,
        "headers": {
          "Content-Type": "application/problem+json",
          "X-Request-Id": "01929c20-0006-7000-8000-000000000006",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "type": "urn:loyal:problem:scope_missing",
          "title": "The credentials lack a scope.",
          "status": 403,
          "code": "scope_missing",
          "request_id": "01929c20-0006-7000-8000-000000000006",
          "scope": "audit"
        }
      }
    }
  ],
  "sleeps": []
}
