# CreateShipment

For accessing the DPD-Shipping brixxbox interface the DPD services need the following setup values (configuration -> settings).

* **DPDUserCredentialsCloudUserID**
* **DPDUserCredentialsToken**
* **DPDPartnerCredentialsName**
* **DPDPartnerCredentialsToken**

If no settings are available, a sample label will be generated.

### Incomming Information

To create labels three groups of information are available:

* **1. OrderSettings** with the following fields (If the group is not present default values will be assumed)
  * **language:** Values „de\_DE“ or „en\_EN“ are allowed. If nothing is set „de\_DE“ will be assumed.
  * **ShipDate:** if not available will be set to „today“
  * **LabelSize:** „PDF\_A4“ or „PDF\_A6“. If nothing is set „PDF\_A4“ will be assumed.
  * **LabelStartPosition:** “UpperLeft“, „UpperRight“, „LowerLeft“, „LowerRigh“
* **2. ShipAddress:**
  * Company
  * Gender
  * Salutation
  * FirstName
  * LastName
  * Name
  * Street
  * HouseNo
  * ZipCode
  * City
  * Country
  * State
  * Phone
  * Mail
* **3. ParcelData:**
  * **YourInternalID:** should be set to your own reference (e.g. order no). if no value is provided a timestamp will be set.
  * Content
  * **Weight:** in kg
  * Reference1
  * Reference2
  * **ShipService:** set to a valid DPD-Service. If nothing is set “Classic” will be assumed.

\
Detailed informationen for field usage can be found at <https://esolutions.dpd.com/dokumente/DPD_Cloud_Service_Webservice_Dokumentation_DE.pdf>

### Returning Information

* In case of **success (status 200)** the following fields are returned
  * **ParcelNo:** The DPD generated ID. This will be used for further references to this shipment.
  * **YourInternalID:** The same ID that was provided for the request
  * **TimeStamp:** an informational time stamp when the request was processed
  * **LabelData:** this is a blob response. It contains the actual label in PDF format and can directly be used for further processing. E.g. “brixxApi.printBlob(LabelPDF);”
* In case of **error (status 400)** the following fields are returned:
  * **TimeStamp:** an informational time stamp when the request was processed
  * **ErrorDataList:** an array with detailed information what went wrong. Every error will show the following fields
    * **ErrorID:** an internal error no
    * **ErrorCode:** an internal error code
    * **ErrorMsgShort:** Error information short version
    * **ErrorMsgLong:** Error information long version

### Example Usages

```javascript
/*----------------------------------------------------------------------------------------------
/This example is minimalistic and will create a sample label. 
/You need to check which fields are relevant for your process and assign the values accordingly.
/----------------------------------------------------------------------------------------------*/

var result = await brixxApi.businessBrixx({
      functionName:"DPDShipping",
      methodName: "CreateShipment",
	  ShipAddress : {
		Company: 'Mustermann AG',
		Name: 'Max Mustermann',
		Street: 'Wailandtstr.',
		HouseNo: '1',
		ZipCode: '63741',
		City: 'Aschaffenburg',
		Country: 'DEU'
	  },
	  ParcelData : {
		Reference1: 'Customer email',
		Content: 'Order number',
		Weight: '13.5'
      }
      });
console.log("Parcel Number: " + result.ParcelNo)
brixxApi.printBlob(result.LabelData);


/*----------------------------------------------------------------------------------------------
/This example uses all fields
/You need to check which fields are relevant for your process and assign the values accordingly.
/----------------------------------------------------------------------------------------------*/
var result = await brixxApi.businessBrixx({
      functionName:"DPDShipping",
      methodName: "CreateShipment",
			OrderSettings : {
				language: 'de_DE',
				LabelSize : 'PDF_A4',
				LabelStartPosition : 'UpperLeft',
				ShipDate : app.getFieldValue("SomeFieldValue")
			  },
			ShipAddress : {
				Company: app.getFieldValue("SomeFieldValue"),
				Gender: app.getFieldValue("SomeFieldValue"),
				Salutation: app.getFieldValue("SomeFieldValue"),
				FirstName: app.getFieldValue("SomeFieldValue"),
				LastName: app.getFieldValue("SomeFieldValue"),
				Name: app.getFieldValue("SomeFieldValue"),
				Street: app.getFieldValue("SomeFieldValue"),
				HouseNo: app.getFieldValue("SomeFieldValue"),
				ZipCode: app.getFieldValue("SomeFieldValue"),
				City: app.getFieldValue("SomeFieldValue"),
				Country: app.getFieldValue("SomeFieldValue"),
				State: '',
				Phone: app.getFieldValue("SomeFieldValue"),
				Mail: app.getFieldValue("SomeFieldValue")			  
			  },
			ParcelData : {
				Reference1: app.getFieldValue("SomeFieldValue"),
				Reference2: app.getFieldValue("SomeFieldValue"),
				Content: app.getFieldValue("SomeFieldValue"),
				Weight: app.getFieldValue("SomeFieldValue"),
				YourInternalID: app.getFieldValue("SomeFieldValue"),
				ShipService: app.getFieldValue("SomeFieldValue")			  
			  }
      });
console.log("Parcel Number: " + result.ParcelNo)
brixxApi.printBlob(result.LabelData);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/businessbrixx/dpd-shiping/createshipment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
