VantageKitVantageKit Docs

Error Handling

API error codes, HTTP status mappings, and how to handle each error type.

Error response format

When a request fails, the API returns a JSON error body:

{
  "error": "Deal room not found",
  "code": "not_found",
  "details": {}
}
  • error — Human-readable error message (safe to display to users)
  • code — Machine-readable error code (use this for programmatic handling)
  • details — Optional structured data with additional context

Error codes

Client errors (4xx)

CodeHTTP StatusDescriptionWhat to do
bad_request400Generic bad requestCheck your request format
validation_error400Invalid query parametersCheck details for specific field errors
unauthorized401Missing or invalid API keyVerify your API key is correct and not revoked
payment_required402Plan doesn't include API accessUpgrade to the Scale plan
forbidden403Insufficient permissionsCheck your API key scopes
not_found404Resource doesn't existVerify the deal room ID exists and belongs to your team
conflict409Resource conflictThe resource already exists or has a duplicate identifier
gone410Resource expired or removedThe resource is no longer available
payload_too_large413Request body too largeReduce the payload size
unsupported_media_type415Invalid content typeUse application/json
rate_limit429Too many requestsWait and retry — see Rate Limiting

Server errors (5xx)

CodeHTTP StatusDescriptionWhat to do
internal_error500Unexpected server errorRetry after a short delay. If persistent, contact support.
not_implemented501Feature not available yetThis endpoint is planned but not yet released
bad_gateway502External service errorRetry after a short delay
service_unavailable503Temporarily unavailableRetry with exponential backoff

Handling errors in code

Node.js
const response = await fetch('https://api.vantagekit.com/v1/deal-rooms/invalid-id', {
  headers: { 'Authorization': `Bearer ${apiKey}` },
})

if (!response.ok) {
  const { error, code, details } = await response.json()

  switch (code) {
    case 'unauthorized':
      // Re-authenticate or check API key
      break
    case 'rate_limit':
      // Wait for Retry-After header and retry
      const retryAfter = response.headers.get('Retry-After')
      await new Promise(r => setTimeout(r, Number(retryAfter) * 1000))
      break
    case 'not_found':
      // Resource doesn't exist
      break
    default:
      console.error(`API error: ${code} — ${error}`)
  }
}
Python
response = requests.get(
    f'https://api.vantagekit.com/v1/deal-rooms/{deal_room_id}',
    headers={'Authorization': f'Bearer {api_key}'},
)

if response.status_code == 429:
    retry_after = int(response.headers.get('Retry-After', 60))
    time.sleep(retry_after)
elif response.status_code >= 400:
    body = response.json()
    raise Exception(f"API error {body['code']}: {body['error']}")

On this page