Authentication overview

Mindee's API authentication system is designed to secure programmatic access to its document processing services. It ensures that only authorized applications and users can interact with the various APIs, such as the Invoices API, Receipts API, or custom document solutions. The primary method for authentication involves the use of API keys, which serve as unique identifiers and secret tokens for client applications.

When an application sends a request to a Mindee API endpoint, the API key must be included in the request headers. The Mindee server then validates this key against its records to determine if the request is legitimate and if the associated account has the necessary permissions and quota to perform the requested operation. This mechanism is a common industry practice for RESTful API authentication, offering a balance between security and ease of implementation for developers across various programming languages and environments.

Mindee provides SDKs in multiple languages, including Python, Node.js, Java, and Ruby, which abstract the underlying HTTP request details and simplify the process of including the API key in requests. This approach helps developers integrate Mindee's capabilities into their applications efficiently while adhering to security protocols.

Supported authentication methods

Mindee primarily supports API key authentication for accessing its services. This method is suitable for most integration scenarios, from server-side applications to client-side implementations where appropriate security measures are in place.

The API key functions as a bearer token, meaning it grants access to whoever possesses it. Therefore, managing and protecting these keys is crucial for maintaining the security of your Mindee account and the data processed through it. The Mindee developer documentation provides specific instructions on how to use the API key within different contexts and SDKs, ensuring proper integration and secure communication.

Authentication method comparison

Method When to Use Security Level
API Key (Header) Server-side applications, backend services, development environments. Medium to High (when securely stored and transmitted over HTTPS).
API Key (SDKs) Applications using Mindee's official SDKs for simplified integration. Medium to High (SDKs handle header inclusion, but key storage is developer responsibility).

While API keys are the primary method, it's important to understand that the underlying communication channel is secured using Transport Layer Security (TLS), commonly known as HTTPS. This encryption protocol protects data in transit between your application and Mindee's servers, preventing eavesdropping and tampering. The IETF's RFC 8446 details the current version of the TLS protocol, ensuring robust cryptographic protection for internet communications.

Getting your credentials

To access Mindee's APIs, you need to obtain an API key from your Mindee account. This key is unique to your account and acts as your authorization token for all API requests. The process typically involves a few steps:

  1. Create a Mindee Account: If you don't already have one, register for a Mindee account on their official website. Mindee offers a free tier for 50 documents/month, which is useful for testing and initial development.
  2. Access Your Dashboard: Log in to your Mindee account dashboard.
  3. Navigate to API Keys Section: Within the dashboard, there will be a dedicated section for managing your API keys. The exact location might vary but is typically found under 'API Keys', 'Settings', or 'Developer' sections.
  4. Generate a New API Key: Follow the instructions to generate a new API key. Mindee may allow you to create multiple keys for different applications or environments, which is a recommended security practice for key rotation and revocation.
  5. Securely Store Your Key: Once generated, copy your API key and store it securely. Treat it like a password; do not hardcode it directly into your source code, commit it to version control, or expose it in client-side code.

For detailed, up-to-date instructions on generating and managing your API keys, always refer to the official Mindee API reference documentation.

Authenticated request example

Mindee provides SDKs in several languages to simplify API interaction. Here's an example using the Python SDK to send a document for processing, demonstrating how the API key is typically handled.

import os
from mindee import Client, product

# Initialize a Mindee client
# The API key is usually loaded from an environment variable for security
mindee_client = Client(api_key=os.environ.get("MINDEE_API_KEY"))

# Load a document from a path (replace with your document path)
input_doc = mindee_client.doc_from_path("path/to/your/invoice.pdf")

# Parse the document using the Invoice API
# The API key is automatically included in the request headers by the SDK
result = mindee_client.parse(product.InvoiceV4, input_doc)

# Print a summary of the parsed document
print(result.document.inference.prediction.orientation.value)
print(result.document.inference.prediction.total_amount.value)

In this Python example, the API key is retrieved from an environment variable MINDEE_API_KEY. This is a common and recommended practice to prevent exposing sensitive credentials directly in the codebase. The mindee_client then uses this key internally for all subsequent API calls, automatically adding it to the Authorization header as a Bearer token.

For Node.js, a similar pattern applies:

const { Client, products } = require("mindee");

// Initialize a Mindee client with the API key from environment variables
const mindeeClient = new Client({ apiKey: process.env.MINDEE_API_KEY });

// Load a document from a file path
const inputDoc = mindeeClient.docFromFile("path/to/your/receipt.jpg");

// Parse the document using the Receipt API
mindeeClient
  .parse(products.ReceiptV5, inputDoc)
  .then((response) => {
    // Handle the parsed response
    console.log(response.document.inference.prediction.totalAmount.value);
  })
  .catch((error) => {
    console.error("Error parsing document:", error);
  });

These examples illustrate how the SDKs abstract the HTTP request details, allowing developers to focus on document processing rather than low-level authentication mechanics. For direct HTTP requests without an SDK, the API key would typically be included in the Authorization header with the format Authorization: Bearer YOUR_API_KEY.

Security best practices

Securing your API keys and ensuring the integrity of your interactions with Mindee's APIs is paramount. Adhering to these best practices helps protect your data and prevent unauthorized access to your account:

  • Environment Variables for API Keys: Never hardcode API keys directly into your application's source code. Instead, store them in environment variables, configuration files that are not committed to version control, or secure secret management services. This prevents accidental exposure in public repositories.
  • Restrict API Key Scopes (If Available): If Mindee offers the ability to create API keys with specific permissions or scopes, always generate keys with the minimum necessary privileges for the task at hand. This limits the damage if a key is compromised.
  • Key Rotation: Regularly rotate your API keys. This means generating new keys and deactivating old ones. The frequency of rotation depends on your organization's security policies and risk assessment.
  • IP Whitelisting (If Available): If Mindee supports IP whitelisting for API keys, configure it to allow API calls only from known and trusted IP addresses or ranges. This adds an extra layer of security by restricting where your API key can be used.
  • Monitor API Usage: Regularly monitor your API usage logs for any unusual activity or spikes that could indicate unauthorized access or abuse of your API key.
  • HTTPS/TLS Enforcement: Always ensure that all communications with Mindee's API endpoints are conducted over HTTPS (TLS). Mindee enforces HTTPS, but it's crucial for your client applications to also use secure connections to prevent man-in-the-middle attacks. The Cloudflare learning center on SSL/TLS provides further details on this critical security protocol.
  • Error Handling: Implement robust error handling in your application to gracefully manage authentication failures without exposing sensitive information.
  • Secure Development Lifecycle: Integrate security considerations throughout your development lifecycle, from design to deployment. This includes code reviews, security testing, and adherence to secure coding guidelines.
  • Revoke Compromised Keys Immediately: If you suspect an API key has been compromised, revoke it immediately from your Mindee dashboard and generate a new one.

By implementing these practices, developers can significantly enhance the security posture of their applications integrating with Mindee's document processing APIs.