Skip to main content

Create API Token

Generate new API tokens for authentication using the create_api_token() method.

Example

create_api_token() takes an ApiTokenRequest (not a plain dict):
from mira_network import MiraClient, ApiTokenRequest

async def create_token():
    async with MiraClient(api_key="your-api-key") as client:
        new_token = await client.create_api_token(
            ApiTokenRequest(description="Production API Key")
        )
        print(f"New token created: {new_token}")

Response Structure

{
    "id": "7b89fb91-ce54-49d5-b177-68f29cf670fa",  # token id
    "token": "sk-mira-xxxx...",                      # the API key (starts with sk-mira-)
    "description": "Production API Key",
    "meta_data": {},
    "created_at": "2026-01-01T00:00:00.000Z"
}
The full token value is only returned here, at creation time. Copy and store it securely — you can’t retrieve it again later.

Usage Notes

  • The full token is shown only at creation — store it securely.
  • Use a clear description so you can identify the token later.
  • Manage tokens in the Mira Console.