When to use this endpoint

Use to hide stock from pickers that require is_archived=0, while retaining its record and existing references. Reactivate with is_archived=0.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. This handler requires both a user identity and tenant context; it adds no stock-page, finance or administrator permission check.

All queries use the authenticated tenant. API signing and session CSRF checks still apply; see Getting started.

Parameters

ParameterTypeRequiredDescription
idInteger-compatible stringYesStock ID converted with intval; must be at least 1.
is_archivedInteger-compatible stringYesRequired scalar, integer-converted; only 0 or 1 are accepted after coercion. 1 archives; 0 reactivates. Unsupported flags return an error.

Example request

$result = FM_api('Stock_setIsArchived', ['id'=>'1042', 'is_archived'=>'1']);

Example response

{"ok":1}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"missing or invalid parameter: id"}Missing/nonpositive id.
{"error":"Stock item does not exist"}No non-deleted stock target.
{"error":"missing parameter: is_archived"}Flag absent/null.
{"ok":1,"warning":"no change needed"}Stored flag integer-equals normalized input; timestamp/event are not changed.
{"error":"stock catalog write failed"}A primary write or required history insert fails; the transaction rolls back.
{"error":"stock catalog read failed"}A checked read fails; a normalization or write transaction is rolled back.
{"error":"stock catalog transaction failed"}Transaction start or commit fails; no success is returned.
{"error":"stock catalog operation failed"}Unexpected database/runtime failure during the transaction.
{"error":"missing or invalid parameter: is_archived"}Non-scalar flag or normalized value outside 0/1.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Locks and updates a non-deleted target in one checked transaction. A matching normalized flag is a no-op, preserving timestamps/history/events.
  • Archival is not deletion: deleted/ddate and deletion log are unchanged. Quantities, allocations, supplier links and document references are retained.
  • Stock_listByCategory excludes archived stock; Stock_listBySupplier, getNames and Stocks_getByCode still include it.
  • No stock-page permission, archive setting or availability validation. History commits with the changed flag; events run after commit.
  • No direct mobile caller was found in the current app JavaScript or m/www intermediary. The app receives stock through syncDownloads, which selects non-deleted stock by edit timestamp; these calls are not the app synchronization protocol.

Side effects

  • On change, writes is_archived, server last_edited, edited_uuid=Stock_setIsArchived and checked history; invalidates stocks cache.
  • Runs configured Stock_edit after commit without stock movement.

See it in Fieldmotion

CRM1

No direct browser caller for this exact endpoint was found in CRM1. Do not claim that an archive action necessarily uses it; other legacy stock edit routes exist.

CRM2

The Stocks Status cell and bulk archive/reactivate actions use the mapped Stock_updateData flow with isArchived, not this snake_case narrow setter.

Related endpoints