# DeliveryResponse Overview

The DeliveryResponse allows clients to receive status updates from the delivery service at the endpoint they have specified on the request.

Note: Consider the following:

- Your CallBack URL must be able to handle requests from both the CallbackHandler and the DeliveryResponse for two separate services: Generation and Delivery callback services.
- The request endpoint must be able to accept response messages from both the Generation and Delivery callback services.

## External Callback Overview

Users supply the Callback URL, Username, and Password with the SelectGenerateAndDeliver and Deliver API's to integrate with IEDocService in Expere Document Services.

The delivery service uses IDeliveryResponse to provide a series of status messages; see below. To use callbacks with SelectGenerateAndDeliver and Deliver API's, integrators should implement the "FulfillmentDeliveryResponse" response of the "IDeliveryResponse." Interface.

## Integrating with the DeliverResponse interface

    public class MyDeliveryCallbackService : DeliveryService.Contracts.V1.IDeliveryResponse
    {
     private readonly string _callbackLogLocation = WebConfigurationManager.AppSettings["CallbackLogLocation"];

    public DeliveryService.Contracts.V1.Data.DeliveryResponseOut FulfillmentDeliveryResponse(DeliveryService.Contracts.V1.Data.DeliveryResponseIn deliveryIn)
     {
     if (!Directory.Exists(_callbackLogLocation))
     {
     DirectoryInfo di = Directory.CreateDirectory(_callbackLogLocation);
     }
     var writeToFile = new List<string>();
     writeToFile.Add("************************************************");
     writeToFile.Add(DateTime.Now + " ---> " + deliveryIn.TransactionId + " - Combined Delivery Status Update Received");
     writeToFile.Add(DateTime.Now + " ---> " + deliveryIn.TransactionId + " - Delivery Request Status: " + deliveryIn.DeliveryRequestStatus);
     writeToFile.Add(DateTime.Now + " ---> " + deliveryIn.TransactionId + " - Delivery Details: " + deliveryIn.Details);
     writeToFile.Add(DateTime.Now + " ---> " + deliveryIn.TransactionId + " - Delivery TimeStamp: " + deliveryIn.TimeStamp);
     File.AppendAllLines(_callbackLogLocation + @"\" + "DeliveryCallbacks.txt", writeToFile);

     return new DeliveryResponseOut() { IsCallbackSuccess = true };
     }
    }

## Status Messages

The Callback will display the following status and details (separated by the"/" in the list below):

- Processing/Processing
- Printed/Printed
- Mailed/Mailed
- Delivery Attempt Made/Status Message
- Delivered/Status Message
- Undelivered/Status Message
- Returned/Status Message
- USPSStatus/Status Message
- Error/Error Message
- Tracking Number/Tracking ID
- Return Receipt

## Additional information - failed transactions and timeouts

If a failed transaction includes a callback URL, a callback is sent to the user indicating that the transaction has failed.

Typically, delivery calls are completed in one to two seconds, which update the user with the status of a package. However, if initial callback execution exceeds 15 seconds, an exception occurs indicating "timeout" or "listening;" at this point a retry occurs.

Note: The number of retries is set to "2."