If you're building with Contentstack, you'll need to understand how authentication works before you can create, update, or fetch content. The good news is that Contentstack uses token-based authentication, which means you don't need to pass your username and password with every request. Instead, you use tokens—think of them as temporary keys that prove you're allowed to access the content.
There are three main types of tokens you can use: Management Tokens, OAuth Tokens, and Authtokens. Each one works a bit differently, and choosing the right one depends on what you're trying to do.
Authtokens are personal tokens tied to your user account. When you log in to Contentstack, the system generates one for you. These tokens carry your identity, which means any action taken with an Authtoken appears to come from you personally. This also means they inherit your role-based permissions—if you don't have access to certain content types, neither does your Authtoken.
Management Tokens are stack-level tokens with no user identity attached. They're more like master keys for a specific stack. Since they're not personal, they don't inherit role permissions. This makes them ideal for automation scripts, third-party integrations, or situations where you need consistent access without worrying about individual user permissions. They're particularly useful for Single Sign-On (SSO)-enabled organizations where personal authtokens might not work as expected.
OAuth Tokens follow the OAuth 2.0 protocol, which lets external applications access Contentstack on behalf of users without exposing credentials. The system generates both App tokens and User tokens, giving you more granular control over what different applications can access. 👉 Learn how SharkTech customers secure their API integrations with enterprise-grade token management
The authentication process is straightforward. You need two things: your stack's API key and one of the tokens mentioned above.
For Authtoken-based authentication, pass the stack's API key in the header using the api_key parameter, and include your Authtoken using the authtoken parameter. Simple as that.
For Management Token-based authentication, you still pass the API key the same way, but this time you put the Management Token value in the authorization parameter instead.
OAuth Token-based authentication works similarly—API key goes in the api_key parameter, and the OAuth Token goes in the authorization parameter.
One thing to remember: when you're making POST or PUT requests, you must include Content-Type:application/json in your header along with your credentials. Otherwise, the API won't process your request properly.
This is where things get practical. If you're testing things out or building something quick, Authtokens work fine. They're easy to generate—just log in and you're good to go.
But here's the catch: Authtokens are tied to you. If someone gets hold of your Authtoken and knows your Stack API key, they can make requests that look like they're coming from you. For personal projects, that's manageable. For production environments or team projects, not so much.
Management Tokens solve this problem. Since they're not tied to any specific user, there's no risk of personal account compromise. They're perfect for background jobs, scheduled tasks, or integrations that need to run independently. The trade-off is that they have some limitations compared to Authtokens—certain operations that require user context won't work with Management Tokens.
OAuth Tokens shine when you're building third-party applications that need to access Contentstack data. They let users authorize your app without sharing their credentials, which is both more secure and more user-friendly.
Finding your Stack API Key is straightforward. Log into Contentstack, go to your stack, navigate to Settings > Stack, and you'll see the API Key under API Credentials on the right side. Keep in mind that only developers, admins, and stack owners can view this key.
To get an Authtoken, you need to make a login request to the Content Management API. The response will include your authtoken. You can generate up to 20 valid authtokens per account. If you create a 21st token, the oldest one expires automatically without warning. These tokens don't expire on their own, which is convenient but also means you should manage them carefully.
For SSO-enabled organizations, there's a quirk: the login request won't return authtokens for users who access the organization through Identity Provider credentials. Only the organization owner and users with non-SSO access can use authtokens in this scenario. This is where Management Tokens become especially valuable.
Getting a Management Token requires admin access. Go to your stack, then Settings > Tokens > Management Tokens, and select the token you need (or create a new one if you have the permissions). You can have up to 10 valid Management Tokens per stack. Creating an 11th token will expire the oldest one automatically.
For OAuth Tokens, you'll need to go through the OAuth configuration process in your Contentstack account. This involves more setup than the other token types, but it's worth it if you're building applications that need proper authorization flows.
The token limits exist for security reasons. Having 20 Authtokens or 10 Management Tokens might sound restrictive, but in practice, it's plenty for most use cases. The automatic expiration of old tokens when you hit the limit is actually helpful—it prevents unused tokens from piling up and potentially creating security vulnerabilities.
Different tokens have different permission levels. Management Tokens are powerful but have certain limitations compared to Authtokens. Before committing to one type, check Contentstack's documentation on Management Token limitations to make sure they'll work for your specific needs.
When you're working with wider coverage across multiple stacks or need more stable long-term integrations, consider how token management fits into your overall infrastructure. The right authentication strategy can make your development process significantly smoother and your applications more secure.
Understanding these authentication methods might seem like extra work upfront, but it pays off quickly. Once you've got your tokens set up correctly, making API requests becomes a straightforward process, and you can focus on building features rather than wrestling with access issues.