# Warehouses

Manage the warehouse addresses that orders ship from.

**Scopes:** `GET` endpoints need `read:warehouses`. `POST`, `PUT`, and `DELETE` need `write:warehouses`. A **Shipping API** key (`read:*`, `write:*`) has both. See [Authentication](authentication.md#scopes).

Warehouse responses can include fields that aren't listed on this page. Rely only on the documented fields; undocumented fields can change or be removed without notice.

## The Warehouse Object

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Warehouse ID |
| `name` | string | Warehouse name |
| `isDefault` | boolean | Whether this is marked as a default warehouse |
| `storeId` | string \| null | Store the warehouse is associated with, if any |
| `shopifyLocationId` | string \| null | Linked Shopify location ID, for warehouses synced from Shopify |
| `addressId` | string | ID of the warehouse's address |
| `address` | object | The warehouse address (below) |
| `createdAt` | string | ISO 8601 creation time |
| `updatedAt` | string | ISO 8601 time of the last change |

**Address object:**

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Address ID |
| `name` | string \| null | Name on the address. Defaults to the warehouse name. |
| `street1` | string | Street line 1 |
| `street2` | string \| null | Street line 2 |
| `city` | string | City |
| `state` | string | State or province |
| `zip` | string | Postal code |
| `country` | string | Country code, for example `US` |
| `phone` | string \| null | Phone number |
| `email` | string \| null | Email address |

## List Warehouses

```
GET /api/v1/warehouses
```

Returns all of your warehouses as a single array, newest first. This endpoint is not paginated.

### Example

```bash
curl https://shipwave.app/api/v1/warehouses \
  -H "Authorization: Bearer sw_live_abc123..."
```

```typescript
const res = await fetch("https://shipwave.app/api/v1/warehouses", {
  headers: { Authorization: "Bearer sw_live_abc123..." },
});
const { data } = await res.json();
```

### Response

```json
{
  "data": [
    {
      "id": "clw9wh1",
      "name": "Main Warehouse",
      "isDefault": true,
      "storeId": null,
      "shopifyLocationId": null,
      "addressId": "clw9addr1",
      "createdAt": "2026-01-10T12:00:00.000Z",
      "updatedAt": "2026-02-01T08:30:00.000Z",
      "address": {
        "id": "clw9addr1",
        "name": "Main Warehouse",
        "street1": "500 Commerce Dr",
        "street2": "Suite 100",
        "city": "Portland",
        "state": "OR",
        "zip": "97201",
        "country": "US",
        "phone": "503-555-0100",
        "email": "warehouse@example.com"
      }
    }
  ]
}
```

---

## Create Warehouse

```
POST /api/v1/warehouses
```

### Request Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | yes | Warehouse name |
| `address` | object | yes | Warehouse address (below) |
| `isDefault` | boolean | no | Mark as a default warehouse (default `false`) |
| `storeId` | string | no | Associate with one of your stores |

**Address object:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `name` | string | no | Defaults to the warehouse `name` |
| `street1` | string | yes | |
| `street2` | string | no | |
| `city` | string | yes | |
| `state` | string | yes | |
| `zip` | string | yes | |
| `country` | string | no | Defaults to `US` |
| `phone` | string | no | |
| `email` | string | no | |

An account has one default warehouse. Creating a warehouse with `isDefault: true` makes it the default and clears `isDefault` on your other warehouses.

### Example

```bash
curl -X POST https://shipwave.app/api/v1/warehouses \
  -H "Authorization: Bearer sw_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "East Coast Warehouse",
    "address": {
      "street1": "200 Industrial Pkwy",
      "city": "Newark",
      "state": "NJ",
      "zip": "07102",
      "country": "US",
      "phone": "973-555-0200"
    },
    "isDefault": false
  }'
```

```typescript
const res = await fetch("https://shipwave.app/api/v1/warehouses", {
  method: "POST",
  headers: {
    Authorization: "Bearer sw_live_abc123...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "East Coast Warehouse",
    address: {
      street1: "200 Industrial Pkwy",
      city: "Newark",
      state: "NJ",
      zip: "07102",
      country: "US",
      phone: "973-555-0200",
    },
    isDefault: false,
  }),
});
const { data } = await res.json(); // 201 Created
```

### Response (201 Created)

Returns the new [warehouse object](#the-warehouse-object), including its `address`.

### Errors

| Status | Code | Cause |
|--------|------|-------|
| 400 | `VALIDATION_ERROR` | The body is missing or isn't valid JSON (`Invalid request body`) |
| 400 | `VALIDATION_ERROR` | A required field is missing: `name is required`, `address is required`, `address.street1 is required`, `address.city is required`, `address.state is required`, or `address.zip is required` |
| 404 | `NOT_FOUND` | `storeId` isn't one of your stores (`Store not found`) |
| 400 | `VALIDATION_ERROR` | A field has the wrong type (for example `isDefault must be a boolean`) |

---

## Get Warehouse

```
GET /api/v1/warehouses/:id
```

Returns one [warehouse object](#the-warehouse-object) with its address.

### Example

```bash
curl https://shipwave.app/api/v1/warehouses/clw9wh1 \
  -H "Authorization: Bearer sw_live_abc123..."
```

### Errors

| Status | Code | Cause |
|--------|------|-------|
| 404 | `NOT_FOUND` | No warehouse with this ID on your account. A warehouse that belongs to another account also returns 404. |

---

## Update Warehouse

```
PUT /api/v1/warehouses/:id
```

Updates an existing warehouse. Send only the fields you want to change; omitted fields keep their current values. Returns the updated [warehouse object](#the-warehouse-object).

### Request Body

| Field | Type | Description |
|-------|------|-------------|
| `name` | string | Warehouse name |
| `isDefault` | boolean | `true` makes this the default warehouse and clears `isDefault` on your other warehouses. Must be a boolean. |
| `address` | object | Any of `name`, `street1`, `street2`, `city`, `state`, `zip`, `country`, `phone` |

`storeId` can't be changed with this endpoint; it is ignored if sent.

### Example

```bash
curl -X PUT https://shipwave.app/api/v1/warehouses/clw9wh1 \
  -H "Authorization: Bearer sw_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Main Warehouse (Updated)",
    "address": {
      "phone": "503-555-0199"
    }
  }'
```

```typescript
const res = await fetch("https://shipwave.app/api/v1/warehouses/clw9wh1", {
  method: "PUT",
  headers: {
    Authorization: "Bearer sw_live_abc123...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Main Warehouse (Updated)",
    address: { phone: "503-555-0199" },
  }),
});
const { data } = await res.json();
```

### Errors

| Status | Code | Cause |
|--------|------|-------|
| 400 | `VALIDATION_ERROR` | The body is missing or isn't valid JSON (`Invalid request body`) |
| 404 | `NOT_FOUND` | No warehouse with this ID on your account. A warehouse that belongs to another account also returns 404. |
| 400 | `VALIDATION_ERROR` | A field has the wrong type, or `name` or a required address field is empty or `null` |

---

## Delete Warehouse

```
DELETE /api/v1/warehouses/:id
```

Permanently deletes a warehouse that nothing uses yet. If the warehouse still has stock records, bin locations, or orders assigned to it, the request returns `409 CONFLICT` with the counts in `details` and nothing is deleted. Reassign or remove those in ShipWave first. The same `409` is returned if other records, such as fulfillment assignments or a connected marketplace ship node, still depend on it.

### Example

```bash
curl -X DELETE https://shipwave.app/api/v1/warehouses/clw9wh2 \
  -H "Authorization: Bearer sw_live_abc123..."
```

### Response

```json
{
  "data": {
    "id": "clw9wh2",
    "deleted": true
  }
}
```

### Errors

| Status | Code | Cause |
|--------|------|-------|
| 404 | `NOT_FOUND` | No warehouse with this ID on your account. A warehouse that belongs to another account also returns 404. |
| 409 | `CONFLICT` | The warehouse still has stock records, bins, or orders, or other records depend on it |

For `401`, `403`, and `429` responses, see [Errors](errors.md).
