# Transaction Delivery

### Delivery Request

Once the transaction has been created, you will need to request initialization of transaction delivery using this API. Delivery request can be initiated in the following scenarios:

* Transaction Status is in PENDING or PROCESSED state
* Transaction 'Type' is DEFAULT i.e. Not a REFUND transaction

Until delivery is requested and approved, the transaction will not be forwarded for payout.&#x20;

#### `PATCH /users/{{user_id}}/transactions/delivery-requests/{{transaction_id}}`

{% tabs %}
{% tab title="Details" %}
**Delivery Request Object**

|                 |              |          |                                                             |
| --------------- | ------------ | -------- | ----------------------------------------------------------- |
| **Field**       | **Required** | **Type** | **Description**                                             |
| status          | Yes          | String   | Enumerated Value : DELIVERY\_REQUESTED                      |
| comment         | No           | String   | Comment / reason for requesting delivery                    |
| transaction\_id | Yes          | UUID     | ID of the transaction for which delivery is being requested |
| user\_id        | Yes          | UUID     | ID of the user who created the transaction                  |
| {% endtab %}    |              |          |                                                             |

{% tab title="Request sample" %}

```
curl --location -g --request PATCH '{{url}}/users/{{user_id}}/transactions/delivery-requests/{{transaction_id}}' \
--header 'X-Client-Id: {{client_id}}' \
--header 'X-Client-Secret: {{client_secret}}' \
--header 'Content-Type: application/json' \
--data-raw '{
  "status": "DELIVERY_REQUESTED",
  "comment": "string"
}'
```

{% endtab %}

{% tab title="Response sample" %}

```
Http status 204 (No Content)
```

{% endtab %}
{% endtabs %}

### Delivery Status

For clients using their own payout network to deliver a transaction, the status of the delivery needs to be updated on our system using this API. Statuses need to be updated to DELIVERED for completed transactions and DELIVERY\_FAILED for transactions which could not be completed.&#x20;

#### `POST /users/{{user_id}}/transactions/{{transaction_id}}/delivery-details`

{% tabs %}
{% tab title="Details" %}

|                   |              |          |                                                                           |
| ----------------- | ------------ | -------- | ------------------------------------------------------------------------- |
| **Field**         | **Required** | **Type** | **Description**                                                           |
| status            | Yes          | String   | Enumerated Value : DELIVERED, DELIVERY\_FAILED                            |
| transaction\_id   | Yes          | UUID     | ID of transaction for which delivery status is being changed.             |
| user\_id          | Yes          | UUID     | ID of the user who created the transaction                                |
| date\_delivered   | No           | String   | Date and time when the transaction was delivered (yyyy-mm-ddThh:mm:ss.ms) |
| reference\_number | No           | String   | Client's reference number of the transaction                              |
| {% endtab %}      |              |          |                                                                           |

{% tab title="Request Sample" %}

```
curl --location --request POST '{{url}}/users/{{user_id}}/transactions/{{transaction_id}}/delivery-details
--header 'X-Client-Id: {{client_id}}' \
--header 'X-Client-Secret: {{client_secret}}' \
--header 'Content-Type: application/json' \
--data-raw '{
	"date_delivered" : "2022-12-21T22:28:22.261767",
	"status" : "DELIVERED",
	"reference_number" : 5657575
}
```

{% endtab %}

{% tab title="Response Sample" %}

```
Http status 204 (No Content)
```

{% endtab %}
{% endtabs %}


---

# 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://paas.docs.machnetinc.com/api-references/transaction/transaction-delivery.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.
