API ReferenceCommerce

Inventory

Warehouses, stock levels and the inventory transactions that record each movement.

About inventory

A warehouse is a place stock is kept, with a unique code and an address. A stock row holds one product’s quantities in one warehouse: available, reserved, in transit and on hand; it is read-only here. A transaction is a ledger entry for one movement of stock, and cannot be changed or deleted once written. A transaction that makes a product available again fires the back-in-stock event that a job can turn into an email.

Stock Read-only

Stock rows are listed, not written; they follow the inventory transactions.

Orders, invoices and fulfilment
Transactions Append-only

A transaction cannot be edited or deleted once written.

Orders, invoices and fulfilment
Warehouses Active or not

active is a datetime, like published elsewhere; a new warehouse is inactive.

Orders, invoices and fulfilment
Access Admin users

Members are refused: a 404 by default, a 403 where the site’s access-denied setting says so. Call it from a server with an admin user’s OAuth token or API key.

Authentication and authorisation

List warehouses#

GET /cdna-api/inventory/warehouses

Lists warehouses. Without limit every match comes back.

Access
Admin users and integrations, with an OAuth access token or an API key.
Model
Warehouse, in the Reference

Parameters

propertiesquery
selector
The fields and relations to return, such as {id,name,code,active,address{addressLine1,suburb,postcode,countryName}}.
filtersquery
name=value
Any stored field, or a relation with a dot, such as parent.id=12. Prefix the name with !, >, <, % or |. Use stored field names exactly as in the model, and compare totalCount with the unfiltered list's to confirm a filter applied.
orderByquery
string
field:ASC or field:DESC, comma-separated. Stored fields only.
limitquery
integer
Records per response. There is no default.
offsetquery
integer
Records to skip.

Example

List warehouses
GET /cdna-api/inventory/warehouses?limit=2&properties={id,name,code,active,address{addressLine1,suburb,postcode,countryName}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "totalCount": 1,
  "data": [
    {
      "id": 1,
      "name": "API sandbox warehouse",
      "code": "API-SANDBOX",
      "active": null,
      "address": {
        "addressLine1": "1 Example Street",
        "suburb": "Melbourne",
        "postcode": "3000",
        "countryName": "Australia"
      }
    }
  ]
}
Real response from this documentation site

Show a warehouse#

GET /cdna-api/inventory/warehouse/{id}

Reads one warehouse by its id.

Access
Admin users and integrations, with an OAuth access token or an API key.
Model
Warehouse, in the Reference

Parameters

idpathrequired
integer
The warehouse id.
propertiesquery
selector
The fields and relations to return, such as {id,name,code,active,address{addressLine1,suburb,postcode,countryName}}.

Example

Show a warehouse
GET /cdna-api/inventory/warehouse/1?properties={id,name,code,active,address{addressLine1,suburb,postcode,countryName}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "data": {
    "id": 1,
    "name": "API sandbox warehouse",
    "code": "API-SANDBOX",
    "active": null,
    "address": {
      "addressLine1": "1 Example Street",
      "suburb": "Melbourne",
      "postcode": "3000",
      "countryName": "Australia"
    }
  }
}
Real response from this documentation site

Create a warehouse#

POST /cdna-api/inventory/warehouse

Creates a warehouse.

Access
Admin users and integrations, with an OAuth access token or an API key.
Returns
The new warehouse, in the fields properties asks for, and a message.

Parameters

namebodyrequired
string
The name, up to 190 characters.
codebodyrequired
string
A unique code.
addressbodyrequired
object
companyName, addressLine1, suburb, stateName, postcode, countryName.
externalIdbody
string
The warehouse’s id in another system; unique.
activebody
datetime
true makes it active now; a new warehouse is inactive.

Example

Create a warehouse
POST /cdna-api/inventory/warehouse?properties={id,name,code,active,address{addressLine1,suburb,postcode,countryName}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "name": "API sandbox warehouse",
  "code": "API-SANDBOX",
  "address": {
    "companyName": "Example Pty Ltd",
    "addressLine1": "1 Example Street",
    "suburb": "Melbourne",
    "stateName": "VIC",
    "postcode": "3000",
    "countryName": "Australia"
  }
}
Response 200 OK
{
  "result": "success",
  "data": {
    "id": 1,
    "name": "API sandbox warehouse",
    "code": "API-SANDBOX",
    "active": null,
    "address": {
      "addressLine1": "1 Example Street",
      "suburb": "Melbourne",
      "postcode": "3000",
      "countryName": "Australia"
    }
  },
  "message": "The Warehouse has been added successfully."
}
Real response from this documentation site

Edit a warehouse#

PUT /cdna-api/inventory/warehouse/{id}

Changes a warehouse. Fields left out keep their values.

Access
Admin users and integrations, with an OAuth access token or an API key.
Returns
The saved warehouse under data.warehouse, and a message.

Parameters

idpathrequired
integer
The warehouse id.
name, code, address, externalId, activebody
As for Create a warehouse.

Example

Edit a warehouse
PUT /cdna-api/inventory/warehouse/9 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "active": true
}

Delete a warehouse#

DELETE /cdna-api/inventory/warehouse/{id}

Deletes a warehouse and its stock rows.

Access
Admin users and integrations, with an OAuth access token or an API key.

Parameters

idpathrequired
integer
The warehouse id.

Example

Delete a warehouse
DELETE /cdna-api/inventory/warehouse/9 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json

List stock#

GET /cdna-api/inventory/stocks

Lists stock rows: one product’s quantities in one warehouse. Read-only. This site has none.

Access
Admin users and integrations, with an OAuth access token or an API key.
Model
Stock, in the Reference

Parameters

propertiesquery
selector
The fields and relations to return, such as {id,availableQuantity,reservedQuantity,inTransitQuantity,onHandQuantity}.
filtersquery
name=value
Any stored field, or a relation with a dot, such as parent.id=12. Prefix the name with !, >, <, % or |. Use stored field names exactly as in the model, and compare totalCount with the unfiltered list's to confirm a filter applied.
orderByquery
string
field:ASC or field:DESC, comma-separated. Stored fields only.
limitquery
integer
Records per response. There is no default.
offsetquery
integer
Records to skip.

Example

List stock
GET /cdna-api/inventory/stocks?limit=2&properties={id,availableQuantity,reservedQuantity,inTransitQuantity,onHandQuantity} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "totalCount": 0,
  "data": []
}
Real response from this documentation site

List transactions#

GET /cdna-api/inventory/transactions

Lists inventory transactions, the ledger of stock movements. This site has none.

Access
Admin users and integrations, with an OAuth access token or an API key.
Model
Transaction, in the Reference

Parameters

propertiesquery
selector
The fields and relations to return, such as {id,productCode,reason,availableQuantity,created}.
filtersquery
name=value
Any stored field, or a relation with a dot, such as parent.id=12. Prefix the name with !, >, <, % or |. Use stored field names exactly as in the model, and compare totalCount with the unfiltered list's to confirm a filter applied.
orderByquery
string
field:ASC or field:DESC, comma-separated. Stored fields only.
limitquery
integer
Records per response. There is no default.
offsetquery
integer
Records to skip.

Example

List transactions
GET /cdna-api/inventory/transactions?limit=2&properties={id,productCode,reason,availableQuantity,created} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "totalCount": 0,
  "data": []
}
Real response from this documentation site

Record a transaction#

POST /cdna-api/inventory/transaction

Writes a ledger entry for one stock movement. It cannot be changed or deleted afterwards. When it makes a product available again, the back-in-stock event fires.

Access
Admin users and integrations, with an OAuth access token or an API key.
Returns
The new transaction under data.transaction, and a message.
Model
Transaction, in the Reference

Parameters

productCodebodyrequired
string
The product’s or variant’s SKU.
availableQuantity, reservedQuantity, inTransitQuantity, onHandQuantitybody
integer
The quantities moved; 0 when left out.
warehousebody
integer
The warehouse, by id.
reasonbody
string
Why the stock moved.

Example

Record a transaction
POST /cdna-api/inventory/transaction HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "productCode": "API-SANDBOX-MUG",
  "warehouse": 1,
  "reason": "Stocktake",
  "availableQuantity": 20,
  "onHandQuantity": 20
}
Response 422 Unprocessable EntityNo product code
{
  "result": "error",
  "validationErrors": {
    "productCode": [
      {
        "message": "This value should not be blank.",
        "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
        "propertyPath": "productCode"
      }
    ]
  },
  "message": "A validation error occurred; please check the submitted fields for errors."
}
Real response from this documentation site

List an order’s fulfilments#

GET /cdna-api/inventory/fulfillments/{order.id}

Lists the fulfilments of one order; without the order id, /inventory/fulfillments, every fulfilment.

Access
Admin users and integrations, with an OAuth access token or an API key.

Parameters

order.idpath
integer
The order id; left out, all fulfilments.

Example

List an order’s fulfilments
GET /cdna-api/inventory/fulfillments/9 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json