Error Codes

Reference for all API error codes, their meanings, and how to handle them in your application.

Error Response Format

All API errors follow a consistent format:

{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "The request body is missing required fields",
"details": {
"missingFields": ["name", "appStoreAppId"]
}
},
"requestId": "req_abc123"
}

HTTP Status Codes

StatusMeaning
200Success - Request completed successfully
201Created - Resource created successfully
400Bad Request - Invalid request body or parameters
401Unauthorized - Missing or invalid API key
403Forbidden - Insufficient permissions
404Not Found - Resource does not exist
409Conflict - Resource already exists or conflict
422Unprocessable Entity - Validation failed
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Something went wrong

Error Codes

Authentication Errors

CodeDescriptionResolution
MISSING_API_KEYNo API key providedAdd Authorization header with Bearer token
INVALID_API_KEYAPI key is invalid or revokedCheck your API key or create a new one
EXPIRED_API_KEYAPI key has expiredCreate a new API key

Request Errors

CodeDescriptionResolution
INVALID_REQUESTRequest body is malformedCheck JSON syntax and required fields
VALIDATION_ERRORField validation failedCheck error details for invalid fields
RESOURCE_NOT_FOUNDRequested resource not foundVerify the resource ID exists

Rate Limiting Errors

CodeDescriptionResolution
RATE_LIMIT_EXCEEDEDToo many requestsWait and retry with exponential backoff
QUOTA_EXCEEDEDMonthly quota reachedUpgrade your plan or wait for reset

Store Errors

CodeDescriptionResolution
STORE_AUTH_FAILEDStore credentials invalidUpdate your store credentials
STORE_APP_NOT_FOUNDApp not found in storeVerify the app ID and permissions
STORE_SYNC_FAILEDFailed to sync with storeCheck store status and retry

Handling Errors

Here's an example of how to handle errors in your code:

async function makeRequest() {
try {
const response = await fetch('https://api.appstorecopilot.com/v1/projects', {
headers: {
'Authorization': `Bearer ${process.env.ASC_API_KEY}`
}
});
if (!response.ok) {
const error = await response.json();
switch (error.error.code) {
case 'RATE_LIMIT_EXCEEDED':
// Wait and retry with exponential backoff
const retryAfter = response.headers.get('Retry-After') || 60;
await sleep(retryAfter * 1000);
return makeRequest();
case 'INVALID_API_KEY':
throw new Error('Invalid API key. Please check your credentials.');
case 'QUOTA_EXCEEDED':
throw new Error('Monthly quota exceeded. Please upgrade your plan.');
default:
throw new Error(error.error.message);
}
}
return response.json();
} catch (error) {
console.error('API Error:', error);
throw error;
}
}