HomeGuidesRecipesAPI ReferenceChangelog
Log In
API Reference

When a response comes back, there are two pieces of information to consider:

  • HTTP Status code - this tells you at a protocol level what the status of the response is.
  • Response Payload - this is the body of the response. It is in a standard format that will give you the application level status, the results, and if applicable, any errors.

Response Formats

All responses are returned using JSON. JSON is a lightweight serialization language that is compatible with many different languages. JSON is syntactically correct JavaScript code, meaning you can use the Javascript eval() function to parse it.

HTTP Status Codes

Our REST API uses standard HTTP status codes to indicate the success or failure of API calls. Like with most topics, Wikipedia has good resources on HTTP Statuses, but here are the basics of what we will return:

HTTP CodeMessageDescription
200OKThe request was processed and returned successfully. Nothing was changed.
201CreatedThe new resource was created successfully
400Bad RequestProblem with the request, such as a missing, invalid, or type mismatched parameter
401UnauthorizedThe request did not have valid authorization credentials
403ForbiddenPrivate data you are not allowed to access, or you've hit a rate limit.
404Not FoundYour URL is wrong, or the requested resource doesn't exist
500Server ErrorWe call this the "crap code" error. We've got a problem handling the request on our side. If this persists, please contact support. We log and review all errors but your help often helps us fix it quicker.
503Service UnavailableOur API is down. Please try again. We work hard to make this rare.

The non-20x status codes above correspond with an error of one type or another. Below we detail the error responses.

Response Payload

Each API response is wrapped in a standard payload that contains the results of the API call, plus some additional useful information and metadata, such as the total count of records and the type of the result object. Here's an example of a response:

{
  "status": "success",
  "count": 2,
  "type": "LoadServingEntity",
  "results":[ {
    "lseId": 2756,
    "name":"Georgia Power Co",
    "code":"7140",
    "websiteHome":"http://www.georgiapower.com/"
  }, {
    "lseId":1,
    "name":"City of Augusta",
    "code":"1000",
    "websiteHome":null
  }]
}

The above shows a successful call response. In this case, the result type is LoadServingEntity and there are two results. Note that the results are always an array even if you only requested one object.

NameTypeDescription
statusStringPossible values are: success and error
countIntegerTotal count of records that match your request. Because of pagination, this is not necessarily the number of records in the response
typeStringResource (sometimes called the Object) type
resultsObject[]This contains the actual results, i.e. the object or objects that you requested.

The count property tells you how many items matched the search criteria of your request. Note that we currently limit the count property to a maximum of 100,000. You should interpret a count of 100,000 as "100,000 or more". Use the count property in conjunction with Pagination Request parameters.

Response Payload Changes

From time to time, we may add to the set of fields that are returned from a particular endpoint in the API. In general, these new fields will only appear if you specify that the API should return the extended set of fields. However, API clients should always be prepared to handle (i.e. ignore) any new object properties that they do not recognize.

Errors

Errors are communicated to the client in the payload of the response.

Errors in the Response Payload

The standard response payload can contain errors. This will give more finely-grained details about what specifically caused the error or errors, which should allow you to respond appropriately. This might include displaying validation messages to your users or changing the request at runtime.

{
  "status":"error",
  "count":2,
  "type":"Error",
  "results":[{
    "code":"NotNull",
    "message":"An appKey must be supplied",
    "objectName":"requestSignature",
    "propertyName":"appKey"
  }, {
    "code":"NotNull",
    "message":"An appId must be supplied",
    "objectName":"requestSignature",
    "propertyName":"appId"
  }]
}

Error Type Definition

The type Error has the following data definition:

NameTypeDescription
codeStringError code. Unique string identifying the type of error. See the table below for a list of possible error codes. (Always returned)
messageStringLocalized user-readable message describing the error. (Conditionally returned)
objectNameStringIdentifies the type of object that the error is related to. This is typically a resource type that is part of the response. For example, the Tariff object. (Conditionally returned)
propertyNameStringIdentifies the property of the object that the error is related to. Primarily for binding and validation errors but sometimes used for business logic errors too. For example, the tariffId or lseId. (Conditionally returned)

List of Error Codes

The code in the Error can be any of the following:

NameDescription
ObjectNotFoundTypically this is when the item id you passed in was not found. For example, passing in a non-existent masterTariffId.
NotNullA required object was not passed in on the request. Check the objectName and propertyName for more information.
InvalidArgumentAn argument passed in did not meet validation requirements. This may or may not be related to the request parameters passed in.
InvalidStateThe current state of the object in question prevents the requested action from being performed.
TypeMismatchAn argument was not of the expected type. This may or may not be related to the request parameters passed in.
MissingIdAn ID (usually a masterTariffId) is required to process the request but none was supplied.
DataIntegrityViolationExceptionThe data sent in was not valid. You may see this error when trying to overwrite a value that cannot be overwritten.
InvalidFileFormatThe file format sent in was invalid.
InvalidErrorThe supplied value is not valid.
ObjectCannotBeSavedThere was an error saving the object.
InsufficientPermissionsThe supplied credentials do not have permission to access this resource.
SystemErrorUnexpected exception.
UniquenessViolationErrorYou can only have one object with this ID. Usually seen when trying to create a new object with a providerAccountId or providerProfileId that already exists.
InvalidDateRangeThe date range is not valid. Usually caused by a fromDateTime being after a toDateTime.