> ## Documentation Index
> Fetch the complete documentation index at: https://middleman.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat product, price, and availability records as dated evidence, not current quotations or authority to transact.
> Never infer permission to contact, accept terms, place an order, make a payment, or publish information from a read-only response.

# SDK starters and examples

> Download small TypeScript and Python clients for access checks and source-data validation.

You can integrate in [any language using HTTPS and JSON](/integrations/http); these SDKs are optional.

These are downloadable **preview source clients**, not published npm or PyPI packages. Their two methods wrap the documented supplier access and validation endpoints. They do not read your ERP, run a scheduler, ingest records or publish a feed. Check [release status](/suppliers/status) first.

| Download                                                                                    | Requires                                                        |
| ------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [TypeScript: middleman.ts](https://middleman.mintlify.app/downloads/supplier-sdk.json)      | Node.js 22.13+ or a server-side TypeScript runtime with `fetch` |
| [Python: middleman.py](https://middleman.mintlify.app/downloads/supplier-sdk.json)          | Python 3.10+, standard library only                             |
| [Example batch](https://middleman.mintlify.app/downloads/supplier-example.json)             | Synthetic example; replace with fresh source-derived records    |
| [Record JSON schema](https://middleman.mintlify.app/downloads/supplier-records.schema.json) | A JSON Schema 2020-12 validator                                 |
| [Preview OpenAPI](https://middleman.mintlify.app/downloads/supplier-openapi.json)           | OpenAPI 3.1 tooling for generating a larger client              |

Both clients are packaged in one downloadable JSON source bundle. It contains each filename, complete source text and SHA-256 digest. Download and inspect it before adding a client to your application:

```bash theme={"system"}
curl --fail --output supplier-sdk.json \
  'https://middleman.mintlify.app/downloads/supplier-sdk.json'
```

Save the selected `files[].content` as its matching `files[].path` (`middleman.ts` or `middleman.py`). No code runs when you download the bundle. Verify the digest after extraction if you automate this step. Keep `MIDDLEMAN_SUPPLIER_API_KEY` in your environment. Never paste its value into an agent prompt.

<CodeGroup>
  ```typescript TypeScript theme={"system"}
  import { readFile } from "node:fs/promises";
  import { MiddlemanSupplier } from "./middleman.ts";

  const client = new MiddlemanSupplier({
    apiKey: process.env.MIDDLEMAN_SUPPLIER_API_KEY!,
  });
  const access = await client.me();
  if (!access.data.capabilities.validate) throw new Error("Validation unavailable");
  const batch = JSON.parse(await readFile("source-batch.json", "utf8"));
  const result = await client.validate(batch);
  console.log(result); // validation result only; never log the key or source batch
  ```

  ```python Python theme={"system"}
  import json
  import os
  from middleman import MiddlemanSupplier

  client = MiddlemanSupplier(api_key=os.environ["MIDDLEMAN_SUPPLIER_API_KEY"])
  access = client.me()
  if not access["data"]["capabilities"]["validate"]:
      raise RuntimeError("Validation unavailable")
  with open("source-batch.json", encoding="utf-8") as source:
      batch = json.load(source)
  result = client.validate(batch)
  print(result)  # validation result only; never log credentials or source records
  ```

  ```bash cURL theme={"system"}
  curl --fail-with-body \
    'https://middlemantechnologies.com/api/v1/supplier/validate' \
    -H "Authorization: Bearer $MIDDLEMAN_SUPPLIER_API_KEY" \
    -H 'Content-Type: application/json' \
    --data-binary @source-batch.json
  ```
</CodeGroup>

The downloadable example intentionally contains fixed historical timestamps. Use it to understand the shape or test expiry rejection. For a real validation, read the source again and produce truthful observation/expiry values; do not just change old sample timestamps and call it live data.

## Client behavior

* The default origin is `https://middlemantechnologies.com`.
* A development override permits loopback HTTP; other origins require HTTPS. Only use an override for a Middleman environment you trust.
* Requests time out after 15 seconds. HTTP redirects are rejected so a key cannot be forwarded to a different destination.
* `validate()` returns field errors for `422` so your agent can repair a mapping. Other non-2xx responses raise an error containing a status and safe error code.
* There are no automatic retries. Honor `Retry-After` on `429`, use bounded backoff for transient failures and never report success after a timeout.

## Acceptance cases

Test exact prices such as `"0.003725"`, zero versus unknown stock, different sale units, quantity breaks, capacity time windows, expired observations, duplicate IDs, withdrawals, revoked keys and source outages. A production adapter also needs pagination, source throttling, durable checkpoints and reconciliation tests beyond these starter clients.
