# Export COGS (cost of goods) for every order line in a date range, JSON or CSV

> Eto API reference for `GET /api/v1/costs`. Base URL `https://eto.tools/api/v1/`. Authenticate with the `X-Eto-API-Key` header.

Part of the [Eto API reference](https://eto.tools/dev/docs/). The full reference in one file is at [llms-full.txt](https://eto.tools/dev/docs/llms-full.txt); the machine-readable schema is at [openapi.json](https://eto.tools/dev/docs/openapi.json).

## GET /api/v1/costs

Export COGS (cost of goods) for every order line in a date range, JSON or CSV

- Operation ID: `costs_export`
- Slug: `costs-export`
- Category: Orders
- Authentication: API key only. Reads or writes data Eto holds for your own account.
- HTML: https://eto.tools/dev/docs/#ep-costs-export
- Markdown: https://eto.tools/dev/docs/orders/costs-export.md

Every order line in a date range with what it cost you, newest order first, across all your stores or one (`shop_id`). Pick the range like finance: `period` (today, yesterday, last_7_days, last_30_days, this_month, last_month; default last_30_days) or `start_date`/`end_date` (YYYY-MM-DD, inclusive), in `timezone` (default the shop's). Up to 366 days. `status=missing` lists only the lines with no cost yet (the to-do list for a COGS bot), `configured` only the costed ones. `format=json` (default) pages with `limit` (1-1000, default 500) and `offset` and adds `totals` for the WHOLE range: `cogs_cents_by_currency` (one figure per currency, never a mixed sum), `lines_configured`, `lines_missing`, `lines_total`. Each line has `shop_id`, `receipt_id`, `order_date`, `transaction_id`, `listing_id`, `sku`, `title`, `quantity`, `currency`, the raw `item_cost_cents`/`unit_costs_cents`, the effective `cost_cents` and `configured` (false = no cost entered; such a line reports cost_cents 0 and is left out of totals). `format=csv` streams the whole range as a file with the columns shop_id, order_number, order_date, transaction_id, listing_id, sku, title, quantity, currency, cost, unit_costs, configured. Fill in `cost` and POST the same file to /api/v1/costs/import. Zero Etsy calls.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `shop_id` | query | `string` | no | Only this connected store (default: all your stores) |
| `period` | query | `string` | no | today, yesterday, last_7_days, last_30_days, this_month, last_month |
| `start_date` | query | `string` | no | First day "YYYY-MM-DD" (inclusive) |
| `end_date` | query | `string` | no | Last day "YYYY-MM-DD" (inclusive) |
| `timezone` | query | `string` | no | IANA timezone for the days (default the shop's) |
| `status` | query | `string` | no | all (default), missing (no cost yet) or configured One of: `all`, `missing`, `configured`. |
| `format` | query | `string` | no | json (default) or csv One of: `json`, `csv`. |
| `limit` | query | `integer` | no | JSON: lines per page, 1-1000 (default 500) |
| `offset` | query | `integer` | no | JSON: lines to skip |

### Request

```bash
curl -H "X-Eto-API-Key: eto_your_key" "https://eto.tools/api/v1/costs?period=last_month&status=missing"
```

```python
import requests

url = "https://eto.tools/api/v1/costs?period=last_month&status=missing"
headers = {"X-Eto-API-Key": "eto_your_key"}

response = requests.get(url, headers=headers, timeout=120)
response.raise_for_status()
print(response.json())
```

```javascript
const url = "https://eto.tools/api/v1/costs?period=last_month&status=missing";

const response = await fetch(url, {
  method: "GET",
  headers: {
    "X-Eto-API-Key": "eto_your_key",
  },
});
if (!response.ok) throw new Error(`Eto API ${response.status}`);
const data = await response.json();
```

### Response

```json
{
  "range": {"start": 1793491200, "end": 1796169600, "timezone": "Europe/London", "label": "last month"},
  "shop_id": null,
  "status": "missing",
  "lines": [
    {"shop_id": "12345678", "receipt_id": 3456789012, "order_date": "2026-10-30",
     "created_timestamp": 1793400000, "transaction_id": 4123456790, "listing_id": 1789456124,
     "sku": "MUG-01", "title": "Enamel mug", "quantity": 1, "currency": "GBP",
     "item_cost_cents": null, "unit_costs_cents": null, "cost_cents": 0, "configured": false}
  ],
  "totals": {"cogs_cents_by_currency": {"GBP": 184250}, "lines_configured": 212,
             "lines_missing": 1, "lines_total": 213},
  "pagination": {"limit": 500, "offset": 0, "count": 1, "total": 1, "next_offset": null}
}
```

### Errors

Failures answer with the shared error body described in the Errors section: `{"error": {"code", "status", "message", "hint", "docs"}}`. Branch on `code`, not on the message.
