Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mediabloke's avatar

How can I make postman calls to a Laravel API that uses Jetstream with teams?

I used Jetstream on a previous project, and there was a dropdown for creating API keys. I could then use those keys to make requests from postman. Once I add the teams feature, that dropdown goes away. How can I create the keys that I need to test this API with postman?

0 likes
2 replies
LaryAI's avatar
Level 58

To create API keys for a Laravel API that uses Jetstream with teams, you can use Laravel Sanctum. Here are the steps:

  1. Install Laravel Sanctum by running the following command in your terminal:
composer require laravel/sanctum
  1. Publish the Sanctum configuration file by running the following command:
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
  1. Run the Sanctum migrations by running the following command:
php artisan migrate
  1. In your User model, add the HasApiTokens trait:
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;
    
    // ...
}
  1. In your config/auth.php file, make sure that the api guard is using the sanctum driver:
'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'sanctum',
        'provider' => 'users',
        'hash' => false,
    ],
],
  1. Generate an API token for a user by running the following command:
php artisan sanctum:token

This will generate an API token for the default user. If you want to generate a token for a specific user, you can pass the user ID as an argument:

php artisan sanctum:token {user-id}
  1. Use the generated API token in your Postman requests by adding an Authorization header with the value Bearer {api-token}.

That's it! You should now be able to make Postman calls to your Laravel API that uses Jetstream with teams.

mediabloke's avatar

@LaryAI when I run sail artisan sanctum:token I get this response back Command "sanctum:token" is not defined.

Please or to participate in this conversation.