# Orders API

## Overview

The Daasity transformation code maps data from the Amazon Seller Central schema into the Unified Order Schema (UOS) for sales data

## Feature Dependencies

You must have enabled our [Code Repository](/technical-docs/transform-code/code-repository.md) feature in order to both access the Daasity transformation code as well as modify a Script Manifest File enabling this code to execute

We recommend you review the [Transformation Configuration](/technical-docs/workflows-and-scheduling/script-manifest-yaml-files.md) section of our Help documentation to familiarize yourself with our workflow engine and script manifest files.

## Script Manifest File (YML)

### Upstream Transformation Dependencies

{% hint style="danger" %}

This code is dependent on the following integration being installed:

* Amazon Orders API
* Amazon Flat File Orders by Last Update Report
* FBA Amazon Fulfilled Shipments Report *(required for AFN orders; used to supplement buyer email, buyer name, and shipping name when not available from the Orders API)*

This code block is dependent on the following upstream code blocks being implemented:

* Initialization
  {% endhint %}

### Transformation Code Requirements

To enable the data transformation from the Amazon Seller Central schema into UOS, the following code must be run in a workflow:

```
  uos_amazon_selling_partner:
    integrations:
      - amazon_selling_partner
    scripts:
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0540_UOS_BAS_AMAZON_locations.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0542_UOS_BAS_AMAZON_customers.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0543_UOS_BAS_AMAZON_products.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0544_UOS_BAS_AMAZON_product_variants.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0545_UOS_BAS_AMAZON_orders.sql"
ℹ️ Note: This script generates the customer ID and populates buyer email, buyer name, and shipping name for Amazon orders. For Amazon-fulfilled (AFN) orders, these fields are now sourced from the FBA Amazon Fulfilled Shipments Report (AMAZON_SELLER_CENTRAL.GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL) when not available in the Orders API data. Merchant-fulfilled (MFN) orders continue to use the existing data source. This change improves customer identification accuracy for AFN orders.
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0546_UOS_BAS_AMAZON_order_line_items.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0549_UOS_BAS_AMAZON_order_payments.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0550_UOS_BAS_AMAZON_transactions.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0553_UOS_BAS_AMAZON_fulfillments.sql"
      - "github://platform-sql-shared/scripts/base/0500_uos/amazon_selling_partner/0554_UOS_BAS_AMAZON_order_item_fulfillments.sql"
      - "github://platform-sql-internal/scripts/base/0500_uos/amazon_selling_partner/0557_UOS_BAS_AMAZON_sales_report.sql"
```

### Unified Order Schema

Code to populate the UOS tables with sales data from Amazon

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0540_UOS_BAS_AMAZON_locations.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0542_UOS_BAS_AMAZON_customers.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0543_UOS_BAS_AMAZON_products.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0544_UOS_BAS_AMAZON_product_variants.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0545_UOS_BAS_AMAZON_orders.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0546_UOS_BAS_AMAZON_order_line_items.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0549_UOS_BAS_AMAZON_order_payments.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0550_UOS_BAS_AMAZON_transactions.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0553_UOS_BAS_AMAZON_fulfillments.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/0500_uos/amazon_selling_partner/0554_UOS_BAS_AMAZON_order_item_fulfillments.sql>


---

# 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://help.daasity.com/core-concepts/data-integrations/setup-guides/digital-integrations/amazon-seller-central/transformation-configuration-setup/orders-api.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.
