---
title: "Admin API guide"
description: "Call the EdgeCart Admin API with the typed client or a raw request."
---

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

# Admin API guide

The Admin API powers the EdgeCart back office. Use it to automate catalog,
orders, fulfillment, payments, customers, promotions, and store setup.

> **Reference coverage**
>
> The generated [API reference](https://edgecart.dev/api) currently covers Storefront operations.
> Admin routes are available through the typed client below and the shared
> [API conventions](https://edgecart.dev/reference/api-conventions).

## Credentials

Every request needs:

- a signed-in store member's Better Auth session cookie, and
- the `x-store-id` header.

The browser admin sends both automatically. A server-side integration must
forward the cookie; do not use a secret key as an admin session.

## Typed client

```ts
import { createAdminApi } from "@edgecart/admin-api";

const api = createAdminApi({ storeId: "store_123" });

const { products, count } = await api.products.list({ limit: 20, q: "cap" });
const product = await api.products.create({ title: "Cap" });
await api.products.update(product.id, { status: "published" });

const { orders } = await api.orders.list({ status: "pending", limit: 20 });
const order = await api.orders.get(orders[0].id);

const fulfillment = await api.orders.fulfillments.create(order.id, {
  items: [{ id: order.items[0].id, quantity: 1 }],
});
await api.fulfillments.ship(fulfillment.id, {
  tracking_numbers: ["TRACK"],
});
```

Resource methods unwrap list envelopes, so the result is the DTO collection
(`{ products, count }`) rather than the raw response.

## Raw requests

`createAdminRequest` is the escape hatch for routes that do not have a resource
helper yet:

```ts
import { createAdminRequest } from "@edgecart/admin-api";

const admin = createAdminRequest({
  storeId: "store_123",
  apiBaseUrl: "https://shop.example/api",
});

const { products } = await admin<{ products: Product[] }>("/products");
await admin("/products", {
  method: "POST",
  body: { title: "Cap" },
  idempotencyKey: crypto.randomUUID(),
});
```

## Uploads

```ts
import { uploadAdminImage } from "@edgecart/admin-api";

await uploadAdminImage({ storeId: "store_123" }, file);
```

The helper posts the file to the uploads route and returns the stored image.

## Errors

Non-2xx responses become `AdminApiError` with `status`, `type`, and `code`.
Cross-store access returns `404`; validation errors return `400` with a
`type`/`code` pair. See [API conventions](https://edgecart.dev/reference/api-conventions).

## Pagination and fields

List endpoints accept `offset` and `limit` and return
`{ <plural>, count, offset, limit }`. Some endpoints accept `fields=` to select
a subset of fields.

## Related

- [API reference](https://edgecart.dev/api)
- [Auth, roles & API keys](https://edgecart.dev/developers/auth)
- [Storefront API guide](https://edgecart.dev/developers/storefront-api)

Source: https://edgecart.dev/developers/admin-api/index.mdx
