Skip to content
Last updated

Using ShipStation API on Behalf of an Account

Once you've created a ShipStation API account, the next step is to make API calls on behalf of that account. You can perform any ShipStation API operation on behalf of your customer, such as:

The On-Behalf-Of Header

All calls to the ShipStation API will require the following two headers:

Header NameDescription
API-KeyThis is your ShipStation Partner API key. See the Getting Started page for details.
On-Behalf-OfThis is the account ID of the ShipStation API account that you are operating on behalf of.

Example Request & Response

POST /v1/labels

POST /v1/labels HTTP/1.1
Host: api.shipengine.com
API-Key: __PARTNER_API_KEY_HERE__
On-Behalf-Of: __ACCOUNT_ID_HERE__
Content-Type: application/json

{
  "shipment": {
    "service_code": "usps_priority_mail",
    "ship_to": {
      "name": "Mickey and Minnie Mouse",
      "phone": "+1 (714) 781-4565",
      "company_name": "The Walt Disney Company",
      "address_line1": "500 South Buena Vista Street",
      "city_locality": "Burbank",
      "state_province": "CA",
      "postal_code": "91521",
      "country_code": "US",
      "address_residential_indicator": "No"
    },
    "ship_from": {
      "name": "Shippy",
      "phone": "512-485-4282",
      "company_name": "ShipStation API",
      "address_line1": "3800 N. Lamar Blvd.",
      "address_line2": "Suite 220",
      "city_locality": "Austin",
      "state_province": "TX",
      "postal_code": "78756",
      "country_code": "US",
      "address_residential_indicator": "No"
    },
    "packages": [
      {
        "weight": {
          "value": 1.0,
          "unit": "ounce"
        }
      }
    ]
  }
}

Example response:

{
  "label_id": "se-202887313",
  "status": "completed",
  "shipment_id": "se-202887313",
  "ship_date": "2019-04-01T05:00:00.000Z",
  "created_at": "2019-04-01T20:46:31.168Z",
  "shipment_cost": {
    "currency": "USD",
    "amount": 6.86
  },
  "insurance_cost": {
    "currency": "USD",
    "amount": 0.0
  },
  "tracking_number": "9405511899560441854156",
  "is_return_label": false,
  "is_international": false,
  "batch_id": "",
  "carrier_id": "se-123890",
  "service_code": "usps_priority_mail",
  "package_code": "package",
  "voided": false,
  "label_format": "pdf",
  "label_layout": "4x6",
  "trackable": false,
  "carrier_code": "stamps_com",
  "tracking_status": "unknown",
  "label_download": {
    "href": "https://api.shipengine.com/v1/downloads/aFbxNUVCZ0SDHHp-BmcKjA/testlabel-202887313.pdf"
  },
  "form_download": null,
  "insurance_claim": null,
  "packages": [
    {
      "package_code": "package",
      "weight": {
        "value": 1.00,
        "unit": "ounce"
      },
      "dimensions": {
        "unit": "inch",
        "length": 0.0,
        "width": 0.0,
        "height": 0.0
      },
      "insured_value": {
        "currency": "usd",
        "amount": 0.00
      },
      "tracking_number": null,
      "label_messages": {
        "reference1": null,
        "reference2": null,
        "reference3": null
      }
    }
  ]
}