Skip to main content

Create Shipment API

Try Now

POST https://api.piyovi.io/v1/shipment

Overview

The Create Shipment API allows you to create a new shipment in the Piyovi system. This endpoint handles all necessary shipment details including origin, destination, package information, and any special requirements.

Authentication

This API requires authentication using one of the following methods:

  • Bearer Token: Include JWT with Bearer prefix in the Authorization header
  • API Key: Include X-API-KEY header with your API key

For more details, see Authentication Guide.

Request Format

POST /v1/shipment
Content-Type: application/json
Authorization: Bearer {token}

Request Body

{
"client": "MyClient",
"location": "MainWarehouse",
"shipDate": "2025-03-20T14:00:00Z",
"shipTo": {
"companyName": "Example Corp",
"contactName": "John Doe",
"emailAddress": "john@example.com",
"phoneNumber1": "123-456-7890",
"address1": "123 Main St",
"city": "San Francisco",
"stateProvince": "CA",
"country": "US",
"zipPostalCode": "94105"
},
"shipFrom": {
"companyName": "Your Company",
"contactName": "Jane Smith",
"emailAddress": "jane@yourcompany.com",
"phoneNumber1": "987-654-3210",
"address1": "456 Warehouse Blvd",
"city": "Chicago",
"stateProvince": "IL",
"country": "US",
"zipPostalCode": "60601"
},
"shipmentInfo": {
"shipMethod": "Ground",
"carrier": "FedEx",
"serviceLevel": "Standard"
},
"packages": [
{
"weight": 25.5,
"length": 20,
"width": 15,
"height": 10,
"type": "Box",
"declaredValue": 500,
"items": [
{
"itemId": "ITEM-123",
"name": "Product Sample",
"description": "Product samples for marketing",
"weight": 25.5,
"qty": 5,
"unitPrice": 100
}
]
}
],
"references": {
"orderNumber": "ORD-12345",
"customerPO": "PO-6789"
}
}

Response Format

Success Response (200 OK)

{
"success": true,
"id": "ship-12345678",
"shipmentReference": "FDX-987654321",
"status": "Created",
"trackingNumber": "794612345678",
"activity_Id": "act-12345",
"estimatedDelivery": "2025-03-23T17:00:00Z",
"transitDays": "3",
"carrierAccount": "FDX-ACCOUNT",
"carrierServiceLevel": "GROUND",
"carrier": "FedEx",
"shipMethod": "Ground",
"references": {
"orderNumber": "ORD-12345",
"customerPO": "PO-6789"
},
"packages": [
{
"package_Id": "pkg-123456",
"referenceId": "0",
"weight": 25.5,
"length": 20,
"width": 15,
"height": 10,
"trackingNumber": "794612345678",
"type": "Box",
"unitOfLength": "IN",
"unitOfWeight": "LB",
"count": 1
}
],
"billingDetail": {
"totalFreight": 45.67,
"totalDiscountFreight": 41.10,
"baseCharge": 39.99,
"totalSurcharges": 5.68,
"totalTaxes": 0.00,
"currencyCode": "USD"
},
"documents": [
{
"document_Id": "doc-12345",
"documentName": "Shipping Label",
"documentType": "Label",
"documentContentType": "application/pdf",
"documentContent": "BASE64_ENCODED_CONTENT",
"documentMimeType": "application/pdf"
}
],
"trackingUrl": "https://www.fedex.com/track?trknbr=794612345678"
}

Error Response (400 Bad Request)

{
"success": false,
"errors": [
{
"code": "InvalidAddress",
"message": "Destination address could not be validated",
"type": "ValidationError"
}
]
}

Field Reference

FieldTypeRequiredDescription
clientstringNoClient identifier
locationstringNoLocation identifier
shipDatedatetimeYesDate and time when the shipment will be sent
shipToobjectYesDestination address details
shipFromobjectYesOrigin address details
shipmentInfoobjectYesShipping method and carrier preferences
packagesarrayYesArray of package details
referencesobjectNoCustom reference fields
internationalDetailobjectNoInternational shipping information (required for international shipments)
notesstringNoSpecial instructions or notes for the shipment
unitOfWeightstringNoUnit of measurement for weight (e.g., KG, LB)
unitOfLengthstringNoUnit of measurement for dimensions (e.g., CM, IN)
dgItemsarrayNoDangerous goods details (if applicable)
additionalOptionsobjectNoAdditional options for the shipment

Address Object Fields (shipTo, shipFrom)

FieldTypeRequiredDescription
companyNamestringNoCompany name
contactNamestringNoContact person's name
emailAddressstringNoEmail address
phoneNumber1stringNoPrimary phone number
address1stringYesStreet address line 1
address2stringNoStreet address line 2
citystringYesCity name
stateProvincestringYesState or province
countrystringYesCountry code (2-letter ISO code recommended)
zipPostalCodestringYesPostal or ZIP code

Shipment Info Object Fields

FieldTypeRequiredDescription
shipMethodstringYesMethod of shipment (e.g., Ground, Express)
carrierstringYesCarrier name
serviceLevelstringNoService level
carrierAccountstringNoCarrier account identifier
paymentTypestringNoPayment method (e.g., Prepaid, Collect)

Package Object Fields

FieldTypeRequiredDescription
weightnumberYesWeight of the package
lengthnumberYesLength of the package
widthnumberYesWidth of the package
heightnumberYesHeight of the package
typestringNoType of package (e.g., Box, Pallet)
declaredValuenumberNoDeclared value for insurance
itemsarrayNoArray of items in the package

Examples

Basic Domestic Shipment

{
"client": "ExampleClient",
"location": "DefaultWarehouse",
"shipDate": "2025-03-20T14:00:00Z",
"shipTo": {
"companyName": "Recipient Corp",
"contactName": "John Recipient",
"address1": "123 Delivery St",
"city": "Los Angeles",
"stateProvince": "CA",
"country": "US",
"zipPostalCode": "90001"
},
"shipFrom": {
"companyName": "Sender Inc",
"contactName": "Jane Sender",
"address1": "456 Shipping Ave",
"city": "Chicago",
"stateProvince": "IL",
"country": "US",
"zipPostalCode": "60601"
},
"shipmentInfo": {
"shipMethod": "Ground",
"carrier": "UPS"
},
"packages": [
{
"weight": 10.5,
"length": 12,
"width": 8,
"height": 6,
"type": "Box"
}
]
}

International Shipment with Multiple Packages

{
"client": "GlobalClient",
"location": "ExportWarehouse",
"shipDate": "2025-03-25T10:00:00Z",
"shipTo": {
"companyName": "International Corp",
"contactName": "Hans Importer",
"address1": "123 Global Street",
"city": "Berlin",
"stateProvince": "Berlin",
"country": "DE",
"zipPostalCode": "10115"
},
"shipFrom": {
"companyName": "Exporter Inc",
"contactName": "Maria Exporter",
"address1": "789 Export Road",
"city": "New York",
"stateProvince": "NY",
"country": "US",
"zipPostalCode": "10001"
},
"shipmentInfo": {
"shipMethod": "Express",
"carrier": "DHL",
"serviceLevel": "International Express"
},
"packages": [
{
"weight": 5.2,
"length": 15,
"width": 10,
"height": 8,
"type": "Box",
"declaredValue": 250
},
{
"weight": 7.8,
"length": 20,
"width": 12,
"height": 10,
"type": "Box",
"declaredValue": 350
}
],
"internationalDetail": {
"dutiesPaidBy": "Sender",
"totalCustomValue": 600,
"reasonToExport": "Commercial Sample",
"incoTerm1": "DAP",
"currencyCode": "USD",
"commodities": [
{
"description": "Product Samples",
"numberOfBoxes": 2,
"quantity": 10,
"unitWeight": 1.3,
"unitPrice": 60,
"customValue": 600,
"countryOfOrigin": "US"
}
]
}
}

Notes

  • For international shipments, ensure you provide all required customs information in the internationalDetail object.
  • For dangerous goods, include detailed information in the dgItems array.
  • The response will include tracking information and shipping documents (labels) in base64 format.
  • Use the references object to include your own reference information (e.g., order numbers, PO numbers).