title: Customize laravel sanctum unauthorize response
body: <p>I am using laravel sanctum in my project, but I am facing a problem. I want to customize the 401 response code (unauthorized) to return a JSON when a token is invalid, something like this:</p>
  <pre><code>    {
      &quot;data&quot;: {
          &quot;code&quot;: 401,
          &quot;book&quot;: null,
          &quot;success&quot;: false,
          &quot;error&quot;: {
              &quot;message&quot;: &quot;Not authenticated&quot;
          }
      }
  }
  </code></pre>
  <p>Instead of default response:</p>
  <pre><code>{
      &quot;message&quot;: &quot;Unauthenticated.&quot;
  }
  </code></pre>
  <p>How to achieve this in laravel sanctum? Thanks in advance.</p>