Ir al contenido
docs

Obtener un movimiento de inventario

Permiso requerido: inventory:read.

GET /public/v1/inventory/movements/{id}

Permiso inventory:read · Inventario

Parámetros

Parámetros de ruta

NombreTipoRequeridoDescripción
idstring (uuid)Sí—

Ejemplo de petición

Terminal
curl "https://api.posdata.so/public/v1/inventory/movements/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d" \
  -H "Authorization: Bearer $POSDATA_API_KEY"
JavaScript
const res = await fetch('https://api.posdata.so/public/v1/inventory/movements/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d', {
  headers: {
    Authorization: `Bearer ${process.env.POSDATA_API_KEY}`,
  },
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message} (${data.error.request_id})`);
Python
import os

import requests

res = requests.get(
    "https://api.posdata.so/public/v1/inventory/movements/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
    headers={
        "Authorization": f"Bearer {os.environ['POSDATA_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
if not res.ok:
    raise RuntimeError(f"{data['error']['code']}: {data['error']['message']} ({data['error']['request_id']})")
PHP
<?php
$ch = curl_init('https://api.posdata.so/public/v1/inventory/movements/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('POSDATA_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
    throw new RuntimeException("{$data['error']['code']}: {$data['error']['message']} ({$data['error']['request_id']})");
}

Respuesta

200 OK: un objeto StockMovement.

CampoTipoRequeridoDescripción
object"stock_movement"Sí—
idstring (uuid)Sí—
product_idstring (uuid)Sí—
variant_idstring (uuid) | nullSí—
warehouse_idstring (uuid) | nullSínull si el movimiento llegó antes que su bodega.
typestringSíTipo de movimiento tal como lo registró la caja.
quantitynumberSíCantidad en la unidad base del producto (puede ser fraccionaria).
reasonstring | nullSí—
referencestring | nullSíReferencia libre del movimiento.
unit_costnumber | nullSíCosto por unidad base al momento del movimiento.
reason_codestring | nullNoMotivo catalogado de un ajuste: shrinkage, damage, expired, theft, internal_use, supplier_return, found, correction, other o transfer_shortage. null si el movimiento no es un ajuste con motivo.
origin_typestring | nullSísale, purchase, purchase_return (goods given back to a supplier), adjustment, recipe_explosion, reversal (a voided purchase or the restock of an annulled sale), transfer (goods moving between two warehouses of the same business: an out at the origin when it is dispatched, an in at the destination when it is received or at the origin when it is returned; it never changes the cost).
sale_idstring (uuid) | nullSíLa venta que causó el movimiento, si aplica.
created_atstring (date-time)Sí—
updated_atstring (date-time)Sí—
Ejemplo de respuesta (valores ilustrativos)
{
  "object": "stock_movement",
  "id": "3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
  "product_id": "3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
  "variant_id": "3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
  "warehouse_id": "3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
  "type": "texto",
  "quantity": 5,
  "reason": "texto",
  "reference": "texto",
  "unit_cost": 1,
  "reason_code": "texto",
  "origin_type": "texto",
  "sale_id": "3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
  "created_at": "2026-09-28T15:04:05.000Z",
  "updated_at": "2026-09-28T15:04:05.000Z"
}

Errores

Todo error responde con un objeto Error y un request_id. Ramifica por error.code, nunca por el mensaje.

Cuerpo: un objeto Error. Qué significa cada código y qué hacer: Errores.

VALIDATION_ERRORINVALID_JSONINVALID_CURSOR

Cuerpo: un objeto Error. Qué significa cada código y qué hacer: Errores.

UNAUTHENTICATEDINVALID_API_KEYAPI_KEY_REVOKEDAPI_KEY_EXPIREDAPI_KEY_WRONG_ENVIRONMENTACCOUNT_INACTIVE

Cuerpo: un objeto Error. Qué significa cada código y qué hacer: Errores.

PLAN_REQUIREDINSUFFICIENT_SCOPEBROWSER_REQUESTS_NOT_ALLOWED

Cuerpo: un objeto Error. Qué significa cada código y qué hacer: Errores.

NOT_FOUND

Cuerpo: un objeto Error. Qué significa cada código y qué hacer: Errores.

RATE_LIMITED

Cuerpo: un objeto Error. Qué significa cada código y qué hacer: Errores.

INTERNAL_ERROR