Ship API Response

Ship API Response

The response is sent to indicate whether the request has been successfully completed or to indicate failure and a description of the error.

Status Codes

Status codes are issued by a server in response to a client's request made to the server. The following table lists the status codes supported by Site Flow. For the response to be configured successfully, please use only these codes in the response.

CodeDescription
200, 201Indicates a successful shipment
400Indicates there is incorrect or misconfigured information on the request
If the 400 status is returned, the body of the response should contain status.code= 'error' along with a meaningful description of the error in the status message. This message will be displayed in the Site Flow UI to the dispatch operator.
401Signature verification failed.

Response Headers

function createSignature(partnerId, apiKey) {
     const hmac = createHmac('sha256', apiKey)
     const nonce = randomBytes(48).toString('hex') hmac.update(nonce)
     const signature = hmac.digest('base64')
     const authorization = `${partnerId}:${signature}`

     return { nonce: nonce, authorization: authorization }
}
     const auth = createSignature(partnerId, 'PARTNER_API_KEY')
     res.setHeader('X-Siteflow-Nonce', auth.nonce)
     res.setHeader('X-Siteflow-Signature', auth.authorization)

Note: The headers x-siteflow-nonce and x-siteflow-signature should always be set on response.

ValueDescription
X-SITEFLOW-NONCEA random token generated for each request
X-SITEFLOW-SIGNATUREThe partnerId and the request signature generated by Site Flow for this request, separated by a ':' character

Shipping response payload

{
	"status": {
		"code": "ok",
		"message": "INSERT MESSAGE HERE"
	},
	"shipmentId": "5976029c770e36a13e25a85e",
	"charges": {
		"value": 0,
		"currency": "GBP"
	},
	"documents": [
		{
			"sendersReference": "20170720122153-0-1",
			"payload": " payload for label ",
			"type": "pdf",
			"encoding": "base64"
		}
	],
	"labels": [
		{
			"trackingNumber": "1Z3X3F910305063713",
			"sendersReference": "20170720122153-0-1",
			"payload": " payload for label ",
			"type": "pdf",
			"encoding": "base64"
		}
	]
}
Keys Description
Status
Code If processing is successful, put 'ok' in this field. If there is an error in processing the shipment, put 'error ' in this field.
Message Enter a detailed error message in this field if there was an error. this will be displayed to operator at dispatch.
Shipmentid The shipmentID from the shipping request. This field is optional
Charges
Value Any of the shipping charges
Currency The currency of the shipping charges
Documents Any other documents required (e.g. commercial invoice)
Senders references Use the referenceNumber from the package on the request so labels can be matched to the correct package.
Payload for label Encoded as specified in the encoding field
Type Should always be 'pdf' for now. This field is optional.
Encoding Should always be 'base64' for now. This field is optional.
Labels
tracking number This field is optional.
senders reference Use the referenceNumber from the package on the request so labels can be matched to the correct package.
payload Encoded as specified in the Encoding field below
type Can be 'pdf' or 'zpl' or 'png'
encoding Defaults to 'base64'. This field can be 'base64' or 'utf8'. Use 'utf8' for ZPL labels, as they do not need to be base64 encoded.