You can also generate these exports in the Langdock UI. See Usage Exports.
Prerequisites
To use the Usage Export API, you need:- Workspace Admin Permission: Only workspace administrators can create API keys with usage export permissions and export data via the web interface.
- API Key with USAGE_EXPORT_API Scope: Special permission for accessing export functions
Programmatic Export
Available Endpoints
The Usage Export API provides access to various data types:The
agents and assistants dataTypes return the same data — agents is an alias. Both paths work identically.Authentication
All API requests require Bearer token authentication:Request Format
Time specification and time zone handling:The API uses the exact time included in the date parameter you provide & treats them as your local times, specified in the timezone parameter. If you include a “Z” at the end of your date (which stands for UTC/Zulu time), it automatically removes it to prevent the timezone from being applied twice.
group_by is optional. Supported values depend on the export type:
| Export | Supported group_by values |
|---|---|
| Users | model |
| Agents / Assistants | model |
| API keys | model |
| Models | source; deployment for BYOK workspaces only |
| Projects | Not supported |
group_by value return a 400 Bad Request.
Response Format
CSV Response
CSV endpoints return a file path and download URL:JSON Response
JSON endpoints return rows directly:Error Response
Example Requests
Export Assistant Usage
Export User Usage
Rate Limits
The Usage Export API is subject to the same rate limits as other API endpoints:- Tokens per Minute: 60,000 Tokens/Min
- Requests per Minute: 500 Requests/Min
Endpoint Details
Troubleshooting
Common Errors
400 Bad Request - Unsupported group_by
group_by value supported by the export type, or omit the field.
401 Unauthorized
404 No Data Found
Security and Privacy
Privacy Settings
Depending on workspace configuration, certain data may be excluded:- User-identifying Data: May be excluded due to privacy settings
- Leaderboards: Must be enabled in the workspace to get complete user data
Best Practices
- Secure API Key Storage: Use environment variables or secure key management
- Regular Rotation: Renew API keys regularly
- Minimal Permissions: Only grant necessary scopes
- Monitoring: Monitor the usage of your API keys
Compliance
The Usage Export API helps with compliance requirements:- Audit Trails: Complete tracking of API usage
- Data Export: Support for GDPR data access rights
- Transparency: Clear insights into workspace usage
Support
For questions about the Usage Export API, contact our support team or consult the complete API documentation.Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on API Key Best Practices.