Error Response Format
All API errors follow a consistent JSON structure:HTTP Status Codes
The API uses standard HTTP status codes to indicate the success or failure of requests.Success Codes (2xx)
Request succeeded. Response body contains the requested data.
Resource successfully created. Response body contains the new resource.
Request succeeded but there’s no response body (e.g., DELETE operations).
Resource hasn’t changed since the last request (when using
If-None-Match with ETags).Client Error Codes (4xx)
The request is malformed or contains invalid data.Common error types:
invalid_input: Invalid request parametersjson_error: Malformed JSON in request bodyxml_error: Malformed XML datavalidation_error: Data failed validation rules
Authentication is required or credentials are invalid.Common error types:Solutions:
unauthorized: Missing or invalid authentication tokenauth_error: Authentication failed
- Include a valid
Authorizationheader - Check that your token hasn’t expired
- Verify your token hasn’t been revoked
You’re authenticated but don’t have permission to perform this action.Common causes:
- Token lacks required scope
- Attempting to modify someone else’s resource
- Attempting a restricted operation
The requested resource doesn’t exist.Common causes:
- Invalid project/version/user ID
- Resource has been deleted
- Typo in the endpoint URL
The request conflicts with the current state of the resource.Common scenarios:
- Duplicate slug or username
- Concurrent modification conflicts
- Resource state prevents the operation
The API version or resource has been permanently removed.Solution: Migrate to a supported API version (v2 or v3).
Server Error Codes (5xx)
An unexpected error occurred on the server.Common error types:What to do:
internal_error: Unexpected server errordatabase_error: Database operation failedsearch_error: Search engine error
- Retry the request after a short delay
- If the error persists, report it to Modrinth support
The API server received an invalid response from an upstream server.Common causes:
- Temporary connectivity issues
- Upstream service degradation
The API is temporarily unavailable.Common causes:
- Scheduled maintenance
- Server overload
- Deployment in progress
The request took too long to process.Common causes:
- Complex search queries
- Large file uploads
- Database slowdowns
- Simplify your query
- Break large requests into smaller chunks
- Retry the request
Common Error Types
Here’s a reference of error type strings returned in theerror field:
Authentication Errors
| Error Type | Status | Description |
|---|---|---|
unauthorized | 401 | Invalid or missing authentication credentials |
auth_error | 401 | Authentication process failed |
invalid_credentials | 401 | Username/password or token is invalid |
invalid_auth_method | 401 | Authentication method not supported |
Input Validation Errors
| Error Type | Status | Description |
|---|---|---|
invalid_input | 400 | Request contains invalid data |
validation_error | 400 | Data failed validation rules |
json_error | 400 | Malformed JSON in request body |
xml_error | 400 | Malformed XML data |
decoding_error | 400 | Failed to decode base62 ID |
Resource Errors
| Error Type | Status | Description |
|---|---|---|
not_found | 404 | Requested resource doesn’t exist |
conflict | 409 | Request conflicts with existing resource |
Rate Limiting
| Error Type | Status | Description |
|---|---|---|
ratelimit_error | 429 | Too many requests, rate limit exceeded |
Server Errors
| Error Type | Status | Description |
|---|---|---|
internal_error | 500 | Unexpected server error |
database_error | 500 | Database operation failed |
redis_database_error | 500 | Redis cache error |
clickhouse_error | 500 | Analytics database error |
search_error | 500 | Search engine error |
file_hosting_error | 500 | File storage error |
mail_error | 500 | Email sending failed |
External Service Errors
| Error Type | Status | Description |
|---|---|---|
payments_error | 424 | Payment processor error |
stripe_error | 424 | Stripe payment processing failed |
discord_error | 424 | Discord integration failed |
turnstile_error | 400 | Cloudflare Turnstile captcha failed |
Error Handling Best Practices
1. Implement Comprehensive Error Handling
2. Use Exponential Backoff for Retries
3. Log Errors for Debugging
4. Provide User-Friendly Error Messages
Debugging Tips
Check Response Headers
Always inspect response headers for debugging information:Verify Your Request
- Check the HTTP method: Ensure you’re using the correct method (GET, POST, etc.)
- Validate the URL: Check for typos in the endpoint path
- Inspect headers: Ensure required headers are present
- Verify request body: Validate JSON syntax and required fields
Test with cURL
Test your requests using cURL to isolate issues:Common Mistakes
Missing User-Agent Header
Missing User-Agent Header
Error:
Unable to obtain user IP address! or blocked requestsSolution: Always include a User-Agent header:Using Slug Instead of ID
Using Slug Instead of ID
Error:
invalid_input or decoding_errorSolution: Some endpoints only accept IDs, not slugs. Check the API documentation for the specific endpoint.Incorrect Authorization Format
Incorrect Authorization Format
Missing Required Scopes
Missing Required Scopes
Error:
unauthorized with message about missing scopeSolution: Create a new token with the required scopes from your account settings.Getting Help
If you’re experiencing issues:- Check the documentation: Verify you’re using the correct endpoint and parameters
- Search existing issues: Look for similar problems on GitHub
- Join the community: Ask questions on Modrinth’s Discord
- Contact support: For persistent issues, email [email protected]
What to Include in Bug Reports
When reporting API issues, include:- Request details: Method, URL, headers (excluding tokens)
- Response: Status code, error message, response headers
- Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Steps to reproduce: Minimal code example
- Environment: Programming language, library versions
Summary
Consistent Format
All errors return
error and description fields in JSON formatStandard Codes
Uses HTTP status codes: 4xx for client errors, 5xx for server errors
Retry Logic
Implement exponential backoff for server errors and rate limits
Helpful Messages
Error descriptions provide actionable guidance for resolution
Next Steps
API Overview
Learn about API basics and common patterns
Authentication
Fix authentication and authorization errors
