# Create a Waste Form

## Introduction

You can use Dashdoc Wam API to create waste forms from your own software.

\
Creating forms requires several steps:

* companies that appear on the form have to be existing (see [#id-1-managing-companies](#id-1-managing-companies "mention"))
* additional details on companies that are specific to the waste activity must be set (see [#id-1-managing-companies](#id-1-managing-companies "mention"))
* contacts must be existing (see [#id-2-manage-contacts](#id-2-manage-contacts "mention"))
* finally the waste form can be created with a combination of those existing companies and contacts (see [#id-3-create-a-waste-form](#id-3-create-a-waste-form "mention"))
* and the waste loads can be detailed and linked to the form (see [#id-4-add-loads-on-a-waste-form](#id-4-add-loads-on-a-waste-form "mention"))

## 1 - Managing companies

#### Reminder

During the waste form initialization in Dashdoc Wam you have to pick 4 companies as producer, organizer, carrier and processor.\
Organizer is always your own own company, even if you're a producer and have your own arrangements for the transport or you waste. In this case, the organizer is filled but won't appear on the PDF document.

\
All companies available are visible in the "address book" in Dashdoc TMS.

Though they have additional properties specifically for the needs of waste form. Those additional information can only bee seen in Wam.

\
The list of extra information available in Wam is:

* Type of actor :
  * options "waste producer", "organizer", "waste processor" are only available in the details of a company in Wam
* Administrative numbers:
  * any company you select must have at least one valid administrative number (this will be checked when you sign the form as organizer)
  * there are different kind of administrative number that can be used as "VAT number", "entreprise number", "EORI number" and more. The list of possible number depends on the roles of the company that are selected with tags in the "Type of actor list"

#### Creating companies

If you want to create a waste form and one of the producer, carrier or processor company is not existing in the address book, you need to create it first.\
To do so, just use the main endpoint on companies, that is part of the TMS API : [/v4/companies/](https://www.dashdoc.eu/api/v4/docs/#tag/Companies). Send a POST request to create the company. You can also update the company later if required.

Payload exemple

```json
{
    "name": "Dashdoc",
    "phone_number": "0032123456789",
    "email": "email@yopmail.com",
    "trade_number": "123456789",
    "vat_number": "BE0123456789",
    "country": "BE",
    "primary_address": {
        "name": "Dashdoc Antwerpen",
        "address": "Sint-Pietersvliet 7",
        "city": "Antwerpen",
        "postcode": "2000",
        "country": "BE",
        "is_carrier": true,
    }
}
```

#### Adding mandatory details for waste forms

Legal constraints on digital waste identification forms forces to have at least one identification number for each company on the form. The possible kind of identification number accepted vary on the role of the company among "producer", "organizer", "carrier", "processor".\
So you need to give companies one or many role and identification number.\
\
Here is a recap of accepted identification number by role:

| type of number / role                       | for waste producers | for transport organizers | for carriers | for waste processors |
| ------------------------------------------- | ------------------- | ------------------------ | ------------ | -------------------- |
| VAT number                                  | YES                 | YES                      | YES          | YES                  |
| Belgian enterprise number                   | YES                 | YES                      | YES          | YES                  |
| EORI number                                 | YES                 | YES                      | YES          | YES                  |
| establishment unit number                   | YES                 | NO                       | NO           | YES                  |
| Sea ship number if the producer is a ship   | YES                 | NO                       | NO           | NO                   |
| Citizen if the producer is a private person | YES                 | NO                       | NO           | NO                   |

As these information are specific to waste forms, they do not appear in the TMS and are not manageable with the main endpoint on companies.\
To set those specific details on companies, you need to use the [/v4/wam/companies/{pk}/details/](https://www.dashdoc.eu/api/v4/docs/#tag/Wam-Companies/paths/~1wam~1companies~1%7Bcompany-id%7D~1details~1/post) endpoint.\
You can set the details and change it later if required.

Payload exemple

```json
{
  "is_organizer": false,
  "is_producer": true,
  "is_processor": false,
  "is_carrier": false,
  "is_citizen": false,
  "enterprise_number": "BE 0429 261 424",
  "producer_establishment_unit_number": "0123456789",
  "vat_number": "FR16807564448"
}
```

## 2 - Manage contacts

Digital waste identification form will be sent to the producer and the processor at some stage. Validation and signature links can also be sent to some actors during the lifecycle of the waste form.\
\
To enable this, some contacts are required in the details of the waste form for Dashdoc Wam to work properly.\
\
Contacts can be created and updated using the endpoint [/v4/wam/contacts/](https://www.dashdoc.eu/api/v4/docs/#tag/Wam-Contacts/paths/~1wam~1contacts~1/post)

## 3 - Create a waste form

To create a digital waste identification form, send a POST on the [/v4/wam/forms/](https://www.dashdoc.eu/api/v4/docs/#tag/Wam-Forms/operation/createWasteForm) endpoint.\
The payload is built with a combination of ids of companies and uids of contacts already existing (see [#id-1-managing-companies](#id-1-managing-companies "mention") and [#id-2-manage-contacts](#id-2-manage-contacts "mention"))

{% hint style="warning" %}
Deprecation notice: We recently deprecated the waste shipment `destination_id` field.

* We now use the processor's primary address as transport delivery address.
* If you send a `destination_id` , Dashdoc Wam will ignore it.
* For few weeks we will keep returning the waste shipment `destination_id` field with processor primary address as value.
{% endhint %}

All companies (producer, organizer, carrier and processor) are mandatory.

☝️To find your own company id, you can check if you have at least one form existing in the web application or create a draft form in the web application, then send a GET request on /v4/wam/forms. You will then see your own company id in the `organizer_id` field of any form in the response body.

Mandatory contacts are :

* the producer contact who will receive a copy of the form after loading and after final signature by the processor
* the processor contact who will receive the final version of the document

Addtionnal contact can be set:

* the processor signatory who will receive a email to validate the loads ang apply final signature on the waste from, after the unloading is done and the trucker has left the site. If that person is the same as the processor contact, then no need to fill it and the signature request email will be sent the processor contact. If it is another person, then just fill it.

Payload exemple:

```json
{
    "producer_id": 2162003,
    "processor_id": 2162037,
    "carrier_id": 2079832,
    "organizer_id": 2079832,
    "origin_id": 66575313,
    "instructions": "test",
    "transport_date": "2024-01-30T13:25:23.814000Z",
    "producer_contact_id": 1306,
    "processor_contact_id": 1399,
    "processor_signatory_id": null
}
```

## 4 - Add loads on a waste form

When the structure of the waste form is created, you need to send more request to add the loads details on the form. You can add one or multiple loads.\
To add a load, send a POST request on [/v4/wam/forms/{form-uid}/loads/](https://www.dashdoc.eu/api/v4/docs/#tag/Wam-Form-Loads/operation/createWasteFormLoad). The load will be added to the waste form targeted in the URL with its uid.\
If you need to add more that one load, send additionnal request for each load.

Payload exemple:

```json
{
  "description": "Waste description",
  "weight": 12500,
  "quantity": 10,
  "eural_code": "02 01 01",
  "physical_properties": "Flammable and reactive waste",
  "chemical_composition": "Radioactive Materials",
  "packaging_type": "Barrels",
  "treatment_type": "Regeneration of acids or bases.",
  "treatment_codes": [
    "R1",
    "D13"
  ]
}
```

You can access all loads of a waste form by sending a GET request on the same endpoint with the uid of the waste form in the URL.

exemple : https://api.dashdoc.eu/api/v4/wam/forms/9be1bd0c-8f55-4825-9d64-116f611070d2/loads/
