/
Core Concepts

Core Concepts


Getting Started with the BBA API is simple. Jump right into the Core concepts below to learn more about its technical implementation. Explore the Technical reference section to know how to make the most of the wide range of resources available. Have a question? Contact our Support Team, we  are here for you. We have your back.

Authentication

To use BBA APIs you need to follow an authentication process. Currently, BBA supports OAuth 2 protocol for authentication and authorization. OAuth 2 framework allows applications to obtain limited access to user accounts on an HTTP service. It delegates user authentication to the service that hosts the user account, and authorizes a third-party application to access the user account.

For a detailed explanation on how to implement this protocol, please visit the Official OAuth 2 RFC.

Libraries and tools

  • REST client application such as Postman or SoapUI to test REST request and response in BBA Mastro services.
  • jwt.io (JSON web toolkit) online encoder and decoder to debug access token. It can be installed also as google chrome extension

Architecture style

BBA APIs are designed based on a REST architectural style. As such, it communicates over the HTTP protocol using HTTP request methods. The APIs use JSON as data exchange format.

Request structure

The base URL for the requests is currently: http://api.bbamastro.com

It will be changed to https://api.bbamastro.com in a near future.

Header

Most of the resources can be accessed only by authenticated users. After the user is successfully authenticated, the system provides an access token. The token must be included in the "Authorization" field of the HTTP header on each request. 

Because the APIs use JSON as data format for interchange communication, the "Content-type" must be set to "application/json" for requests that contain JSON data.

The HTTP sample header below is the commonly used header for requests.


HTTP Header Request
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJnb2hhcmlrZ2FicmVseWFuQGdtYWlsLmNvbSIsInNjb3BlIjpbInJlYWQiLCJ3cml0ZSJdLCJleHAiOjE0ODA2ODY3NTMsInVzZXJJZCI6MTAsImF1dGhvcml0aWVzIjpbIlJPTEVfQURNSU4iLCJST0xFX0NPTVBBTllfQURNSU4iXSwianRpIjoiODg1YjMwMWItOGU4OC00OWU0LThkYzktMzZkNmRlZTUyOTAxIiwiY2xpZW50X2lkIjoiY2xpZW50YXBwIn0.6gn5-AibKa-RPkf0m1H2mh0HK97ZNSlSyoTtSCJyIHo
Content-type: application/json


HTTP Methods

There are several HTTP methods used in the BBA system.

Method NameDescription
POSTThis method is used for create new resources.
GETThis method is used to get resources.
PUTThis method is used to update all fields of a resource.
PATCHThis method is used to update some fields of a resource.
DELETEThis method is used to delete data.


Data Types

There are several data types used in this system

NameDescription
NumberNumeric data type
StringAlfa numeric data type
BooleanTrue or false

Date

Date with format (yyyy-MM-dd)


Response format

Responses from BBA system consists of:

  1. Response code: refer to the Error handling section on this page for further details on response codes.
  2. Response body: the content of the response in JSON format or file (PDF, CSV, etc).

Pagination

Some of our APIs resources support pagination under the following rules:

Default page size20
Maximum page size2000

Pagination parameters 

size page size
page page number
sort sorting query

Error handling

Every request to the API is replied by the system regardless if it is successful or not. The response code for success is 2xx. The table below provides a list of errors that may occur and how to solve them.

Error codeError messageTroubleshooting
unauthorizedFull authentication is required to access this resource

The user is not authenticated or an invalid access token is provided.

To solve this issue, set "Authorization" with a correct access token in the header.

Authorization: Bearer [access_token_here]

invalid_tokenAccess token expired: xxxx

The Access token expired. Get a new access token and set it in the header as follows:

Authorization: Bearer [access_token_here]

405Method Not AllowedThis error message occurs because of an invalid HTTP method. Check the documentation for the supported HTTP methods (GET, POST, PUT, DELETE).
Invalid RequestValidation issue

Incorrect request data was provided. In order to solve this error, check the "fieldErrors" data for the correct data.

Example, the error below occurred because the field "name" is empty:

{
"code": "Invalid Request",
"message": "Validation issues",
"fieldErrors": [

{
"resource": "marketplace",
"field": "name",
"code": "NotEmpty",
"message": "may not be empty"
}

]
}

Make sure you provide all the required data.

500Internal Server Error

Error on the system. Contact the developer to fix this issue.

Example:

{
"timestamp": "2016-12-02 07:41:57 +0000",
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.NullPointerException",
"message": "No message available",
"path": "/shipment/583fea2339c058125540caaf/pickslip"
}

Terminology


TermDescription
APIAPI (Application Program Interface) is a set of routines, protocols, and tools for building software applications. An API specifies how software components should interact and APIs are used when programming graphical user interface (GUI) components.
RESTREST (Representational State Transfer) is an architectural style for designing networked application that uses HTTP protocol to make a call between machines.
JSONJSON (Javascript Object Notation) is a lightweight data-interchange format that easy for humans to read and write. It is easy also for machines to parse and generate.
Oauth2OAuth 2 is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service.
JWTJWT (JSON Web Tokens) is an open, industry standard RFC 7519 method for representing claims securely between two parties.
Access TokenAccess token is a token provided by the authentication server after the user is authenticated. The token must be used to access API resource. It has a lifetime and must be renewed when it expires.




In this page


Related content

BBA Mastro System Authorization Process
BBA Mastro System Authorization Process
More like this
Additional References
Additional References
More like this
POST /shipment
POST /shipment
Read with this
API Documentation
API Documentation
More like this
AUTHENTICATION Service
AUTHENTICATION Service
More like this
GET /{shipmentId}/tracking
GET /{shipmentId}/tracking
More like this