Preflight check before disabling a currency
const url = 'https://api.emite.cr/v1/tenants/me/settings/disable-currency-impact?currency=USD';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.emite.cr/v1/tenants/me/settings/disable-currency-impact?currency=USD' \ --header 'Authorization: Bearer <token>'Returns what disabling a currency would block or affect, counted across both environments: draftsCount and draftsSample (drafts in it — while any exists, the disable answers 409 CURRENCY_HAS_DRAFTS), productsLosingAllPrices (active items left with no price in any enabled currency; nothing is archived), affectsDefaultCurrency and suggestedNewDefault (a new default must be chosen in the same update), and historicalInvoicesCount (informational). Changes nothing. The web uses it to gate the disable action with a confirmation modal.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Example
USDISO 4217 code to evaluate.
Responses
Section titled “Responses”object
The currency evaluated (the currency of the request).
Draft documents in that currency, in both environments. While above 0, disabling it answers 409 CURRENCY_HAS_DRAFTS.
Up to 5 of those drafts, to show which ones to issue or delete first.
object
Id of the draft document.
Its 50-digit clave, when a number was already allocated to it; else null.
Its 20-digit consecutivo, when a number was already allocated; else null.
Active items whose only prices are in that currency: with it disabled they could not be sold in any currency. Their prices are kept, and come back if it is enabled again.
Whether it is the company's defaultCurrency — then the same update must choose another default (400 DEFAULT_CURRENCY_NOT_ENABLED otherwise).
When it is the default: the first of the other enabled currencies, to propose as the new default. null when it is not the default, or when no other currency is enabled.
Every document ever created in that currency, in both environments and whatever its status (drafts and deleted ones included). Informational: documents keep their currency.
Example
{ "currency": "AED", "suggestedNewDefault": "AED"}Currency code not in ISO 4217 catalog.
Missing or invalid JWT / API key.