Error Code Reference
REST ad requests (/request) return one of the following codes in the code field of the response body.
If authentication fails, the API returns HTTP
401. See HTTP Status Codes.
- The
msgfield contains the constant name shown above, not a human-readable message. Handle errors based on thecodevalue. - REST ad requests do not return
4000(ERROR_CODE_INVALID_UNIT) or4001(ERROR_CODE_AD_INACTIVE). An invalid ad unit ID or an ad unit without active campaigns also returns4002.
Detailed Error Descriptions
ERROR_CODE_AD_NO_FILL (4002)
Cause: No ad can be served for the request. Common causes include:- The ad unit ID is incorrect, or it belongs to a different app than the App Key
- The ad unit is not a banner or native ad unit
- There are no active ad campaigns for the ad unit
- The request does not match the campaigns’ targeting, including context targeting (
contextId)
- Verify that the ad unit ID is correct and belongs to the same app as the App Key, and that no whitespace or special characters were included when copying
- Check that the ad unit is a banner or native ad unit
- Verify campaigns are running in the console, and check the campaign schedule (start/end dates) and budget
- Check that
contextIdexactly matches a Context ID entered in the console - Check if targeting settings are too restrictive
- Implement retry logic (exponential backoff recommended)
- Prepare fallback content
ERROR_CODE_INVALID_PARAMS (4003)
Cause: The requiredunit parameter is missing or empty.
Solutions:
- Verify the required parameter (
unit) is included and has a value - Ensure there are no typos in the parameter name
Error Handling Best Practices
1. Handle Errors Based on Code
2. Prepare Fallback Content
3. Monitoring and Logging
HTTP Status Codes
The REST API also returns standard HTTP status codes.Related Documentation
REST API Overview
Basic API usage
Targeting Settings
Configure targeting parameters