> ## Documentation Index
> Fetch the complete documentation index at: https://docs.procuros.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Shipping Notices

This is the right section for you if you are acting as a supplier and looking to send shipping notices to your customers.

Throughout this guide you will learn how to send shipping notices to the Procuros API.

PHP examples are included but you will likely also want to look at the relevant API calls in the [API reference](/en/api/v2/overview).

## Process

These are usually the steps taken when sending a shipping notice:

1. Check, if this document should be sent via Procuros (see: [Enabled Trade Partners](/en/api/v2/features-enabled-trade-partners))
2. Verify this document has not already been sent (see: [Tracking Document Status](/en/api/v2/features-tracking-document-status))
3. Build the transaction payload to be sent via Procuros.
   1. If products being shipped are perishable and thus require shelf-life tracking, batch information needs to be added (see: [Batches & Best Before Dates](/en/api/v2/features-batches-best-before-dates))
   2. If you are sending large shipments on Euro Pallets, additional shipment identification needs to be provided. (see: [Package Identification](/en/api/v2/features-package-identification))
4. Send the transaction payload via the Procuros API

## Authentication

You will need an API token to authenticate. We use a bearer token which has to be included in each request you send to the API.

Please read the [Authentication](/en/api/v2/concept-authentication) section of our API reference for a detailed description.

## Error Handling

The API will return a `2xx` status code for successful requests. Anything else indicates an error.

Please read the [Errors](/en/api/v2/concept-error-handling) section of our API reference for a detailed description plus examples of how to handle them.

## Send Shipping Notices

The API call [Send transaction](/en/api/v2/outgoing-transactions/send-transaction) is used to create transactions, including shipping notices.

The following fields are required:

* `type` (Transaction type. In this case `SHIPPING_NOTICE`)
* `content` (The details of the shipping notice items.)

Inside the `content` you will need to build all shipping notice items. All details can be found in the `SHIPPING_NOTICE` schema as described in the [API reference](/en/api/v2/outgoing-transactions/send-transaction).

<Note>
  Each item in `transportUnits` must have a `unitType`. The following values are supported:

  | Value                 | Description                  |
  | --------------------- | ---------------------------- |
  | `EURO_PALLET`         | Euro Pallet (120 × 80 cm)    |
  | `EURO_PALLET_HALF`    | 1/2 Euro Pallet (80 × 60 cm) |
  | `EURO_PALLET_QUARTER` | 1/4 Euro Pallet (60 × 40 cm) |
  | `PALLET`              | Generic / non-Euro pallet    |
  | `PACKAGE`             | Package                      |
  | `CARTON`              | Carton                       |
  | `CONTAINER`           | Shipping container           |
</Note>

An example request would look like:

<CodeGroup>
  ```php php theme={null}
  // install dependency
  // $ composer require guzzlehttp/guzzle

  <?php
  require_once('vendor/autoload.php');

  $client = new \GuzzleHttp\Client();

  $transaction = [
    'type' => 'SHIPPING_NOTICE',
    'content' => [
      'header' => [
        'buyer' => [
          'name' => 'ACME Co. Ltd.',
          'identifiers' => [
            [
              'identifier' => '3220010000005',
              'domain' => 'GS1'
            ]
          ]
        ],
        'supplier' => [
          'name' => 'Testsupplier',
          'identifiers' => [
            [
              'identifier' => '3220010000010',
              'domain' => 'GS1'
            ]
          ]
        ],
        'shipTo' => [
          'identifiers' => [
            [
              'identifier' => '3220010000005',
              'domain' => 'GS1'
            ]
          ]
        ],
        'billTo' => [
          'identifiers' => [
            [
              'identifier' => '3220010000006',
              'domain' => 'GS1'
            ]
          ]
        ],
        'technicalRecipient' => [
          'identifiers' => [
            [
              'identifier' => '3220010000006',
              'domain' => 'GS1'
            ]
          ]
        ],
        'technicalSender' => [
          'identifiers' => [
            [
              'identifier' => '3220010000007',
              'domain' => 'GS1'
            ]
          ]
        ],
        'shippingNoticeIdentifier' => 'SN9383-R45',
        'shippingNoticeDate' => '2021-11-24',
        'orderIdentifier' => 'PO9383-R45',
        'orderDate' => '2021-11-20',
        'despatchDate' => '2021-11-05',
        'requestedDeliveryDate' => '2021-11-06',
        'expectedDeliveryDate' => '2021-11-06'
      ],
      'transportUnits' => [
        [
          'unitIdentifier' => '34000000000001',
          'unitType' => 'EURO_PALLET',
          'containedTradeUnitCount' => 10,
          'items' => [
            [
              'lineNumber' => 1,
              'orderLineNumber' => 1,
              'orderIdentifier' => 'PO9383-R45',
              'identifiers' => [
                [
                  'identifier' => '2330010000061',
                  'domain' => 'GS1'
                ],
                [
                  'identifier' => 'filter-coffee',
                  'domain' => 'BUYER'
                ],
                [
                  'identifier' => 'supplier-filter-coffee',
                  'domain' => 'SUPPLIER'
                ]
              ],
              'isDepositItem' => false,
              'orderedQuantity' => 20,
              'shippedQuantity' => 20,
              'description' => 'First product description.',
              'certifications' => [
                'eudr' => [
                  'verificationNumber' => 'FAHLHGK7',
                  'referenceNumber' => '24ITYGBJFOS258'
                ]
              ],
              'batches' => [
                [
                  'batchIdentifier' => 'BATCH_ID_1',
                  'expirationDate' => '2022-12-24',
                  'quantity' => 15
                ],
                [
                  'batchIdentifier' => 'BATCH_ID_2',
                  'expirationDate' => '2022-12-31',
                  'quantity' => 5
                ]
              ]
            ],
            [
              'lineNumber' => 2,
              'orderLineNumber' => 2,
              'orderIdentifier' => 'PO9383-R45',
              'identifiers' => [
                  [
                      'identifier' => '2330010000019',
                      'domain' => 'GS1'
                  ],
                  [
                      'identifier' => 'bread-crumbs-bulk',
                      'domain' => 'BUYER'
                  ],
                  [
                      'identifier' => 'supplier-bread-crumbs-bulk',
                      'domain' => 'SUPPLIER'
                  ]
              ],
              'isDepositItem' => false,
              'orderedQuantity' => 19,
              'shippedQuantity' => 15,
              'openQuantityAction' => 'DISCARDED',
              'batches' => [
                [
                  'batchIdentifier' => 'BATCH_ID_2',
                  'expirationDate' => '2022-05-01',
                  'quantity' => 15
                ]
              ],
              'description' => 'Sparkling Water - Crate (6x0.75l).'
            ]
          ]
        ]
      ]
    ]
  ];

  $response = $client->request('POST', 'https://api.procuros.io/v2/transactions', [
    'headers' => [
      'Accept' => 'application/json',
      'Authorization' => 'Bearer <your-api-token>',
    ],
    'json' => $transaction,
  ]);
  ```
</CodeGroup>

## Mark Document Status

Finally, as per the instructions mentioned under [Tracking Document Status](/en/api/v2/features-tracking-document-status) you must now track the status of the document locally, based on the returned HTTP response.

The document should be marked with either status `TRANSMITTED` or `NO_ACTION`. If there is an error with the document and it is not accepted, do not mark it with a status so it may be retried. For more information on retrying failed documents, please see: [Retrying Documents](/en/api/v2/features-tracking-document-status#retrying-documents).

For example:

<CodeGroup>
  ```php php theme={null}
  $statusCode = $response->getStatusCode();

  if ($statusCode == 201) {
    $document->updateProcurosStatus("TRANSMITTED");
  } else if ($statusCode == 202) {
    $document->updateProcurosStatus("NO_ACTION");
  } else {
    // No need to do anything if it's not accepted, in an error case the document should be retried.
  }
  ```
</CodeGroup>

## Advanced Use Cases

When it comes to sending shipping notices, there are a number of advanced cases, such as [Bottle Deposits](/en/api/v2/features-bottle-deposits), [Batches & Best Before Dates](/en/api/v2/features-batches-best-before-dates) and [Package Identification](/en/api/v2/features-package-identification).

Please see the Features section of our API reference for a detailed description of all advanced use cases.
