> For the complete documentation index, see [llms.txt](https://help.orderdesk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.orderdesk.com/guided-walkthroughs/rules-and-automations/how-to-post-order-information-to-a-custom-script.md).

# How to Post Order Information to a Custom Script

With Order Desk, you can post order information to a custom script using the [Rule Builder](/guided-walkthroughs/rules-and-automations/how-to-work-with-rules.md). One of the rule actions that can be triggered on an event of your choice is to send order details to a third-party endpoint.

This is helpful if you want to keep track of inventory or perform a custom function when something happens to an order—when a shipment is added or it’s put in the Closed folder, as examples. The action in the rule builder for this is called **Post Order JSON**:

![](/files/iIckPmIuVuDyXFhGRW87)

You can also choose whether to include the order’s history in the data being posted by setting the **Include History** option to **Yes**.

### Format

The order data will be sent in JSON format via POST to your custom URL with the field name *order*.

The format will be using Order Desk field names, for a reference to these, [click here](/resources/order-desk-field-names.md).

### Testing

The easiest way to test this functionality and see the data returned is to set up a temporary request bin at a service like [Mockbin](https://mockbin.org/).

Set up your rule and use the testing mechanism to send order data to this URL. You can then inspect it to see exactly what you will be getting from Order Desk.

To send immediately, after you perform the test, go to your [View Appointments](https://app.orderdesk.com/tools/appointments) page and run the pending **Send Order To Website** action:

![](/files/6JXgOLlyKFDkidqr4pqn)

If there’s an error, you’ll see the response returned.

While testing, you may want to set your response status code to 400 so you can continue to run the appointment over and over while making sure everything returns correctly.

### Response

Order Desk expects your script to return a status code of 200 or 201. If your script returns a status code higher than 201, the post will be considered failed and will be retried up to five times over the course of two hours.

**A timeout will occur after 30 seconds and will last 10 seconds before the next try.**

After the two hours has elapsed, you will need to manually resubmit your request from the [View Appointments](https://app.orderdesk.com/tools/appointments) page.

### Security

Order Desk will pass in an “X-ORDER-DESK-STORE-ID” header with the ID of your store. You can use this to help avoid any spoofing.

For extra security, set an API key and another header will be set called “X-ORDER-DESK-HASH”. This will be an hmac encoded string of the order value being posted.

Here is sample PHP code to ensure that the posted order details came from Order Desk:

### Embedded code sample

```
<?php
//Check For Order
if (!isset($_POST['order'])) {
        header(':', true, 400);
        die('No Data Found');
}
 
//Cbeck Store ID
//Be sure to set your store ID. Ask Order Desk support if you aren't sure what it is.
if (!isset($_SERVER['HTTP_X_ORDER_DESK_STORE_ID']) || $_SERVER['HTTP_X_ORDER_DESK_STORE_ID'] != "YOUR-STORE-ID") {
        header(':', true, 403);
        die('Unauthorized Request');
}
 
//Check the Hash (optional)
//The API Key can be found in the Advanced Settings section. Order Desk Pro only
if (!isset($_SERVER['HTTP_X_ORDER_DESK_HASH']) || hash_hmac('sha256', $_POST['order'], 'YOUR_API_KEY') !== $_SERVER['HTTP_X_ORDER_DESK_HASH']) {
        header(':', true, 403);
        die('Unauthorized Request');
}
 
//Check Order Data
$order = json_decode($_POST['order'], 1);
if (!is_array($order)) {
        header(':', true, 400);
        die('Invalid Order Data');
}
 
//Everything Checks Out -- do your thing
echo "<pre>" . print_r($order, 1) . "</pre>";
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://help.orderdesk.com/guided-walkthroughs/rules-and-automations/how-to-post-order-information-to-a-custom-script.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
