Typical Response Structure

Successful responses are indicated with a 200-series HTTP code and a JSON-based payload containing the object(s) requested, created, modified, or deleted along with an expression of the server’s interpretation of your request.

If you had issued a successful request you would receive as part of your response a request node echoing back your request.

Example: GET accounts/abcdefg/campaigns?with_deleted=true

{
      /* the data of your response... */,
      "request": {
        "params": {
          "account_id": "abcdefg",
          "with_deleted": "true"
        }
      }
    }

The data field in JSON responses will contain the specific objects associated with the leveraged resource. The format of the data node will be a JSON array when the response may contain one or more results. It will be returned as JSON hash when only one result is possible in response. In some rare cases, you may see a response that would typically include a collection with a hashmap instead. In this case, assume the single hashmap is an object of the same type as specified in the type field.

Error Response Structure

Error responses are served with a non-200-series HTTP code. Usually a JSON response will be attached, but some errors will respond with different kinds of body. In these circumstances where a response structure cannot be parsed, consider the HTTP code’s core meaning to take precedence. For instance, you may occasionally see a HTTP 404 along with a HTML response. In this case, it’s safe to assume that the content cannot be found (HTTP 404 means “Not Found”).

Typical error responses follow a similar structure to successful responses. The nature of the error will be communicated in an errors node of the response. The errors/code node will indicate a CAPS_CASE constant error code you can programmatically consume to make resolution decisions from. The errors/message node will indicate a (usually) human-readable description of the error in English. Additional fields may be attached to indicate finer-grained detail about the error.

    {
      "errors": [
        {
          "parameter": "start_time",
          "details": "invalid date",
          "code": "INVALID_PARAMETER",
          "value": "",
          "message": "Expected time, got \"\" for start_time"
        }
      ],
      "request": {
        "params": {
          "account_id": "hkk5"
        }
      }
    }

In the above example, a request to an analytics endpoint was made with an invalid value for the start_time parameter. The errors/code for requests with invalid parameters is INVALID_PARAMETER.

HTTP CodeError Code
403ACCOUNT_LOCKED_OUT
404ACCOUNT_MEDIA_NOT_FOUND
403ACCOUNT_NOT_FOUND
403ACTION_NOT_ALLOWED
404APP_EVENT_PROVIDER_CONFIGURATION_NOT_FOUND
404APP_EVENT_TAG_NOT_FOUND
404BEHAVIOR_OR_BEHAVIOR_EXPANDED_NOT_FOUND
404CAMPAIGN_NOT_FOUND
408CANCELLED_REQUEST
404CARD_NOT_FOUND
403CURRENT_USER_SUSPENDED
400DUPLICATE_TWEET
400EXCLUSIVE_PARAMETERS
400FEATURE_NOT_AVAILABLE
403FUNDING_INSTRUMENT_ACCESS_NOT_ALLOWED
403FUNDING_INSTRUMENT_EXCEEDS_AVAILABLE_CREDIT_LIMIT
404FUNDING_INSTRUMENT_NOT_FOUND
403GENERIC_TWEET_ERROR
400ILLEGAL_CHARACTERS
400INCLUSIVE_PARAMETERS
500INTERNAL_ERROR
404INVALID_APP_ID
404INVALID_APP_STORE
400INVALID_DENOMINATION
400INVALID_FUNDING_INSTRUMENT
404INVALID_IAB_CATEGORY
404INVALID_ID_ILLEGAL_CHARACTERS
400INVALID_IMAGE
400INVALID_MEDIA
400INVALID_MEDIA_ID
400INVALID_PARAMETER
400INVALID_PLACEMENT_TYPE
400INVALID_TAILORED_AUDIENCE_TYPE
400INVALID_TARGETING_TYPE
400INVALID_TIME_WINDOW
400INVALID_TV_SHOW_LOCATIONS
400INVALID_TWEET
400INVALID_USER
400INVALID_USER_ID
423LOCK_ACQUISITION_TIMEOUT
404LINE_ITEM_APP_NOT_FOUND
404LINE_ITEM_NOT_FOUND
404MACT_APP_NOT_FOUND
403MALWARE_STATUS
404MEDIA_CREATIVE_NOT_FOUND
404MEDIA_NOT_FOUND
405METHOD_NOT_ALLOWED
400MISSING_PARAMETER
404NO_PROVIDER_AVAILABLE_FOR_THIS_CLIENT_APPLICATION
404NOT_FOUND
404PROMOTABLE_USER_NOT_FOUND
404PROMOTED_ACCOUNT_NOT_FOUND
404PROMOTED_TWEET_NOT_FOUND
403READONLY_CLIENT_APPLICATION
400REQUEST_TOO_COMPLEX
404ROUTE_NOT_FOUND
503SERVICE_UNAVAILABLE
503OVER_CAPACITY
400SPEND_EXCEEDS_BUDGET
404TAILORED_AUDIENCE_CHANGE_FILE_NOT_FOUND
404TAILORED_AUDIENCE_NOT_FOUND
404TAILORED_AUDIENCE_OR_TAILORED_AUDIENCE_EXPANDED_NOT_FOUND
404TARGETING_CRITERION_NOT_FOUND
400TOO_MANY_CAMPAIGNS
400TOO_MANY_LINE_ITEMS
429TOO_MANY_REQUESTS
400TV_SHOW_OUTSIDE_MARKET
400TWEET_CANNOT_BE_BLANK
403TWEET_IS_SPAM
404TWEET_NOT_FOUND
429TWEET_RATE_LIMIT_EXCEEDED
401UNAUTHORIZED_ACCESS
403UNAUTHORIZED_CLIENT_APPLICATION
400UNKNOWN_CARD_TYPE
400UNKNOWN_CRITERIA_TYPE
403USER_NOT_FOUND
404WEB_EVENT_TAG_NOT_FOUND