Basics

Sendbox API are HTTP based RESTful APIs. API request and response format are in JSON.

  • All request should be issued using HTTP protocol

  • All request requires authentication

  • Content type for responses will always be application/json

API Request

To construct an API request the following components are required.

Component

Description

The HTTP method

GET. Request data from resource

POST . Submit data to a resource to process

PUT . Update a resource

DELETE . Deletes a resource

The URL to the staging API service

The URL to the live API service

HTTP request header

Includes the Content-type header with the value application/json

A JSON request body

required for making a request

You are advised to make all test request on the staging API and ensure there are no errors before you deploy to users using the live API

API response

This describes the response format for Sendbox API

Sendbox API calls return HTTP status codes in the response headers. API calls also return JSON response bodies that include information about the resource.

Each REST API request returns a success or error HTTP status code.we will talk about errors latter in the docs but for now, we will focus on success.

status code

Description

200

A successful GET request

201

A successful POST, PUT request means your request is created or updated.

Fetching Data

Fetching data means you will like to retrieve data from a resource. Most times, you are required to set header parameters usually the content-type and the authorization key and make a get request to an endpoint. For example, let say we want to get all shipments, we can simply make a get request and a successful request will come back with a 200 status code and return all the shipments in JSON format.

Fetch Data

https://sandbox.staging.sendbox.co/shipping

https://live.sendbox.co/shipping/shipments

In this example, we are making a get request to shipment endpoint to fetch all shipments

Headers

Name

Type

Description

Authorization

String

Authorization-key

Content-type

String

application/json

Posting Data

Posting data is a little different from fetching data. here you are required to make a post request to the endpoint and pass in a body of JSON data you would like to post. For example, let's say you want to get delivery quotes for a shipment. You simply make a post request to the delivery quotes endpoint this returns a status code 201 and quotes of that shipments in JSON format.

JSON body sample to make a post request

{
"origin_country":"Nigeria",
"origin_country_code":"NG", 
"origin_state" : "Lagos",
"destination_country":"Nigeria",
"destination_country_code":" ",
"destination_state": "Abuja",
"weight" : 3,
"destination_state_code":"ABV",
"origin_state_code": "LOS"
}

Post Data

https://sandbox.staging.sendbox.co/shipping/shipment_delivery_quote

https://live.sendbox.co/shipping/shipment_delivery_quote

In this example, we are making a post request to the shipment_delivery_quote endpoint.

Headers

Name

Type

Description

Authorization

String

Authorization-key

Content-type

String

application/json

Body Parameters

Name

Type

Description

origin_country

String

senders country

origin_country_code

String

senders country code

origin_state

String

senders state

origin_state_code

String

senders state code

destination_country

String

recipient country

destination_country_code

String

recipient country code

destination_state

String

recipient state

destination_state_code

String

recipient state code

weight

float

weight of package

Last updated