Error calling Test Notification endpoint

I'm trying to call the Test Notification endpoint: https://developer.apple.com/documentation/appstoreserverapi/request_a_test_notification?language=objc

I'm creating a JWT bearer token using a script I run on the console with these 2 commands: npm install jsonwebtoken fs and node generate_jwt.js

Keys are taken from App Store Connect -> User and Access -> Integrations -> Keys -> In-App Purchase.

generate_jwt.js script:

const jwt = require('jsonwebtoken');
const fs = require('fs');

const keyId = 'MY_KEY_ID';
const issuerId = 'MY_ISSUER_ID';
const privateKey = `-----BEGIN PRIVATE KEY-----
MY_SECRET_KEY
-----END PRIVATE KEY-----`;

// Define JWT headers and claims
const token = jwt.sign({}, privateKey, {
  algorithm: 'ES256',
  expiresIn: '1h',
  issuer: issuerId,
  header: {
    alg: 'ES256',
    kid: keyId,
  },
  audience: 'appstoreconnect-v1'
});

console.log('JWT Token:', token);

When I run a POST https://api.storekit.itunes.apple.com/inApps/v1/notifications/test request on postman with Bearer token authentication, I get a 401 Unauthorized error.

Error calling Test Notification endpoint
 
 
Q