> For the complete documentation index, see [llms.txt](https://docs.waveline.ai/extract/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.waveline.ai/extract/examples/order-table-extraction.md).

# Order Table Extraction

In this example, we are a company that sells many different products. Our customer sends us a small table of all the items they want to buy. However, since the customer creates the table, it can look slightly different every time. For example, they write Product ID instead of `product_id`, `Qty` instead of `Quantity`, and the shipping times have no clear structure.

<table><thead><tr><th width="188">Product ID</th><th width="133.33333333333331">Qty</th><th width="124">Unit price</th><th>Manufacturar</th><th>Shipping Time</th></tr></thead><tbody><tr><td>TZX22-EHZ2</td><td>100</td><td>2.76$</td><td>Tusp</td><td>1-2 days</td></tr><tr><td>ZUI23-772L6</td><td>250</td><td>5.00$</td><td>-</td><td>1 week</td></tr><tr><td>UIUU-13BMW</td><td>340'000</td><td>0.001$</td><td>puma</td><td>About a month</td></tr><tr><td>QUE2-AIME2</td><td>56</td><td>45.56$</td><td>lebra</td><td>Tomorrow</td></tr></tbody></table>

{% file src="/files/B7ZLbkf1MlEAzPskHf5S" %}

Waveline Extract makes it easy to unify these fields into one format we define.

Let's construct a [Shape](/extract/types/shape.md) to extract `product_id`, `unit_price`, `quantity`**,** and `shipping_time` for each product:

```json
[
  {
    "name": "products",
    "type": "object",
    "description": "All products from the table",
    "isArray": true,
    "elements": [
      {
        "name": "product_id",
        "type": "string",
        "description": "The id of that product. aka product number",
        "isArray": false
      },
      {
        "name": "quantity",
        "type": "number",
        "description": "Quantity of how many units. Aka Qty",
        "isArray": false
      },
      {
        "name": "unit_price",
        "type": "number",
        "description": "Unit price of that product in dollars",
        "isArray": false
      },
      {
        "name": "shipping_time",
        "type": "string",
        "description": "Time it takes to ship this product. (In days)",
        "isArray": false
      }
    ]
  }
]
```

We can now call the [`/extract-document`](/extract/endpoints/extract-document.md) endpoint with this shape and the table as the payload to create the job:

```bash
curl -X POST "https://waveline.ai/api/v1/extract-document" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{
          "fileName": "OrderTable.txt",
          "contentType": "application/pdf",
          "base64Content": "JVBERi0xLjMKMSAwIG9iago8PC9UeXBlL0NhdGF...",
          "shape": YOUR_SHAPE
        }'
```

After some time, we query for the result of this job with the [job](/extract/endpoints/jobs-id.md) endpoint and get the following in the `result` field:

```json
{
  "products": [
    {
      "product_id": "TZX22-EHZ2",
      "quantity": "100",
      "unit_price": 2.76,
      "shipping_time": "1-2 days"
    },
    {
      "product_id": "ZUI23-772L6",
      "quantity": "250",
      "unit_price": 5,
      "shipping_time": "1 week"
    },
    {
      "product_id": "UIUU-13BMW",
      "quantity": "340000",
      "unit_price": 0.001,
      "shipping_time": "About a month"
    },
    {
      "product_id": "QUE2-AIME2",
      "quantity": "56",
      "unit_price": 45.56,
      "shipping_time": "Tomorrow"
    }
  ]
}
```

As we can see above, all the fields have successfully been unified into the format we defined!


---

# 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://docs.waveline.ai/extract/examples/order-table-extraction.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.
