Authentication
The Mirra SDK uses API keys for authentication. All API requests must include an API key in the Authorization header using the Bearer authentication scheme.
Getting your API key
API keys are automatically generated when you create scripts or resources in Mirra. The most common way to obtain an API key is by creating a script.
Creating a script and getting an API key
When you create a script via the API or web interface, an API key is automatically generated and returned in the response. This key is only shown once—save it securely as you cannot retrieve it later.
Example: Creating a script via API
Response:
The apiKey field contains your authentication credential. Store it securely in environment variables or a secrets manager.
The API key is only returned once during script creation. If you lose it, you will need to regenerate it by creating a new version of your script.
Creating a script via the web interface
You can also obtain an API key through the browser-based developer dashboard:
- Navigate to https://store.getmirra.app/developer/scripts
- Click Create New Script
- Complete the script creation wizard
- Your API key is displayed after script creation—copy it immediately
The web interface provides the same functionality as the API, making it easier to get started without writing code.
API key format
Mirra API keys use prefixes to identify their type and context:
mirra_script_- Keys associated with scripts you createmirra_install_- Keys for installed script instances (Lambda execution)mirra_test_- Test environment keys for development
API keys are 64 to 128 characters long and contain hexadecimal characters after the prefix.
Example API keys:
Never commit API keys to version control or expose them in client-side code. Treat API keys like passwords—they provide full access to your Mirra resources.
Using API keys
Include your API key in the Authorization header with the Bearer scheme for every API request:
In application code
Node.js:
Load the API key from an environment variable rather than hardcoding it in your source code.
Python:
Security best practices
Store keys securely
Store API keys in environment variables, not in source code:
Never hardcode API keys:
Regenerate compromised keys
If an API key is accidentally exposed or compromised, regenerate it immediately:
- Create a new version of your script to get a fresh API key
- Update your applications to use the new key
- Test that all systems work with the new key
- The old script version and its key become inactive
Separate keys for different environments
Create separate scripts for development, staging, and production environments. Each script receives its own API key, providing isolation between environments:
This limits the impact if a development key is compromised—production resources remain secure.
Limit key exposure
Minimize the number of places where API keys are stored or transmitted:
- Use environment variables in server-side applications
- Store keys in secure secrets managers (AWS Secrets Manager, HashiCorp Vault)
- Never log API keys in application logs
- Avoid passing keys as URL parameters
- Never expose keys in client-side code (browsers, mobile apps)
Monitor usage
Regularly review your scripts and their activity:
- Check deployment logs for unusual patterns
- Monitor execution frequency and error rates
- Review which scripts are actively using their API keys
- Delete unused scripts to reduce attack surface
Rate limits
API requests are rate-limited per API key to ensure fair usage and system stability:
| Tier | Rate Limit |
|---|---|
| Free | 100 requests/minute |
| Pro | 1,000 requests/minute |
| Enterprise | Custom limits |
Rate limit headers
Rate limit information is included in response headers for every API request:
X-RateLimit-Limit- Maximum requests allowed in the current windowX-RateLimit-Remaining- Requests remaining in the current windowX-RateLimit-Reset- Unix timestamp when the rate limit resets
Rate limit errors
When you exceed your rate limit, the API returns a 429 Too Many Requests response:
The retryAfter field indicates how many seconds to wait before retrying. Implement exponential backoff in your application to handle rate limits gracefully.
Authentication with session tokens
Some operations, particularly when using the web interface, use session tokens instead of script API keys. Session tokens are obtained by logging into the Mirra platform and are used for account-level operations.
When to use session tokens:
- Creating new scripts via the API (to obtain an API key)
- Managing your developer profile
- Accessing marketplace features
- Administrative operations on your account
When to use script API keys:
- Executing deployed scripts
- Calling resource methods
- Automated workflows and integrations
- Production applications
Session tokens typically have shorter expiration times than API keys and are managed automatically by the web interface.
Troubleshooting
401 Unauthorized
Your API key is missing, invalid, or associated with an inactive script.
Common causes:
- Missing
Authorizationheader - Invalid API key format
- Script has been deleted or deactivated
- API key was not copied correctly from creation response
Solutions:
- Verify the header format:
Authorization: Bearer YOUR_KEY - Check that your API key starts with
mirra_script_ormirra_install_ - Ensure the script associated with the key is still active
- If the key is lost, create a new script version to get a new key
Invalid API key format
API keys must meet these requirements:
- Start with
mirra_script_,mirra_install_, ormirra_test_ - Be 64 to 128 characters long after the prefix
- Contain only lowercase letters and hexadecimal characters (a-f, 0-9)
If your API key does not meet these requirements, it may have been truncated or modified. Retrieve the full key from the script creation response.
Missing Authorization header
The API returns a 401 Unauthorized error if the Authorization header is missing:
Ensure every API request includes the header with the correct format:
See also
- Quickstart - Create your first script and get an API key
- Error Codes - Complete error reference
- Scripts - Deploy serverless functions
- Resources - Create API integrations