> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.recurrente.com/referencia-api/api-reference/products/create-product-variant-inventory-adjustment/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.recurrente.com/_mcp/server. # Ajustar el inventario de una variante POST https://app.recurrente.com/api/product_variants/{product_variant_id}/inventory_adjustments Content-Type: application/json Igual que el de un producto, sobre el conteo de una combinación. Reference: https://docs.recurrente.com/referencia-api/api-reference/products/create-product-variant-inventory-adjustment ## Authentication - `X-SECRET-KEY` header (required) — Tu clave secreta de API. Una llave de cuenta (`sk_live_...`, `sk_test_...`) opera sobre su propia cuenta y, con `X-ACCOUNT-ID`, sobre sus cuentas conectadas. La llave también fija el ambiente: una `sk_test_` solo lista y resuelve objetos de prueba (`live_mode: false`) y una `sk_live_` solo objetos reales. Un ID del otro ambiente responde `404` (`401` en `/customers`). Una llave de organización (`sk_org_live_...`, `sk_org_test_...`) alcanza todas las cuentas de una organización y solo sirve para leer: saldos, movimientos y reportes. Para operar sobre una cuenta debe nombrarla con `X-ACCOUNT-ID`; omitirlo en una lectura devuelve todas las cuentas de la organización. Cualquier otro endpoint responde `403` con `code: organization_key_unsupported`. ## Request ### Path parameters - `product_variant_id` (string, required) — ID de la variante ### Body (application/json) This endpoint expects an object. - `inventory_adjustment` (InventoryAdjustmentRequest, required) — Mover el inventario de un producto o de una de sus combinaciones. **La razón lleva el signo**, así que `quantity` siempre es cuántas unidades se movieron y nunca un número negativo cuyo significado podría contradecir la razón que va al lado: `received` suma, `damaged` y `lost` restan. `recount` es la excepción — dice cuánto hay en la bodega y el libro calcula la diferencia. ## Response ### 201 La línea que quedó en el libro - `id` (string, optional) - `product_id` (string, optional) - `variant_id` (string, optional, nullable) - `delta` (integer, optional) — Las unidades que se movieron, con signo: una venta es negativa, una entrega positiva. - `resulting_quantity` (integer, optional) — El conteo que quedó justo después de este movimiento. - `reason` (enum, optional) — `sale` y `refund` los escribe un pago; el resto los escribe el comercio o una integración. `manual` es un conteo escrito en el formulario del producto y `api` su equivalente enviado por la API. - Allowed values: `sale`, `refund`, `received`, `recount`, `damaged`, `lost`, `manual`, `api` - `note` (string, optional, nullable) - `created_at` (datetime, optional) ## Errors ### 422 Unprocessable Entity Error No se movió nada; `code` dice por qué. - `message` (string, optional) - `code` (enum, optional) - Allowed values: `inventory_not_tracked`, `nothing_to_adjust`, `invalid_adjustment` ## Types ### InventoryAdjustmentRequest Mover el inventario de un producto o de una de sus combinaciones. **La razón lleva el signo**, así que `quantity` siempre es cuántas unidades se movieron y nunca un número negativo cuyo significado podría contradecir la razón que va al lado: `received` suma, `damaged` y `lost` restan. `recount` es la excepción — dice cuánto hay en la bodega y el libro calcula la diferencia. - `reason` (enum, required) - Allowed values: `received`, `recount`, `damaged`, `lost` - `quantity` (integer, optional) — Cuántas unidades se movieron. Obligatorio salvo en `recount`. - `count` (integer, optional) — Cuántas unidades hay en la bodega. Solo para `recount`, donde es obligatorio. Un producto que no llevaba inventario empieza a llevarlo con este conteo. - `note` (string, optional) ## Examples **Request** ```json { "inventory_adjustment": { "reason": "received" } } ``` **Response** ```json { "id": "im_9lstwgbr", "product_id": "prod_9lstwgbr", "variant_id": "var_9lstwgbr", "delta": -1, "resulting_quantity": 4, "reason": "sale", "note": "string", "created_at": "2024-01-15T09:30:00Z" } ``` **SDK Code** ```python import requests url = "https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments" payload = { "inventory_adjustment": { "reason": "received" } } headers = { "X-SECRET-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments'; const options = { method: 'POST', headers: {'X-SECRET-KEY': '', 'Content-Type': 'application/json'}, body: '{"inventory_adjustment":{"reason":"received"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments" payload := strings.NewReader("{\n \"inventory_adjustment\": {\n \"reason\": \"received\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-SECRET-KEY", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-SECRET-KEY"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"inventory_adjustment\": {\n \"reason\": \"received\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments") .header("X-SECRET-KEY", "") .header("Content-Type", "application/json") .body("{\n \"inventory_adjustment\": {\n \"reason\": \"received\"\n }\n}") .asString(); ``` ```php request('POST', 'https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments', [ 'body' => '{ "inventory_adjustment": { "reason": "received" } }', 'headers' => [ 'Content-Type' => 'application/json', 'X-SECRET-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments"); var request = new RestRequest(Method.POST); request.AddHeader("X-SECRET-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"inventory_adjustment\": {\n \"reason\": \"received\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-SECRET-KEY": "", "Content-Type": "application/json" ] let parameters = ["inventory_adjustment": ["reason": "received"]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.recurrente.com/api/product_variants/product_variant_id/inventory_adjustments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```