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

# Quickstart

> A working call in about five minutes, against a sandbox filled with demo data.

A sandbox is a copy of the product filled with demo data. Nothing you do there touches your live data.

## 1. Create a sandbox

In the app, open [Sandbox](https://insightchain.ai/dashboard/sandbox) and choose Create sandbox. An organization admin does this once. It takes a few minutes to fill: about 800 items, 200 suppliers and 20 locations, with purchase orders, sales orders, product passports and sensor reads.

## 2. Create a test key

Open [API keys](https://insightchain.ai/dashboard/api-keys) and create a key with the environment Test and the scope `read`. Copy it: it starts with `ic_test_` and is shown once. A test key reaches the sandbox and nothing else.

## 3. SDKs

There is an SDK for TypeScript and JavaScript (Node 18 or newer) and one for Python (3.9 or newer). Neither has dependencies.

The SDK packages are being released to the public registries. Until the install commands are shown here, do not install a package of these names from anywhere else. Make the calls with cURL, as in the next steps; the TypeScript and Python samples on this site apply unchanged once the SDK is installed.

## 4. Make the first call

Put the key in `INSIGHTCHAIN_API_KEY`. Every sample on this site reads it from there.

```bash theme={null}
export INSIGHTCHAIN_API_KEY="ic_test_..."
```

Then list what the sandbox proposes.

```bash cURL theme={null}
curl "https://api.insightchain.ai/v1/recommendations?status=proposed&limit=5" \
  -H "Authorization: Bearer $INSIGHTCHAIN_API_KEY"
```

```typescript TypeScript theme={null}
import { InsightChain } from "@insightchain/sdk";

const client = new InsightChain(); // reads INSIGHTCHAIN_API_KEY

const page = await client.listRecommendations({ status: "proposed", limit: 5 });
for (const rec of page.data) {
  console.log(rec.id, rec.kind, rec.status, rec.priority);
}
console.log("more:", page.has_more);
```

```python Python theme={null}
from insightchain import InsightChain

client = InsightChain()  # reads INSIGHTCHAIN_API_KEY

page = client.list_recommendations(status="proposed", limit=5)
for rec in page["data"]:
    print(rec["id"], rec["kind"], rec["status"], rec["priority"])
print("more:", page["has_more"])
```

Every answer to a test key carries the header `X-InsightChain-Sandbox: true`.

## 5. Page through a list

A list answers one page: `data`, `has_more` and `next_cursor`. For the next page, send `next_cursor` as `cursor`; stop when `has_more` is false. In an SDK, each list method has a companion that walks every page for you.

```bash cURL theme={null}
# The first page
curl "https://api.insightchain.ai/v1/recommendations?status=proposed&limit=50" \
  -H "Authorization: Bearer $INSIGHTCHAIN_API_KEY"

# The next page: next_cursor of that answer, sent as cursor. Stop when has_more is false.
curl "https://api.insightchain.ai/v1/recommendations?status=proposed&limit=50&cursor=$NEXT_CURSOR" \
  -H "Authorization: Bearer $INSIGHTCHAIN_API_KEY"
```

```typescript TypeScript theme={null}
import { InsightChain } from "@insightchain/sdk";

const client = new InsightChain();

let count = 0;
for await (const rec of client.listRecommendationsAll({ status: "proposed", limit: 50 })) {
  count += 1;
  console.log(rec.id, rec.kind, rec.priority);
}
console.log(`${count} proposed recommendations`);
```

```python Python theme={null}
from insightchain import InsightChain

client = InsightChain()

count = 0
for rec in client.list_recommendations_all(status="proposed", limit=50):
    count += 1
    print(rec["id"], rec["kind"], rec["priority"])
print(count, "proposed recommendations")
```

## 6. Handle an error

A call that fails answers the error object: the API's `code`, which is stable, and the `request_id`, with the HTTP status. An SDK throws an error that carries all three. Every code is in the [error reference](/docs/errors.md).

```bash cURL theme={null}
# No recommendation has this id: the API answers 404 and the error object.
curl -i "https://api.insightchain.ai/v1/recommendations/00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer $INSIGHTCHAIN_API_KEY"
```

```typescript TypeScript theme={null}
import { InsightChain, InsightChainError } from "@insightchain/sdk";

const client = new InsightChain();

try {
  // No recommendation has this id: the API answers 404.
  await client.getRecommendation({ id: "00000000-0000-0000-0000-000000000000" });
} catch (err) {
  if (!(err instanceof InsightChainError)) throw err;
  console.log("status:", err.status);
  console.log("code:", err.code);
  console.log("request_id:", err.requestId);
}
```

```python Python theme={null}
import insightchain

client = insightchain.InsightChain()

try:
    # No recommendation has this id: the API answers 404.
    client.get_recommendation("00000000-0000-0000-0000-000000000000")
except insightchain.InsightChainError as err:
    print("status:", err.status)
    print("code:", err.code)
    print("request_id:", err.request_id)
```

To see the call from our side, open [API requests](https://insightchain.ai/dashboard/api-requests) in the app and search for that request id: the route, the status, the error code and how long it took.

## 7. Go live

Create a live key on the [API keys](https://insightchain.ai/dashboard/api-keys) page and swap it in. The base URL, the routes and your code stay the same.

```bash theme={null}
export INSIGHTCHAIN_API_KEY="ic_live_..."
```

## What a sandbox does not do

A sandbox holds the demo data plus what you push. It raises no alerts, and some reads that depend on your history answer empty. Routes that use AI have a budget of 25 calls a day. A webhook registered with a test key receives test events only.

## Next

* [Recipes](/docs/recipes.md): one job each, with the scopes, the steps and what comes back.
* The API reference tab: every route, its scope and its parameters.
* [Errors](/docs/errors.md): the error object and every code.
* [Connect an AI client](/docs/agents.md): the same operations as tools for an assistant.
* [Changelog](/docs/changelog.md): every change a caller can see.
* [Postman collection](https://insightchain.ai/postman_collection.json): import the file into Postman, then set the collection variables `apiKey` (your key) and `baseUrl` (already `https://api.insightchain.ai/v1`).
* [openapi.json](https://insightchain.ai/openapi.json): the API description the SDKs are generated from.
* [Status](https://status.insightchain.ai): whether the API is up right now.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.