Expand description
API Key management operations
Provides secure API key management for programmatic access to Files.com. API keys are the recommended authentication method for applications and scripts.
§Features
- Create and revoke API keys
- Set expiration dates
- Configure permission sets
- Track key usage and last access
- Manage keys for specific users
§Security Best Practices
- Store API keys securely (environment variables, secret managers)
- Set expiration dates for temporary access
- Use permission sets to limit key capabilities
- Rotate keys periodically
- Delete unused keys immediately
§Example
use files_sdk::{FilesClient, ApiKeyHandler};
let client = FilesClient::builder()
.api_key("your-api-key")
.build()?;
let handler = ApiKeyHandler::new(client);
// Create a new API key with expiration
let key = handler.create(
Some("Automation Script Key"),
Some("For nightly backup automation"),
Some("2025-12-31T23:59:59Z"),
None
).await?;
// IMPORTANT: Save this key securely - it won't be shown again
println!("New API Key: {}", key.key.unwrap());
println!("Key ID: {}", key.id.unwrap());
// List all API keys
let (keys, _) = handler.list(None, None, Some(50)).await?;
for api_key in keys {
println!("{}: Last used {}",
api_key.name.unwrap_or_default(),
api_key.last_use_at.unwrap_or_default());
}
Structs§
- ApiKey
Entity - API Key entity from Files.com API
- ApiKey
Handler - Handler for API key operations