APIDeveloperUserRelease NotesDemoContact Us
  • Api

    • Summary
    • Address
    • Checkouts
    • Countries
    • Customer Returns
    • Line Items
    • Option Types
    • Option Values
    • Orders
    • Payments
    • Product Images
    • Product Properties
    • Products
    • Return Authorizations
    • Shipments
    • States
    • Stock Items
    • Stock Locations
    • Stock Movements
    • Taxonomies
    • Users
    • Variants
    • Zones

Table Of Contents

IndexParametersResponseSearchResponseShowResponseCreateResponseUpdateResponseDeleteResponse

Stock Locations

Index

This action is only accessible by an admin user.

To get a list of stock locations, make this request:

GET /api/v1/stock_locations

Stock locations are paginated and can be iterated through by passing along a page parameter:

GET /api/v1/stock_locations?page=2

Parameters

page:

The page number of stock location to display.

per_page:

The number of stock locations to return per page

Response

Status:
200 OK
{
"stock_locations": [
{
"id": 1,
"name": "default",
"address1": "7735 Old Georgetown Road",
"address2": "Suite 510",
"city": "Bethesda",
"state_id": 1,
"state_name": null,
"country_id": 1,
"zipcode": "20814",
"phone": "",
"active": true,
"country": {
"id": 1,
"iso_name": "UNITED STATES",
"iso": "US",
"iso3": "USA",
"name": "United States",
"numcode": 1
},
"state": {
"id": 1,
"name": "New York",
"abbr": "NY",
"country_id": 1
}
}
],
"count": 5,
"current_page": 1,
"pages": 1
}

Search

This action is only accessible by an admin user.

To search for a particular stock location, make a request like this:

GET /api/v1/stock_locations?q[name_cont]=default

The searching API is provided through the Ransack gem which Spree depends on. The name_cont here is called a predicate, and you can learn more about them by reading about Predicates on the Ransack wiki.

The search results are paginated.

Response

Status:
200 OK
{
"stock_locations": [
{
"id": 1,
"name": "default",
"address1": "7735 Old Georgetown Road",
"address2": "Suite 510",
"city": "Bethesda",
"state_id": 1,
"state_name": null,
"country_id": 1,
"zipcode": "20814",
"phone": "",
"active": true,
"country": {
"id": 1,
"iso_name": "UNITED STATES",
"iso": "US",
"iso3": "USA",
"name": "United States",
"numcode": 1
},
"state": {
"id": 1,
"name": "New York",
"abbr": "NY",
"country_id": 1
}
}
],
"count": 5,
"current_page": 1,
"pages": 1
}

Show

This action is only accessible by an admin user.

To get information for a single stock location, make this request:

GET /api/v1/stock_locations/1

Response

Status:
200 OK
{
"id": 1,
"name": "default",
"address1": "7735 Old Georgetown Road",
"address2": "Suite 510",
"city": "Bethesda",
"state_id": 1,
"state_name": null,
"country_id": 1,
"zipcode": "20814",
"phone": "",
"active": true,
"country": {
"id": 1,
"iso_name": "UNITED STATES",
"iso": "US",
"iso3": "USA",
"name": "United States",
"numcode": 1
},
"state": {
"id": 1,
"name": "New York",
"abbr": "NY",
"country_id": 1
}
}

Create

This action is only accessible by an admin user.

To create a stock location, make a request like this:

POST /api/v1/stock_locations

Assuming in this instance that you want to create a stock location with a name of East Coast, send through the parameters like this:

{
  "stock_location": {
    "name": "East Coast"
  }
}

Response

Status:
201 Created
{
"id": 1,
"name": "East Coast",
"address1": "7735 Old Georgetown Road",
"address2": "Suite 510",
"city": "Bethesda",
"state_id": 1,
"state_name": null,
"country_id": 1,
"zipcode": "20814",
"phone": "",
"active": true,
"country": {
"id": 1,
"iso_name": "UNITED STATES",
"iso": "US",
"iso3": "USA",
"name": "United States",
"numcode": 1
},
"state": {
"id": 1,
"name": "New York",
"abbr": "NY",
"country_id": 1
}
}

Update

This action is only accessible by an admin user.

To update a stock location, make a request like this:

PUT /api/v1/stock_locations/1

To update stock location information, use parameters like this:

{
  "stock_location": {
    "name": "North Pole"
  }
}

Response

Status:
200 OK
{
"id": 1,
"name": "North Pole",
"address1": "7735 Old Georgetown Road",
"address2": "Suite 510",
"city": "Bethesda",
"state_id": 1,
"state_name": null,
"country_id": 1,
"zipcode": "20814",
"phone": "",
"active": true,
"country": {
"id": 1,
"iso_name": "UNITED STATES",
"iso": "US",
"iso3": "USA",
"name": "United States",
"numcode": 1
},
"state": {
"id": 1,
"name": "New York",
"abbr": "NY",
"country_id": 1
}
}

Delete

This action is only accessible by an admin user.

To delete a stock location, make a request like this:

DELETE /api/v1/stock_locations/1

This request will also delete any related stock item records.

Response

Status:
204 No Content
Propose changes to this page
Designed and developed bySpree Commerce & Ruby on Rails developers© Spree Commerce. 2021 All Rights Reserved.