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

# Create Location

> Create a new warehouse or store location

<Note>
  This endpoint creates a new location for inventory management. Locations can be warehouses, stores, or distribution centers.
</Note>

## Authentication

This endpoint requires a valid API key with `locations:write` permissions.

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Request Body

<ParamField body="name" type="string" required>
  Location name
</ParamField>

<ParamField body="code" type="string" required>
  Unique location code (e.g., "WH-001", "STORE-NYC-01")
</ParamField>

<ParamField body="type" type="string" required>
  Location type: "warehouse", "store", "distribution\_center", "dropship"
</ParamField>

<ParamField body="address" type="object" required>
  Location address

  <Expandable title="Address properties">
    <ParamField body="line1" type="string" required>
      Street address
    </ParamField>

    <ParamField body="line2" type="string">
      Additional address info
    </ParamField>

    <ParamField body="city" type="string" required>
      City
    </ParamField>

    <ParamField body="state" type="string" required>
      State/Province code
    </ParamField>

    <ParamField body="postal_code" type="string" required>
      Postal/ZIP code
    </ParamField>

    <ParamField body="country" type="string" required>
      ISO 3166-1 alpha-2 country code
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="contact" type="object">
  Contact information

  <Expandable title="Contact properties">
    <ParamField body="name" type="string">
      Contact person name
    </ParamField>

    <ParamField body="email" type="string">
      Contact email
    </ParamField>

    <ParamField body="phone" type="string">
      Contact phone
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="operating_hours" type="object">
  Operating hours

  <Expandable title="Hours properties">
    <ParamField body="monday" type="object">
      Monday hours with open/close times
    </ParamField>

    <ParamField body="tuesday" type="object">
      Tuesday hours
    </ParamField>

    <ParamField body="wednesday" type="object">
      Wednesday hours
    </ParamField>

    <ParamField body="thursday" type="object">
      Thursday hours
    </ParamField>

    <ParamField body="friday" type="object">
      Friday hours
    </ParamField>

    <ParamField body="saturday" type="object">
      Saturday hours
    </ParamField>

    <ParamField body="sunday" type="object">
      Sunday hours
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="capabilities" type="array">
  Location capabilities: "storage", "fulfillment", "returns", "cross\_dock", "pickup"
</ParamField>

<ParamField body="capacity" type="object">
  Storage capacity information

  <Expandable title="Capacity properties">
    <ParamField body="total_sqft" type="integer">
      Total square footage
    </ParamField>

    <ParamField body="storage_units" type="integer">
      Number of storage units/bins
    </ParamField>

    <ParamField body="pallet_positions" type="integer">
      Number of pallet positions
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="timezone" type="string">
  Location timezone (e.g., "America/Los\_Angeles")
</ParamField>

<ParamField body="is_active" type="boolean">
  Whether location is active (default: true)
</ParamField>

<ParamField body="metadata" type="object">
  Additional custom fields
</ParamField>

### Response

Returns the created location.

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request POST 'https://api.stateset.com/v1/locations' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data-raw '{
      "name": "West Coast Distribution Center",
      "code": "WH-WEST-01",
      "type": "warehouse",
      "address": {
          "line1": "1000 Distribution Way",
          "city": "Los Angeles",
          "state": "CA",
          "postal_code": "90001",
          "country": "US"
      },
      "contact": {
          "name": "John Smith",
          "email": "john.smith@warehouse.com",
          "phone": "+1-555-123-4567"
      },
      "capabilities": ["storage", "fulfillment", "returns"],
      "capacity": {
          "total_sqft": 50000,
          "storage_units": 5000,
          "pallet_positions": 2000
      },
      "timezone": "America/Los_Angeles"
  }'
  ```

  ```javascript Node.js theme={null}
  const location = await stateset.locations.create({
    name: "West Coast Distribution Center",
    code: "WH-WEST-01",
    type: "warehouse",
    address: {
      line1: "1000 Distribution Way",
      city: "Los Angeles",
      state: "CA",
      postal_code: "90001",
      country: "US"
    },
    contact: {
      name: "John Smith",
      email: "john.smith@warehouse.com",
      phone: "+1-555-123-4567"
    },
    capabilities: ["storage", "fulfillment", "returns"],
    capacity: {
      total_sqft: 50000,
      storage_units: 5000,
      pallet_positions: 2000
    },
    timezone: "America/Los_Angeles"
  });
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "loc_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
    "object": "location",
    "name": "West Coast Distribution Center",
    "code": "WH-WEST-01",
    "type": "warehouse",
    "status": "active",
    "created_at": "2024-01-19T16:00:00Z",
    "address": {
      "line1": "1000 Distribution Way",
      "city": "Los Angeles",
      "state": "CA",
      "postal_code": "90001",
      "country": "US",
      "formatted": "1000 Distribution Way, Los Angeles, CA 90001, US"
    },
    "contact": {
      "name": "John Smith",
      "email": "john.smith@warehouse.com",
      "phone": "+1-555-123-4567"
    },
    "capabilities": ["storage", "fulfillment", "returns"],
    "capacity": {
      "total_sqft": 50000,
      "storage_units": 5000,
      "pallet_positions": 2000,
      "available_units": 4850,
      "available_pallets": 1920
    },
    "operating_hours": {
      "monday": { "open": "06:00", "close": "22:00" },
      "tuesday": { "open": "06:00", "close": "22:00" },
      "wednesday": { "open": "06:00", "close": "22:00" },
      "thursday": { "open": "06:00", "close": "22:00" },
      "friday": { "open": "06:00", "close": "22:00" },
      "saturday": { "open": "08:00", "close": "18:00" },
      "sunday": { "closed": true }
    },
    "timezone": "America/Los_Angeles",
    "coordinates": {
      "latitude": 34.0522,
      "longitude": -118.2437
    }
  }
  ```
</ResponseExample>
