aYOUne
← Purchase API

Stocks

Singular: Stock — Base URL: https://purchase-api.ayoune.app — Access: CRUD

play_circle Try it now beta

Requests are proxied through the consumer-app to *.ayoune.app. Tokens stay in your browser and are forwarded per call.

Example response (recorded) sample

A real, previously recorded GET /:id response of this endpoint — not the live call above. Sensitive fields are masked.

{
  "payload": {
    "amountReserved": 0,
    "amountAvailable": 0,
    "amountInQC": 0,
    "amountInQuarantine": 0,
    "_id": "65e0b1ae121b7d48fe159dbb",
    "amount": 0,
    "lotNumber": "",
    "type": "Frei",
    "createdBy": "6045f4d25704710012485569",
    "createdAt": "2024-02-29T16:32:46.816Z",
    "updatedAt": "2024-02-29T16:32:46.816Z"
  },
  "meta": {
    "links": [
      {
        "rel": "self",
        "href": "https://purchase-api.ayoune.app/stocks/65e0b1ae121b7d48fe159dbb",
        "method": "get",
        "title": "GET",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ]
      }
    ],
    "relations": [
      {
        "rel": "Consumers",
        "title": "MODEL_CONSUMER",
        "href": "https://api.ayoune.app/crm/consumers",
        "method": "get",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ],
        "right": "crm.consumers"
      },
      {
        "rel": "Products",
        "title": "MODEL_PRODUCT",
        "href": "https://api.ayoune.app/pim/products",
        "method": "get",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ],
        "right": "pim.products"
      },
      {
        "rel": "Warehouses",
        "title": "MODEL_WAREHOUSE",
        "href": "https://api.ayoune.app/config/warehouses",
        "method": "get",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ],
        "right": "config.warehouses"
      },
      {
        "rel": "StorageAreas",
        "title": "MODEL_STORAGEAREA",
        "href": "https://api.ayoune.app/config/storageareas",
        "method": "get",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ],
        "right": "config.storageareas"
      },
      {
        "rel": "StorageAreas",
        "title": "MODEL_STORAGEAREA",
        "href": "https://api.ayoune.app/config/storageareas",
        "method": "get",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ],
        "right": "config.storageareas"
      },
      {
        "rel": "Lots",
        "title": "MODEL_LOT",
        "href": "https://api.ayoune.app/sale/lots",
        "method": "get",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ],
        "right": "sale.lots"
      },
      {
        "rel": "ProductionOrders",
        "title": "MODEL_PRODUCTIONORDER",
        "href": "https://api.ayoune.app/production/productionorders",
        "method": "get",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ],
        "right": "production.productionorders"
      }
    ],
    "debugId": "6a6198c51496f64392e30225",
    "errors": [],
    "actions": [
      {
        "rel": "self",
        "action": "COPY",
        "title": "MODEL_STOCK",
        "href": "https://api.ayoune.app/purchase/stocks/65e0b1ae121b7d48fe159dbb/copy",
        "method": "post",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ]
      },
      {
        "rel": "self",
        "action": "DELETE",
        "title": "MODEL_STOCK",
        "href": "https://api.ayoune.app/purchase/stocks/65e0b1ae121b7d48fe159dbb/copy",
        "method": "post",
        "types": [
          "application/json",
          "application/yaml",
          "text/csv"
        ]
      }
    ],
    "version": {
      "host": "2026.10.0",
      "core": "2026.257.1"
    },
    "rateLimit": {
      "limit": "2500",
      "remaining": "2424",
      "reset": "1784784576",
      "resetDate": "Thu Jul 23 2026"
    },
    "responseTime": 190.024615,
    "code": 200,
    "status": "success",
    "error": false
  }
}

Endpoints

MethodPathDescriptionRight
GET /stocks List with filters/pagination purchase.stocks.view
GET /stocks/:id Single record purchase.stocks.view
POST /stocks Create new record purchase.stocks.new
PUT /stocks Update record purchase.stocks.edit
DELETE /stocks/:id Delete record purchase.stocks.delete

SDK

import { aYOUne } from '@tolinax/ayoune';
const ay = new aYOUne('pat_your_token');

// List all
const list = await ay.purchase.stocks.find().limit(10).exec();

// Single record
const one = await ay.purchase.stocks.findById('OBJECT_ID').exec();

// Create
const created = await ay.purchase.stocks.create({ name: 'Foo' });

See also