title: How to change laravel sanctum return "message": "Unauthenticated."
body: <p>I have integrated sanctum for API authentication. I was facing a problem of redirection if the <code>token</code> is unauthenticated and solved it using this answer on <a href="https://laracasts.com/discuss/channels/laravel/sanctum-api-authentication-redirects-to-login-page?page=1&amp;replyId=695124" rel="nofollow noreferrer">laracasts</a></p>
  <p>I could get a JSON response like:</p>
  <pre><code>{
  &quot;message&quot;: &quot;Unauthenticated.&quot;
  }
  </code></pre>
  <p>What I am trying to do is to handle this response to be something like:</p>
  <pre><code>{
  &quot;status_code&quot;: 401,
  &quot;success&quot;:false,
  &quot;message&quot;: &quot;Unauthenticated.&quot;
  }
  </code></pre>
  <p>Thanks in advance ^^</p>