IBC. Inc.

IBC Label Service - REST Service

Introduction

This REST service allows your system to create shipping labels using standalone, web or script based program.

Your client should use POST HTTP method to successfully submit your label create requests.

The service URL is:
 https://api.pactrak.com/shiplabel/v1/ 

Attention: This is a secure service, you need to obtain a security token first and use the "Authorization" header with the "Bearer" scheme on every request, for example:
    curl https://api.pactrak.com/shiplabel/v1/..... -H "Content-Type: application/json" -H "Authorization: Bearer NmIzY2Y1OWV8SmFoMnclWl5Od1p2S1NzVw=="
Please visit the Authority Web service for information on how to receive an authority token.
https://api.pactrak.com/authority/documentation.html

Default values

Your service requests URLs will need to use these variable parameters:

  1. STATION_CODE: select between MIA, NYC, LAX, DFW or ORD.
  2. SERVICE_CODE:
    • - For Fedex labels use S for SmartPost, G for Ground, GH for Ground Home Delivery, E for Standard Express

URL parameters

Your service request URL can contain these optional parameters:

For example - for a Fedex Ground test label for MIA station:
  https://api.pactrak.com/shiplabel/v1/MIA/G?_test  

Label Create Requests

To create a new label you will need:

  • Submit a HTTP POST request to the server.
  • Set HTTP Header: "Content-Type: application/json"
  • Set HTTP Header: "Authorization: Bearer TOKEN_DATA......"
  • The URL should have the following format:
     https://api.pactrak.com/shiplabel/v1/STATION_CODE/SERVICE_CODE
  • The request data feed JSON format.
  •                             
    { /** This object describes the recipient information. */
        "customer": {
            "name": "", /* required */
            "company": "",
            "phone": "", /* required */
            "address1": "", /* required */
            "address2": "",
            "city": "", /* required */
            "state": "", /* required */
            "postalCode": "", /* required */
            "countryCode": "" /* required - should always be 'US' */
        },
        /** This object describes the shipper information */
        "shipper":{
            "ibc_account": "####", /* Use the shipper account number IBC assigned  -required */
            "name":"", /* required */
            "company":"",
            "phone":"", /* required */
            "address1":"", /* required */
            "address2": "",
            "city":"", /* required */
            "state":"", /* required */
            "postalCode":"", /* required */
            "countryCode":"" /* required - ISO two letter code */
        },
        /* This object describes the physial item being shipped */
        "items": [ 
            {
                "weight": 0.00, /* required */
                "weight_unit": "", /* required (OZ, GM, LB) ounces, grams or pounds */
                "value": 0.00, /* required */
                "packaging": "", /* required ( BAG, BOX, ENVELOPE, OTHER )*/
                "description": "", /* required */
                "length": 0, /* required if supplying dimensions */
                "width": 0, /* required if supplying dimensions */
                "height": 0, /* required if supplying dimensions */
                "dim_unit": "" /* required if supplying dimensions (IN, CM)*/
                
            }
        ],
        
        "reference": "", /* optional - any reference id for your transaction */
        
        
    }
                            

Fedex Service Codes

Use these codes for Fedex Labels
  • S: SmartPost - requires close manifest
  • G: Ground - requires close manifest
  • GH: Ground Home Delivery - requires close manifest
  • E: Fedex Express label

See shipment label options for optional label configurations, default is ZPLII 4x6 Stock label

Optional Label type and Size Options

The requests allow you to modify the return typle. You can modify the label type by appending the following parameters to your URL:

 ?label_type=LABEL_TYPE&label_size=LABEL_SIZE
Fedex Options
For Standard Label Printers
label_type label_size
ZPLII STOCK_4X6
EPL2 STOCK_4X6.75_LEADING_DOC_TAB
DPL STOCK_4X6.75_TRAILING_DOC_TAB
  STOCK_4X8
  STOCK_4X9_LEADING_DOC_TAB
  STOCK_4X9_TRAILING_DOC_TAB
For Laser Printer Labels
label_type label_size
PDF PAPER_4X6
PNG PAPER_4X8
RTF PAPER_4X9
TEXT PAPER_7X4.75
  PAPER_8.5X11_TOP_HALF_LABEL
  PAPER_8.5X11_BOTTOM_HALF_LABEL
  PAPER_LETTER

Use only KG, LB as weight_unit

Label Delete Requests

To delete a label you will need:

  • Submit a HTTP DELETE request to the server.
  • Set HTTP Header: "Content-Type: application/json"
  • Set HTTP Header: "Authorization: Bearer TOKEN_DATA......"
  • The URL should have the following format:

     https://api.pactrak.com/shiplabel/v1/STATION_CODE/SERVICE_CODE/TRACK_NUMBER

  • There is no request body, the service response will be JSON, in the same general foramt outlined in the Response JSON structure section below.

For all Fedex services, you can just use 'F' as the service code.

How to submit your data

You will need to obtain a security token before submitting your test or production requests.

The easiest way to test your POST request is to use cURL from the system's command line. Use the url parameter code _test for TEST entries.

For example - for a Fedex Ground test label for MIA station:
  https://api.pactrak.com/shiplabel/v1/MIA/G?_test  

We recommend saving your JSON structure into a text file ( input-file.txt ).

curl -siL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer NmIzY2Y1OWV8SmFoMnclWl5Od1p2S1NzVw==" --data "@input-file.txt" https://api.pactrak.com/shiplabel/v1/MIA/G?_test

Sample JSON structures ready for testing.

{ "customer":{ "name":"Jon Test", "company":"Test Inc", "phone":"305 591 8080", "address1":"1755 West Plantation Road", "city":"Miami", "state":"FL", "postalCode":"33122", "countryCode":"US" }, "shipper":{ "ibc_account": "8040", "name":"Mike Bello", "company":"IBC", "phone":"305 591 8080", "address1":"8401 NW 17th St", "city":"Miami", "state":"FL", "postalCode":"33191", "countryCode":"US" }, "items":[{ "weight":1.35, "weight_unit":"LB", "packaging":"BOX", "description":"magazines", "length": 10, "width": 20, "height": 10, "value": 1, "dim_unit": "IN" }], "reference": "165432423" }

How to cancel labels

curl -siL -X DELETE -H "Authorization: Bearer NmIzY2Y1OWV8SmFoMnclWl5Od1p2S1NzVw==" https://api.pactrak.com/shiplabel/v1/F/7026465464

Response JSON structure

After making a successful submission you should expect a return of one of the following JSON structures:

                    
{ /**
    * The HTTP response code
    * @type Integer.
    */
    "code": , /** Successful response: 200, Error response: 40x */
    
    /**
    * Response message relevant to the action requested.
    * @type String.
    */
    "message":"",
    
    /**
    * Detailed Response message relevant to the action requested.
    * @type String.
    */
    "developerMessage":"",
    
    /**
    * A link to the resource.
    * @type String.
    */
    "href":"/shiplabel/v1/..",
    
    /**
    * The direct response from the label provider with the details of your label transaction. Note:
    may not appear on error responses.
    * @type JSON Object.
    */
    "service_answer": [ 
        { 
            /** Note: not all items will be available on all responses. Most are for informational purposes only. */
            "message": "", /** */
            "label_feed": "", /** The data feed that is used to create your physical label. The data is base64 encoded.*/
            "labelResponse": "", /** informational details about the label feed */
            "label_type": "LABEL-ZPLII", /** Defaults to LABEL-ZPLII*/
            "trackNumbers": [ "" ], /** This is an array object. The first item in the array is your main track number.  */
            "service": "", /** Service requested */
            "notes": "",
            "notices": "",
            "jobId": "", /** A unique Job Id created by the service provider. */
            "barcode": "", /** The data that created the barcode printed on the label.. */
        }
    ],
    "trackNumber": "" /** This is the internal number IBC will use for your shipment */ 
    "is_error": false, /** true or false */ 
    "completion_time": "" /** informational purposes */
}
                    
                

On error responses the Developer message object will contain a validity report with details of the issues found with the input provided. It is formatted with end of line chars "\n" so that it will be readable in your browser's web console.

Developer Resources

Restful services are capable of receiving requests form web based or standalone applications. We have tested our services to comply with REST standards, returning appropriate HTTP codes to help developers using commonly used frameworks as JQuery or Prototype.

Additionally, there are many examples from many different programming languages such as C#, Java, PHP and C++.

If you desire to test or need Java sample code, the following project is an example of how to call an HTTP Rest service using HTTP Post protocol, IBCPost.

Useful Links