error response codes - swisscom-api/doc GitHub Wiki

Error Handling

Error Response Schema

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object" ,
  "properties": {
    "uuid": {
      "description": "The UUID of the client software",
      "type": "string",
      "required": false
    },
    "status": {
      "description": "The http status code, e.g. 400",
      "type": "string",
      "required": true
    },
    "code": {
      "description": "The error code, e.g. INVALID_PARAMETER",
      "type": "string",
      "required": true
    },
    "message": {
      "description": "The error message",
      "type": "string",
      "required": true
    },
    "detail": {
      "description": "The error detail",
      "type": "string",
      "required": false
    }
  }
}

Error Response Examples

400 (Bad Request. Invalid request.)

{
  "status": "400",
  "code": "INVALID_REQUEST",
  "message": "The request could not be understood due to malformed syntax. Correct the request syntax and try again.",
  "detail": ""
}

401 (Unauthorized. No permission to resource or invalid api key.)

{
  "status": "401",
  "code": "INVALID_AUTHENTICATION_CREDENTIALS",
  "message": "Authentication credentials missing or incorrect. Check that you are using the correct authentication method and that you have permission to the given resource and your app key is approved.",
  "detail": ""
}

403 (Forbidden. No permission for requested resource.)

{
  "status": "403",
  "code": "FORBIDDEN_RESOURCE",
  "message": "The server understood the request, but is refusing to fulfill it. Check that you have permission to the given resource.",
  "detail": ""
}

404 (Not Found. The server has not found anything matching the Request-URI.)

{
  "status": "404",
  "code": "INVALID_REQUEST_RESOURCE",
  "message": "The requested resource does not exist. Verify that the resource URI is correctly spelled.",
  "detail": ""
}

405 (Method Not Allowed. The resource is not accessible via the given method. For example, the client sent a POST request to a resource that only implements GET.)

{
  "status": "405",
  "code": "INVALID_REQUEST_METHOD",
  "message": "The resource is not accessible via the given method. Check the documentation or the Allow header for allowed methods.",
  "detail": ""
}

406 (Invalid Header Accept. The provided Accept-type is not equal the accepted. E.g. application/zip instead of text/json.)

{
  "status": "406",
  "code": "INVALID_HEADER_ACCEPT",
  "message": "The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request. Make sure the request has an Accept header with a media type supported by the API. Check the developer portal for supported media types.",
  "detail": ""
}

429 (Too Many Requests. Quota for this service has been exhausted. Message must contain further details.)

{
  "status": "429",
  "code": "EXPIRED_QUOTA",
  "message": "Your quota for this service has been exhausted. Try again later or contact support at [email protected].",
  "detail": ""
}

500 (Internal Server Error. Server is misconfigured, or generic error message.)

{
  "status": "500",
  "code": "INTERNAL_SERVER_ERROR",
  "message": "The server encountered an unexpected condition which prevented it from fulfilling the request. Try again later or contact support at [email protected].",
  "detail": ""
}

503 (Service Unavailable. The server is currently unable to handle the request due to temporary overloading or maintenance. Typically back-end is unavailable.)

{
  "status": "503",
  "code": "UNAVAILABLE_SERVICE",
  "message": "The server is currently unable to handle the request due to temporary overloading or maintenance. Try again later or contact support at [email protected].",
  "detail": ""
}