Authentication overview

Sheetsu provides a service to transform Google Sheets into a RESTful API, enabling developers to perform CRUD (Create, Read, Update, Delete) operations on spreadsheet data programmatically. Authentication for Sheetsu APIs is managed through the use of API keys. Each API key is a unique token that identifies the requesting application or user and grants access to specific Sheetsu endpoints linked to your Google Sheet. These keys are fundamental for securing your data and ensuring that only authorized requests can interact with your API. The API key acts as a form of bearer token, requiring its inclusion with every API request to authorize access to your Sheetsu endpoints, as detailed in the Sheetsu API documentation. Without a valid API key, requests to Sheetsu endpoints are rejected with an authorization error, protecting the integrity of your spreadsheet data.

The authentication model is straightforward, designed to facilitate rapid prototyping and quick integration. Developers are responsible for safeguarding their API keys, as their compromise could lead to unauthorized data access or modification. Sheetsu's model focuses on simplicity and direct access control, making it suitable for applications where managing complex authentication flows like OAuth 2.0 is not necessary. For more complex scenarios or highly sensitive data, additional layers of security beyond API keys, such as network access restrictions or IP whitelisting, may be considered if supported by the infrastructure surrounding your Sheetsu implementation.

Supported authentication methods

Sheetsu primarily supports authentication via a secret API key. This method involves generating a unique key from your Sheetsu dashboard and including it in the headers of your HTTP requests. This simple approach is effective for applications where control over the API key is maintained, such as server-side applications or tools with restricted access. The API key serves as the primary credential for all API interactions.

The table below summarizes the key authentication method supported by Sheetsu, outlining its typical use cases and general security implications. This information helps developers choose the appropriate method for their specific application requirements.

Method When to Use Security Level
API Key (Header) Server-side applications, internal tools, rapid prototyping, scenarios where key can be kept secret. Moderate (Dependent on key secrecy and management practices).

While API keys offer a convenient way to authenticate, their security level is directly tied to how well they are protected. Unlike OAuth 2.0 tokens, which often have scopes and expiration times, Sheetsu API keys typically grant full access to the linked Google Sheet data and remain valid until revoked. This makes their secure handling paramount. Developers should consider the environment in which their application will operate and choose authentication methods that align with the security requirements of their data and users.

Getting your credentials

To obtain your API key for Sheetsu, you must first have an active Sheetsu account and a Sheetsu API endpoint connected to a Google Sheet. The process generally involves the following steps:

  1. Create a Sheetsu Account: If you don't already have one, sign up for a Sheetsu account on their official website. There is a free tier available for initial testing.
  2. Connect a Google Sheet: Navigate to your Sheetsu dashboard and create a new API endpoint by linking a Google Sheet. This involves providing the URL of your Google Sheet and configuring access permissions.
  3. Generate the API Key: Once your API endpoint is set up, Sheetsu automatically generates an API key associated with that endpoint. You can find this key within the settings or details page for your specific API in the Sheetsu dashboard. The key is typically displayed prominently and can be copied for use in your applications.
  4. Record and Secure the Key: It is crucial to immediately record your API key and store it securely. Treat it like a password. Sheetsu API keys are typically long alphanumeric strings designed to be difficult to guess. For security reasons, Sheetsu usually only displays the full key once upon generation; subsequent views might be redacted or require regeneration, emphasizing the importance of initial secure storage.

Sheetsu does not typically provide a mechanism for individual user authentication within the API itself; rather, the API key authenticates the application or service making the request. Therefore, if you are building an application that requires user-specific authentication and authorization, you would need to implement that logic within your application layer, managing user sessions and permissions before making requests to your Sheetsu API with your main API key. The Sheetsu API key becomes the trusted credential your backend uses to interact with the Google Sheet.

Authenticated request example

When making requests to your Sheetsu API, the API key must be included in the HTTP headers. The standard header for Sheetsu API keys is X-Api-Key. Below is an example of a GET request using cURL to fetch data from a Sheetsu endpoint, demonstrating how to include the API key.

Before executing this example, replace YOUR_API_URL with the actual URL of your Sheetsu API endpoint (e.g., https://sheetsu.com/apis/v1.0/your-api-id) and YOUR_API_KEY with the API key you obtained from your Sheetsu dashboard.

curl -X GET \
  'YOUR_API_URL' \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: YOUR_API_KEY'

This cURL command sends a HTTP GET request, instructing the server to expect JSON in response via the Accept header, and authenticating the request using the X-Api-Key header. For POST, PUT, or DELETE requests, the method changes, and a request body (often JSON) would be included, but the authentication header remains the same. For instance, a POST request to add data might look like this:

curl -X POST \
  'YOUR_API_URL' \
  -H 'Content-Type: application/json' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -d '{ "name": "John Doe", "email": "[email protected]" }'

In client-side JavaScript (e.g., using fetch API), the implementation would be similar:

const apiUrl = 'YOUR_API_URL';
const apiKey = 'YOUR_API_KEY';

fetch(apiUrl, {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'X-Api-Key': apiKey
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error fetching data:', error));

It's important to note that embedding API keys directly in client-side code (like in the JavaScript example) for public-facing applications is generally not recommended due to the risk of exposure. For client-side applications, it is often more secure to route API requests through a backend proxy that can securely inject the API key, preventing it from being exposed in the client's browser or application bundle. This approach maintains the secrecy of your API key even for user-facing applications.

Security best practices

Securing your Sheetsu API keys is critical to protect your Google Sheet data from unauthorized access and manipulation. Adhering to established security practices can significantly mitigate risks:

  • Keep API Keys Confidential: Treat your Sheetsu API key like a password. Never hardcode it directly into client-side code (e.g., JavaScript running in a browser or mobile apps) or commit it to public version control systems like GitHub. If an API key is exposed, it could grant unauthorized parties full access to your Sheetsu-connected Google Sheet.
  • Use Environment Variables: For server-side applications, store API keys in environment variables rather than directly in your codebase. This prevents the key from being exposed if your code repository is compromised and allows for easier rotation and management across different deployment environments.
  • Implement a Backend Proxy: If your frontend application needs to interact with Sheetsu, route all requests through a secure backend proxy. The backend server can then securely add the API key to the request headers before forwarding it to Sheetsu, ensuring the key is never exposed to the client. This is a standard practice for protecting sensitive credentials in web applications.
  • Restrict Access to Dashboard: Limit access to your Sheetsu dashboard, where API keys are generated and managed, to only necessary personnel. Use strong, unique passwords for your Sheetsu account and enable multi-factor authentication if available.
  • Regularly Rotate Keys: Periodically generate new API keys and revoke old ones. This practice minimizes the window of opportunity for a compromised key to be exploited. While Sheetsu does not offer automatic key rotation, manual rotation should be part of your security routine, especially after any security incidents or team member changes.
  • Monitor API Usage: Keep an eye on your Sheetsu API usage patterns. Unusual spikes or activity might indicate a compromised key or unauthorized access. While Sheetsu's dashboard offers basic usage metrics (as mentioned in their official documentation), integrating with external monitoring tools can provide more granular insights and alerting capabilities.
  • Secure Your Google Sheet: Remember that Sheetsu exposes your Google Sheet. Ensure the underlying Google Sheet itself has appropriate sharing settings. While Sheetsu controls access to its API, the ultimate data source remains your Google Sheet. Avoid making highly sensitive data publicly accessible via the Google Sheet's own sharing controls.
  • Use HTTPS for All Communications: Always ensure that all communication with Sheetsu APIs occurs over HTTPS (TLS/SSL). This encrypts data in transit, protecting your API key and data payload from eavesdropping and man-in-the-middle attacks. Sheetsu endpoints are inherently served over HTTPS. This is a fundamental security practice for any web service interaction, as reinforced by general web security guidelines from organizations like the Mozilla Developer Network on secure contexts.

By following these best practices, developers can maintain a higher level of security for applications powered by Sheetsu, safeguarding data integrity and preventing unauthorized access to the underlying Google Sheet.