Skip to main content

Errors

When working with Topsort’s APIs, you may encounter various error responses. This comprehensive guide helps you understand, diagnose, and resolve common issues.

Quick Navigation

How Errors Work

Topsort APIs return errors as JSON arrays containing error objects with these fields:
FieldTypeDescription
errCodestringA short string uniquely identifying the problem.
docUrlstringA link to this documentation providing more information about the error.
messagestringOptional. If present, human-readable explanation of or details about the error. The string for a given error may change over time; code should not parse or dispatch based on particular values for this field.

Error Codes and Meanings

The following table shows HTTP status codes you’ll encounter and what they mean:
CodeDescriptionDetails
400Bad RequestUnacceptable request, i.e. Incorrect formatting
403Forbidden/UnauthorizedAPI key issue or missing tokens
404Not FoundThe server cannot find the requested resource. Either the request URL is not on our routes, or the resource is not available (ie. the requested campaign does not exist)
422Unprocessable EntityMismatched request body and model, i.e, you are missing a property, or API is expecting a date but received a number
429Rate Limit ExceededIP-based rate limit reached. This error comes with following headers:
- X-RateLimit-Limit: total number of requests allowed for the time period
- X-RateLimit-Remaining: remaining number of requests for the time period
- X-RateLimit-Reset: when you can make another request

Error Codes

Error CodeDescription
bad_requestRequest couldn’t be parsed; check the OpenAPI specification for the correct schema.
empty_requestRequest is empty; check the OpenAPI specification for the correct schema.
internal_server_errorUnexpected server problem; our team typically fixes these issues quickly.
invalid_api_keyMissing, invalid, or expired API key; see authentication for details.
invalid_auction_idAuction ID doesn’t correspond to an auction; ensure a valid auction ID is passed in the request.
invalid_event_typeEvent type must be “Impression”, “Click”, or “Purchase”.
invalid_promotion_typeInvalid promotion types in slots field.
invalid_sessionsession object must contain a non-empty sessionId.
missing_auctionsAt least one auction must be specified.
missing_contextRequired context missing; specify a category, product list, or search query.
missing_placementRequired placement or placement.page field is missing.
missing_product_idproductId missing.
missing_promotion_typeAn auction must request slots for at least one promotion type.
missing_purchased_atRequired purchasedAt field missing.
missing_sessionRequired session field missing.
missing_slot_idRequired slotId field missing.
missing_slotsRequired slots field missing.
no_productsAt least one product must be specified.
no_purchase_itemsAt least one item must be purchased.
purchase_item_quantity_less_or_equal_than_zeroA purchase item has a quantity of less than or equal to zero.
resolved_bid_id_not_foundProvided resolved bid ID doesn’t match an internal record.
too_few_impressionsAt least one impression must be included.
too_few_slotsAt least one slot must be specified in an auction.
too_many_auctionsMaximum of 5 auctions can run in parallel; contact your KAM to increase this limit.

Debugging Tips

Getting More Error Details

Some endpoints return detailed validation errors:
{
  "error": "validation_error",
  "message": "Invalid request body",
  "details": [
    {
      "field": "events[0].productId",
      "message": "Product 'sku_999' not found in catalog"
    },
    {
      "field": "events[0].occurredAt", 
      "message": "Timestamp cannot be in the future"
    }
  ]
}

Common Integration Issues

Events returning 200 but not appearing in dashboard:
  • Check occurredAt is within last 30 days
  • Verify product exists in catalog
  • Confirm event type is spelled correctly (click, not Click)
Auctions returning empty results:
Budget exhaustion is the #1 cause of empty auctions. Before debugging complex auction issues, first check that your campaigns have sufficient daily budget and account balance. Campaigns with zero budget cannot participate in auctions.
  • Verify active campaigns exist
  • Check campaign has budget remaining (most common issue)
  • Verify account balance is positive
  • Confirm products are in stock and active
  • Check bid amounts aren’t too low
Attribution not working:

Using Developer Logs for Debugging

Check the Dev Tools tab in your Ad Platform for detailed API request/response logs. See our Developer Logs guide for help interpreting log entries and common error patterns.

Handling rate limiting

Our endpoints - except making calls to /auctions or /events - are rate-limited to prevent abuse. If you exceed the rate limit, you will receive a 429 error response. There are two recommended ways to handle these limits

Retry with exponential back-off

Exponential backoff retry is a technique used in programming to retry an operation with increasing intervals between retries, which helps to mitigate issues such as network latency, temporary failures, or resource constraints. Below there is a code example in Python on how the technique can be implemented.
def exponential_backoff_retry(url, max_retries=5, base_delay=1, max_delay=64, retry_on_status=429):
    retries = 0
    delay = base_delay
    while retries < max_retries:
        try:
            response = requests.get(url)
            if response.status_code == retry_on_status:
                print(f"Received status code {retry_on_status}, retrying...")
                retries += 1
                if retries < max_retries:
                    print(f"Retrying in {delay} seconds...")
                    time.sleep(delay)
                    delay = min(delay * 2, max_delay)
                else:
                    raise Exception(f"All retries exhausted for status code {retry_on_status}")
            else:
                response.raise_for_status()  # Raise an exception for HTTP errors other than the specified one
                return response.json()  # Assuming the response is JSON, adjust as needed
        except Exception as e:
            print(f"Attempt {retries + 1}/{max_retries} failed: {e}")
            retries += 1
            if retries < max_retries:
                print(f"Retrying in {delay} seconds...")
                time.sleep(delay)
                delay = min(delay * 2, max_delay)
            else:
                raise

Use Retry-After

Use the values in the headers to determine when you can make another request:
  • X-RateLimit-Limit: how many requests you have made during the time period
  • X-RateLimit-Remaining: remaining request during the time period
  • X-RateLimit-Reset: when you can make another request
If you have distributed services hitting the resource, you can still get 429, even if you waited the time amount specified in X-RateLimit-Reset. If you are hitting this problem, you may want to either replace this technique with the Exponential back-off or use them together, that is, first waiting the amount of time given by X-RateLimit-Reset and then fall-back to exponential back-off retries.

Connection and Network Issues

Connection Refused/Timeout Errors

Symptoms:
  • Connection refused or Connection timeout errors
  • Requests hanging indefinitely
  • Intermittent connectivity issues
Common Causes & Solutions:

Network Connectivity

  • Check internet connection and DNS resolution
  • Test with curl: curl -I https://api.topsort.com
  • Verify API endpoint URLs are correct

Firewall/Proxy Issues

  • Whitelist Topsort domains:
    • api.topsort.com
    • *.topsort.com
  • Allow outbound HTTPS (port 443) traffic
  • Configure proxy settings if your network requires them

SSL/TLS Certificate Problems

  • Update your HTTP client to support modern TLS versions
  • Check certificate validation - ensure your system trusts standard CAs
  • Test with OpenSSL: openssl s_client -connect api.topsort.com:443

Request Timeout Issues

Solutions:
  • Increase timeout values in your HTTP client
  • Implement retry logic with exponential backoff
  • Check for large request payloads that might exceed limits
# Example: Proper timeout and retry configuration
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

def create_topsort_session():
    session = requests.Session()
    
    # Retry strategy
    retry_strategy = Retry(
        total=3,
        backoff_factor=1,
        status_forcelist=[429, 500, 502, 503, 504],
    )
    
    # Mount adapter with retry strategy
    adapter = HTTPAdapter(max_retries=retry_strategy)
    session.mount("https://", adapter)
    
    # Set reasonable timeouts
    session.timeout = (10, 30)  # (connect, read)
    
    return session

Regional Connectivity Issues

If you’re experiencing connectivity issues from specific regions:
  • Test from different locations to isolate regional problems
  • Use a CDN or proxy service if needed for your region
  • Contact support with your location details for assistance

Basic Connectivity Test

Test basic connectivity to Topsort’s API:
# Test if you can reach the API domain
curl -I https://api.topsort.com

# Or test with a simple API call (requires API key)
curl -X GET "https://api.topsort.com/v2/auctions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Troubleshooting Checklist

When experiencing connection issues:
  1. Test basic connectivity: Can you reach api.topsort.com?
  2. Check firewall rules: Are outbound HTTPS requests allowed?
  3. Verify API endpoint: Are you using the correct URL?
  4. Test with minimal request: Does a simple connectivity test work?
  5. Check our status page: topsort.statuspage.io
  6. Review proxy settings: Are corporate proxies interfering?
  7. Update TLS support: Is your client using modern TLS versions?

Need More Help?

If you’re still experiencing issues after consulting this guide:
  • Check our status page at topsort.statuspage.io for service updates
  • Contact support with your error details and API request for faster resolution
  • Review our API documentation for endpoint-specific requirements and examples
Last updated: