Authentication overview

AssemblyAI utilizes a straightforward authentication model centered on API keys. An API key acts as a unique identifier and secret token that your application presents with each request to the AssemblyAI API. This mechanism verifies your identity and authorization to access specific API endpoints and resources associated with your account. All interactions with the AssemblyAI API are conducted over HTTPS/TLS, ensuring encrypted communication and protecting your API key and data in transit. The API key is typically included in the Authorization header of HTTP requests as a Bearer token.

The use of API keys is a common practice for authenticating access to web services, offering a balance between simplicity for developers and security for API providers. Best practices for managing these keys are crucial to prevent unauthorized access to your AssemblyAI account and the data processed through its services. Developers should be aware of OAuth 2.0 as another common authentication framework for delegated authorization, often used by APIs requiring more granular permissions or third-party access, as described in the OAuth 2.0 specification.

Supported authentication methods

AssemblyAI primarily supports API key authentication. This method is suitable for most integration scenarios, from server-side applications to development environments. The API key functions as a Bearer token, which means it grants access to whoever possesses it. Therefore, maintaining the confidentiality of your API key is paramount.

The table below summarizes the supported authentication method:

Method When to Use Security Level
API Key (Bearer Token)
  • Server-side applications
  • Backend services
  • Data processing workflows
  • Command-line tools
  • Development and testing environments
  • High, if keys are securely stored and transmitted over HTTPS/TLS.
  • Medium, if keys are exposed in client-side code or public repositories.

For operations that require managing account settings or billing, direct access through the AssemblyAI dashboard is typically secured via email and password, potentially with multi-factor authentication (MFA) enabled. However, API interactions specifically rely on the generated API key.

Getting your credentials

To access the AssemblyAI API, you will need an API key. This key is generated and managed within your AssemblyAI account dashboard. The process generally involves setting up an account and then navigating to a designated section for API key management.

  1. Create an AssemblyAI Account: If you don't already have one, sign up for a free AssemblyAI account on their homepage. The free tier offers 3 hours of transcription per month, which is sufficient for initial testing and development.
  2. Access the Dashboard: Once logged in, navigate to your AssemblyAI user dashboard.
  3. Locate API Key Section: Look for a section related to 'API Settings', 'Developers', or 'Account Settings'. The exact navigation might vary but is typically clearly labeled.
  4. Generate or Retrieve Key: In this section, you should find your existing API key or an option to generate a new one. AssemblyAI typically provides a single primary API key for your account. Copy this key securely.

It is crucial to treat your API key as sensitive information. Avoid hardcoding it directly into your application's source code, especially for public-facing client-side applications or open-source projects. Instead, use environment variables, a secrets management service, or a secure configuration file that is not committed to version control. The AssemblyAI documentation provides specific guidance on obtaining and using your API key within their platform.

Authenticated request example

When making API requests to AssemblyAI, your API key must be included in the Authorization header of your HTTP request. The format for this header is Authorization: Bearer YOUR_API_KEY.

Here's an example of how to make an authenticated request using curl to submit an audio file for transcription:


curl -X POST \ \
  https://api.assemblyai.com/v2/transcript \ \
  -H "Authorization: Bearer YOUR_API_KEY" \ \
  -H "Content-Type: application/json" \ \
  -d '{ "audio_url": "https://storage.googleapis.com/aai-web-samples/nyc.mp3" }'

In this example:

  • YOUR_API_KEY must be replaced with your actual API key obtained from your AssemblyAI dashboard.
  • The -H "Authorization: Bearer YOUR_API_KEY" header is essential for authenticating the request.
  • The Content-Type: application/json header indicates that the request body is in JSON format.
  • The -d flag provides the JSON payload, specifying the audio_url to be transcribed.

SDKs for various languages (e.g., Python, Node.js) handle the inclusion of the API key similarly, abstracting the HTTP header construction. For instance, in Python, you might configure a client object with your API key, and it will automatically add the authorization header to subsequent requests. The AssemblyAI API reference provides detailed code examples for different programming languages and endpoints.

Security best practices

Securing your API keys is critical to prevent unauthorized access to your AssemblyAI account and potential misuse of your transcription services, which could lead to unexpected charges or exposure of sensitive data. Adhering to these best practices helps maintain the integrity and confidentiality of your API interactions:

  1. Never Expose API Keys in Client-Side Code: Do not embed API keys directly into public client-side code (e.g., JavaScript in a web browser, mobile application code that can be reverse-engineered). Malicious actors can easily extract these keys. All API calls using your key should originate from a secure backend server.
  2. Use Environment Variables: Store API keys as environment variables on your server or development machine. This keeps them out of your codebase and version control systems. Most programming languages and frameworks provide mechanisms to access environment variables securely.
  3. Implement a Secrets Management Solution: For production environments, consider using a dedicated secrets management service (e.g., AWS Secrets Manager, Google Secret Manager, Azure Key Vault, HashiCorp Vault). These services centralize, encrypt, and control access to sensitive credentials, offering rotation and auditing capabilities. The AWS Secrets Manager documentation provides an overview of how such services function.
  4. Restrict IP Addresses (where possible): If AssemblyAI supports IP address whitelisting, configure your API key to only accept requests from a predefined set of trusted IP addresses. This adds an extra layer of security, even if a key is compromised.
  5. Rotate API Keys Regularly: Periodically generate new API keys and revoke old ones. This practice limits the window of opportunity for a compromised key to be exploited. Establish a routine for key rotation, perhaps quarterly or annually.
  6. Monitor API Usage: Regularly review your AssemblyAI account for unusual activity or unexpected spikes in usage. This can help detect unauthorized use of your API key early.
  7. Use HTTPS/TLS (Mandatory): Always ensure that all communications with the AssemblyAI API are conducted over HTTPS/TLS. AssemblyAI enforces this by default, encrypting data in transit and protecting your API key from interception. This is a fundamental layer of web security, as outlined in Cloudflare's guide to SSL/TLS.
  8. Implement Least Privilege: While AssemblyAI's API keys typically grant full access to your account's capabilities, if different keys could be generated with varying permissions (e.g., read-only vs. read-write), always use the key with the minimum necessary privileges for a given application.
  9. Secure Your Development Environment: Ensure that your local development environment is secured. Use strong passwords, keep your operating system and software updated, and employ antivirus/anti-malware solutions to prevent key theft from your local machine.
  10. Avoid Logging API Keys: Ensure that your application's logs do not inadvertently capture or store API keys. This prevents exposure if logs are compromised.

By following these guidelines, developers can significantly reduce the risk of unauthorized access and ensure the secure operation of their applications integrated with AssemblyAI.