Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Ship X API is the main interface for exchanging data with the central system. 

Access to data is protected, authorization mechanism is based on OAuth 2.0 standard.

Requests are authenticate by Bearer token. API is stateless interface.

HTTP Status codes

List of HTTP status codes which may occurs in response:

HTTP status codeDescription
200 OKSuccessful request.
201 CREATEDNew resource is created.
204 NO CONTENTServer successfully processed the request, and is not returning any content.
400 BAD REQUESTServer cannot process the request. More info in response.
401 UNAUTHORIZEDProper authorization is required to access this resource.
403 FORBIDDENAccess to the requested resource is forbidden
404 NOT FOUNDResource is not found.
500 SERVER ERRORThe server  failed to fulfil a request

Errors

If error occurs, API will return object with following attributes:

AttributeTypOpis
statusIntegerHTTP status code
errorStringError key
messageString

Easy to understand description of error.

It may change - do not base on it in your code.

detailsObjectDetails of the error which occurred.

Response example

HTTP/1.1 404 Not Found
 
{
	"status": 404,
	"error": "resource_not_found",
	"message": "Resource you are looking for are not found",
	"details: {}
} 

In POST or PUT query - validation errors may occur. Details about them are placed in "details" attribute.

HTTP/1.1 400 Bad Request
 
{
	"status": 400,
	"error": "validation_failed",
	"message": "Data sent by POST or PUT request are not valid. Check details for more info",
	"details: {
		"name": ["required", "too_short"],
		"post_code": ["invalid_format"]
	}
} 

(warning) Names of attributes with validation errors are keys for details object. Their value is a table with error keys which occured. Error keys are described below.

Error Keys

The table below shows the error keys that may occurs with possible HTTP codes.

Error keyHTTP CodeDescription
resource_not_found404The resource you are looking for was not found
validation_failed400

There were validation errors when sending data via POST or PUT. More info in "details".

unauthorized401

Access to the resource is impossible due to lack of or incorrect access token. 

access_forbidden403

Access to the specified resource is denied due to lack of or incorrect permissions.

Validation error keys

The table below shows the validation error keys that may occurs in details attribute if validation is failed.

Error keyDescription
requiredValue is required.
invalidValue is invalid, more info in resource documentation.
too_shortValue is too short, more info in resource documentation.
too_longValue is too long.
too_smallValue is too small, it concerns to numerical value. 
too_bigValue is too big, it concerns to numerical value.  
invalid_format

Given value has an invalid format, e.g word in phone number field.

Besides to the above errors, there may be others, for specific resources. More details in documentation specific to these resources.

  • No labels