> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/admin/orders/order-agreements.md).

# Order Agreements

A **read-only** administrative endpoint for **order agreements** — the legal contracts captured at checkout and stored against an order. Turkish distance-selling law requires two documents per order: the Preliminary Information Form (`info`) and the Distance Sales Agreement (`sales`). Each is rendered to HTML at order time and stored as a file, producing one order-agreement record per contract type per order.

The endpoint exposes only **list** and **retrieve** — order agreements are created by the checkout flow, never through this API, and cannot be updated or deleted here. Retrieving an agreement fetches the stored contract document and returns its full text alongside the metadata.

### Core Capabilities

**1. Agreement Listing & Filtering**

* Retrieve a paginated list of all order agreements.
* Filter by `order_number` or `order_id` to find the agreements captured for a specific order, or by `contract_type` to select a document type.
* Order results with the `sort` parameter.

**2. Agreement Retrieval**

* Retrieve a single order agreement, including the full contract text.

### Order Agreement Fields

| Field              | Type         | Description                                                                                                                                   |
| ------------------ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `order_id`         | string       | The identifier of the order the agreement belongs to.                                                                                         |
| `url`              | string (URI) | URL of the stored contract document.                                                                                                          |
| `type`             | string enum  | The contract type: `info` (Preliminary Information Form) or `sales` (Distance Sales Agreement).                                               |
| `contract_content` | string       | The full text of the contract document, fetched from the document store at read time. An empty string if the document could not be retrieved. |

### Filtering & Ordering

| Parameter       | Match | Notes                                                        |
| --------------- | ----- | ------------------------------------------------------------ |
| `order_number`  | Exact | Keep only agreements whose order has the given order number. |
| `order_id`      | Exact | Keep only agreements for the given order identifier.         |
| `contract_type` | Exact | Filter by contract type (`info` or `sales`).                 |

Use the `sort` query parameter to order the results; prefix with `-` for descending.

### Dynamic Settings & Environment Variables

No dynamic settings (`dj_dynamic_settings`) affect these endpoints.

**Environment variables / Django settings** — the `contract_content` field is populated by fetching the stored document over HTTP at serialization time. The document URL is built from:

| Setting                      | Type   | Effect                                                                            |
| ---------------------------- | ------ | --------------------------------------------------------------------------------- |
| `AWS_S3_BUCKET_URL_TEMPLATE` | string | When set, used as the URL template for the stored contract document.              |
| `AWS_STORAGE_BUCKET_NAME`    | string | Fallback bucket name used to build the document URL when the template is not set. |

If the document cannot be fetched, `contract_content` is returned as an empty string; the rest of the record is unaffected.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/commerce-openapis/admin/orders/order-agreements.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
