meta {
  name: Sign-In - email
  type: http
  seq: 3
}

post {
  url: {{url}}/lst/api/auth/sign-in/email
  body: json
  auth: inherit
}

body:json {
  {
    "email": "blake.matthes@alpla.com",
    "password": "nova0511"
  }
}

script:post-response {
  // grab the raw Set-Cookie header
  const cookies = res.headers["set-cookie"];
  
  // cookies is usually an array, e.g. ["auth_session=abcd123; Path=/; HttpOnly; Secure; SameSite=Lax"]
  
  // Extract just the value part ("auth_session=abcd123")
  const sessionCookie = cookies[0].split(";")[0];
  
  // Save it as an environment variable
  bru.setEnvVar("session_cookie", sessionCookie);
}

settings {
  encodeUrl: true
}
