{"openapi":"3.1.0","info":{"title":"Ivahi API","version":"v1","description":"Ivahi keeps a company's books: sales, stock, payments and the accounts built from them. Company calls go to the company's own address with a company key (ivk_…, made in its Settings); /companies goes to ivahi.com with a developer key (ivd_…, made on ivahi.com/account). Every write needs an Idempotency-Key. At most 120 calls a minute per key. The same company key connects an AI assistant to the MCP server at https://{address}.ivahi.com/api/mcp. Guide: https://ivahi.com/developers"},"tags":[{"name":"Your key"},{"name":"Look-ups"},{"name":"Sales"},{"name":"Money and stock"},{"name":"Reports"},{"name":"Companies"}],"paths":{"/me":{"get":{"operationId":"me","summary":"Which company and key","description":"The company this key belongs to, what it may do, and the branches it reaches. Their ids are the branchId other calls take.","tags":["Your key"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"responses":{"200":{"description":"{ company, key, branches }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products":{"get":{"operationId":"listProducts","summary":"Products and prices","description":"Products with each price a sale can name (prices[].id is the priceId a sale takes), the branches each price is for, and the units on each branch's shelf. Cost prices are never listed.","tags":["Look-ups"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"page","in":"query","required":false,"schema":{"type":"integer","exclusiveMinimum":0,"default":1}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"search","in":"query","required":false,"schema":{"type":"string","maxLength":100}}],"responses":{"200":{"description":"{ products, page, limit, total }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"createProduct","summary":"Add a product","description":"A new product with its prices, made exactly as the product form makes it. Prices go on the price lists of branches the key reaches (GET /me shows each branch's priceListId), each by the base unit or the pack; the first on each list is its default unless another is marked. The cost per base unit is a fact you state. No opening stock: record goods received with POST /purchases. No image: add one on the web.","tags":["Look-ups"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"categoryId":{"type":"integer","exclusiveMinimum":0},"barcode":{"type":"string","maxLength":60},"manufacturer":{"type":"string","maxLength":120},"description":{"type":"string","maxLength":2000},"baseUnit":{"type":"string","minLength":1,"maxLength":30},"packagingUnit":{"type":"string","minLength":1,"maxLength":30},"unitsPerPack":{"type":"integer","minimum":1,"maximum":100000,"default":1},"costPerBaseUnit":{"type":"number","minimum":0},"lowStockThreshold":{"type":"integer","minimum":1,"maximum":1000000},"prices":{"type":"array","items":{"type":"object","properties":{"priceListId":{"type":"integer","exclusiveMinimum":0},"name":{"type":"string","minLength":1,"maxLength":80},"unit":{"type":"string","enum":["base","pack"]},"price":{"type":"number","minimum":0},"default":{"type":"boolean"}},"required":["priceListId","name","unit","price"],"additionalProperties":false},"minItems":1,"maxItems":20}},"required":["name","categoryId","baseUnit","costPerBaseUnit","prices"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ product } with its prices (their ids are the priceId a sale takes)","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/categories":{"get":{"operationId":"listCategories","summary":"Product categories","description":"The company's product categories; their ids are the categoryId a new product takes.","tags":["Look-ups"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"responses":{"200":{"description":"{ categories }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/customers":{"get":{"operationId":"listCustomers","summary":"Customers and balances","description":"Customers with what each owes, holds as credit, and may owe (their limit) at each branch the key reaches.","tags":["Look-ups"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"page","in":"query","required":false,"schema":{"type":"integer","exclusiveMinimum":0,"default":1}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"search","in":"query","required":false,"schema":{"type":"string","maxLength":100}}],"responses":{"200":{"description":"{ customers, page, limit, total }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"createCustomer","summary":"Add a customer","description":"A new customer: their details, their home branch (one the key reaches) and their credit limit there. A name already in use is refused.","tags":["Look-ups"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":150},"contactName":{"type":"string","maxLength":120},"phone":{"type":"string","maxLength":30},"email":{"type":"string","format":"email"},"address":{"type":"string","maxLength":300},"homeBranchId":{"type":"integer","exclusiveMinimum":0},"creditLimit":{"type":"number","minimum":0,"default":0},"notes":{"type":"string","maxLength":500}},"required":["name","homeBranchId"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ customer }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/suppliers":{"get":{"operationId":"listSuppliers","summary":"Suppliers and balances","description":"Suppliers with what each branch the key reaches owes them, or has paid ahead.","tags":["Look-ups"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"page","in":"query","required":false,"schema":{"type":"integer","exclusiveMinimum":0,"default":1}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"search","in":"query","required":false,"schema":{"type":"string","maxLength":100}}],"responses":{"200":{"description":"{ suppliers, page, limit, total }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/sales":{"post":{"operationId":"recordSale","summary":"Record a sale","description":"A sale in a Cloud branch. Lines name a priceId and a number of packs: Ivahi prices them from the branch's list and charges the company's VAT, so a sale never carries a price of its own. Payment is cash, electronic (name the branch's bank account), split, or credit (needs a customerId).","tags":["Sales"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"branchId":{"type":"integer","exclusiveMinimum":0},"customerId":{"type":"integer","exclusiveMinimum":0},"customerName":{"type":"string","maxLength":120},"items":{"type":"array","items":{"type":"object","properties":{"priceId":{"type":"integer","exclusiveMinimum":0},"quantity":{"type":"integer","exclusiveMinimum":0,"maximum":1000000}},"required":["priceId","quantity"],"additionalProperties":false},"minItems":1,"maxItems":200},"discount":{"type":"number","minimum":0,"default":0},"payment":{"type":"object","properties":{"method":{"type":"string","enum":["cash","electronic","split","credit"]},"amountReceived":{"type":"number","minimum":0},"bankAccountId":{"anyOf":[{"type":"integer","exclusiveMinimum":0},{"type":"null"}]},"split":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["cash","electronic"]},"amount":{"type":"number","minimum":0},"bankAccountId":{"anyOf":[{"type":"integer","exclusiveMinimum":0},{"type":"null"}]}},"required":["method","amount"],"additionalProperties":false},"minItems":2,"maxItems":4}},"required":["method","amountReceived"],"additionalProperties":false},"notes":{"type":"string","maxLength":500}},"required":["branchId","items","payment"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ sale }: number, lines, totals, amount paid, balance","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/sales/{saleId}/returns":{"post":{"operationId":"returnSale","summary":"Record goods returned","description":"Goods coming back from a sale, by its line ids and packs. The refund is what those lines sold for, back through the sale's own payment or onto the customer's account; no more than is left can come back.","tags":["Sales"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"saleId","in":"path","required":true,"description":"The sale's id, as POST /sales answered it.","schema":{"type":"integer"}},{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"lineId":{"type":"integer","exclusiveMinimum":0},"quantity":{"type":"integer","exclusiveMinimum":0},"reason":{"type":"string","minLength":1,"maxLength":200},"restock":{"type":"boolean","default":true}},"required":["lineId","quantity","reason"],"additionalProperties":false},"minItems":1,"maxItems":200},"refund":{"type":"string","enum":["original_payment","account"]},"returnDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"bankAccountId":{"anyOf":[{"type":"integer","exclusiveMinimum":0},{"type":"null"}]},"notes":{"type":"string","maxLength":500}},"required":["items","refund","returnDate"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ return, sale }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/sales/{saleId}/void":{"post":{"operationId":"voidSale","summary":"Void a sale","description":"Void a sale, with a reason. A sale that already had goods returned cannot be voided: return the rest instead.","tags":["Sales"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"saleId","in":"path","required":true,"description":"The sale's id, as POST /sales answered it.","schema":{"type":"integer"}},{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":3,"maxLength":500}},"required":["reason"],"additionalProperties":false}}}},"responses":{"200":{"description":"{ sale } now voided","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/customer-payments":{"post":{"operationId":"recordCustomerPayment","summary":"Record a customer's payment","description":"Money a customer paid at a branch. It settles their invoices there first; anything beyond is held as their credit.","tags":["Money and stock"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"customerId":{"type":"integer","exclusiveMinimum":0},"branchId":{"type":"integer","exclusiveMinimum":0},"amount":{"type":"number","minimum":0},"method":{"type":"string","enum":["cash","electronic"]},"bankAccountId":{"anyOf":[{"type":"integer","exclusiveMinimum":0},{"type":"null"}]},"date":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"reference":{"type":"string","maxLength":100},"notes":{"type":"string","maxLength":500}},"required":["customerId","branchId","amount","method","date"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ payment }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/purchases":{"post":{"operationId":"recordPurchase","summary":"Record goods received","description":"Goods received from a supplier into a branch, with each line's packs, pack size, cost and expiry date as delivered. A branch on Simple accounting pays on arrival (send payment); a Full branch owes the supplier.","tags":["Money and stock"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"branchId":{"type":"integer","exclusiveMinimum":0},"supplierId":{"type":"integer","exclusiveMinimum":0},"date":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"invoiceNumber":{"type":"string","maxLength":60},"notes":{"type":"string","maxLength":500},"items":{"type":"array","items":{"type":"object","properties":{"productId":{"type":"integer","exclusiveMinimum":0},"quantity":{"type":"integer","exclusiveMinimum":0},"unitsPerPack":{"type":"integer","exclusiveMinimum":0},"packagingUnit":{"type":"string","minLength":1,"maxLength":30},"costPerPack":{"type":"number","minimum":0},"expiryDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["productId","quantity","unitsPerPack","packagingUnit","costPerPack","expiryDate"],"additionalProperties":false},"minItems":1,"maxItems":200},"payment":{"type":"object","properties":{"method":{"type":"string","enum":["cash","electronic"]},"bankAccountId":{"anyOf":[{"type":"integer","exclusiveMinimum":0},{"type":"null"}]}},"required":["method"],"additionalProperties":false}},"required":["branchId","supplierId","date","items"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ purchase }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/expenses":{"post":{"operationId":"recordExpense","summary":"Record an expense","description":"An expense a branch paid, in cash or from one of its bank accounts, posted to the account its category maps to.","tags":["Money and stock"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"Your own name for this one operation, sent as the Idempotency-Key: the same key again returns the first answer and records nothing twice.","schema":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[\\x21-\\x7e]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"branchId":{"type":"integer","exclusiveMinimum":0},"categoryId":{"type":"integer","exclusiveMinimum":0},"description":{"type":"string","minLength":1,"maxLength":200},"amount":{"type":"number","minimum":0},"date":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"method":{"type":"string","enum":["cash","electronic"]},"bankAccountId":{"anyOf":[{"type":"integer","exclusiveMinimum":0},{"type":"null"}]},"paidTo":{"type":"string","maxLength":120},"reference":{"type":"string","maxLength":100},"notes":{"type":"string","maxLength":500}},"required":["branchId","categoryId","description","amount","date","method"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ expense }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/trial-balance":{"get":{"operationId":"trialBalance","summary":"Trial balance","description":"One branch's trial balance on a day (today if asOf is left out), exactly as the Ivahi Finance screen shows it. The branch must use Full accounting.","tags":["Reports"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"branchId","in":"query","required":true,"schema":{"type":"integer","exclusiveMinimum":0}},{"name":"asOf","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}}],"responses":{"200":{"description":"{ branchId, branch, asOf, accounts, totals }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/profit-loss":{"get":{"operationId":"profitAndLoss","summary":"Profit and loss","description":"One branch's profit and loss for a period (today if from and to are left out), exactly as the Ivahi Finance screen shows it. Full accounting only.","tags":["Reports"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"branchId","in":"query","required":true,"schema":{"type":"integer","exclusiveMinimum":0}},{"name":"from","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}}],"responses":{"200":{"description":"{ branchId, branch, fromDate, toDate, revenue, cogs, expenses, … }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/balance-sheet":{"get":{"operationId":"balanceSheet","summary":"Balance sheet","description":"One branch's balance sheet on a day, with whether it balances, exactly as the Ivahi Finance screen shows it. Full accounting only.","tags":["Reports"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"branchId","in":"query","required":true,"schema":{"type":"integer","exclusiveMinimum":0}},{"name":"asOf","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}}],"responses":{"200":{"description":"{ branchId, branch, asOfDate, assets, liabilities, equity, isBalanced, variance }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/journal":{"get":{"operationId":"journal","summary":"Journal entries","description":"One branch's journal entries with their lines, newest first; filter by dates and by what made them (sourceType). Full accounting only.","tags":["Reports"],"servers":[{"url":"https://{address}.ivahi.com/api/v1","description":"The company's own address","variables":{"address":{"default":"yourcompany","description":"The part before .ivahi.com"}}}],"security":[{"companyKey":[]}],"parameters":[{"name":"branchId","in":"query","required":true,"schema":{"type":"integer","exclusiveMinimum":0}},{"name":"from","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"to","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},{"name":"sourceType","in":"query","required":false,"schema":{"type":"string","enum":["sale","purchase","expense","purchase_return","sale_return","payment_in","payment_out","sale_payment","order_deposit","stock_transfer","inventory_adjustment","payroll","bank_deposit","bank_withdrawal"]}},{"name":"page","in":"query","required":false,"schema":{"type":"integer","exclusiveMinimum":0,"default":1}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"{ branchId, branch, entries, total, page, totalPages }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies":{"get":{"operationId":"listCompanies","summary":"Your companies","description":"The companies your owner account owns, newest first, with their status.","tags":["Companies"],"servers":[{"url":"https://ivahi.com/api/v1","description":"The Ivahi platform"}],"security":[{"developerKey":[]}],"responses":{"200":{"description":"{ companies }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"createCompany","summary":"Create a company","description":"A Cloud company you then own and are billed for, by the same rules as Add a business: email confirmed, the address free, at most 3 a day. It answers while its database is being made; asking again for an address you already own answers that company.","tags":["Companies"],"servers":[{"url":"https://ivahi.com/api/v1","description":"The Ivahi platform"}],"security":[{"developerKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":120},"address":{"type":"string","minLength":1,"maxLength":63},"category":{"type":"string","enum":["supermarket","pharmacy","fashion","electronics","food","beauty","hardware","other"]},"agentCode":{"type":"string","maxLength":12}},"required":["name","address","category"],"additionalProperties":false}}}},"responses":{"202":{"description":"{ company } with status setting_up (200 when it already existed)","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies/{address}":{"get":{"operationId":"getCompany","summary":"One company's status","description":"One of your companies, with its status: setting_up, active or suspended. Ask again until it is active.","tags":["Companies"],"servers":[{"url":"https://ivahi.com/api/v1","description":"The Ivahi platform"}],"security":[{"developerKey":[]}],"parameters":[{"name":"address","in":"path","required":true,"description":"The company's address: the part before .ivahi.com.","schema":{"type":"string"}}],"responses":{"200":{"description":"{ company }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies/{address}/keys":{"post":{"operationId":"createCompanyKey","summary":"Make a company key","description":"A company key (ivk_…) for one of your active companies, reaching the Cloud branches you name (all of them when left out). It is shown once; each call makes a new key.","tags":["Companies"],"servers":[{"url":"https://ivahi.com/api/v1","description":"The Ivahi platform"}],"security":[{"developerKey":[]}],"parameters":[{"name":"address","in":"path","required":true,"description":"The company's address: the part before .ivahi.com.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"access":{"type":"string","enum":["read","write"],"default":"write"},"branchIds":{"type":"array","items":{"type":"integer","exclusiveMinimum":0},"minItems":1,"maxItems":200}},"required":["name"],"additionalProperties":false}}}},"responses":{"201":{"description":"{ key, prefix, company, access, branches }","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"invalid_request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"missing_key, key_not_recognised, key_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"payment_overdue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"read_only_key, branch_not_allowed, key_owner_inactive","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"no_company, not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"branch_unavailable, idempotency_conflict, books_not_shown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"server_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"companyKey":{"type":"http","scheme":"bearer","bearerFormat":"ivk_…","description":"A company key, made in the company's Settings, API keys (or minted by a developer key)."},"developerKey":{"type":"http","scheme":"bearer","bearerFormat":"ivd_…","description":"A developer key, made on ivahi.com/account."}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["no_company","missing_key","key_not_recognised","key_revoked","read_only_key","branch_not_allowed","branch_unavailable","payment_overdue","invalid_request","server_error","idempotency_conflict","key_owner_inactive","refused","not_found","books_not_shown","rate_limited"],"description":"Stable: branch on it in software."},"message":{"type":"string","description":"Plain words a person can act on."}}}}}}},"x-error-codes":[{"code":"no_company","status":404,"meaning":"The call reached no company: call the company's own address (or ivahi.com for /companies)."},{"code":"missing_key","status":401,"meaning":"No key was sent."},{"code":"key_not_recognised","status":401,"meaning":"The key is not one Ivahi knows, or is the wrong kind for this address."},{"code":"key_revoked","status":401,"meaning":"The owner revoked the key."},{"code":"read_only_key","status":403,"meaning":"A read-only key tried to write."},{"code":"branch_not_allowed","status":403,"meaning":"The key does not reach that branch."},{"code":"branch_unavailable","status":409,"meaning":"The branch is closed, or run by its device."},{"code":"payment_overdue","status":402,"meaning":"The company or branch is read-only until its Ivahi payment is made."},{"code":"invalid_request","status":400,"meaning":"The request is not what the endpoint takes; the message names the field."},{"code":"server_error","status":500,"meaning":"Ivahi could not finish the call; nothing was changed by it."},{"code":"idempotency_conflict","status":409,"meaning":"The Idempotency-Key was used for a different request, or is still running."},{"code":"key_owner_inactive","status":403,"meaning":"The owner who made the key is no longer an active owner."},{"code":"refused","status":422,"meaning":"The books' own rules refused it (short stock, a closed month, a credit limit…); nothing was recorded."},{"code":"not_found","status":404,"meaning":"No such record in the branches the key reaches (the same answer either way)."},{"code":"books_not_shown","status":409,"meaning":"The branch uses Simple accounting, so its books are not shown."},{"code":"rate_limited","status":429,"meaning":"More than 120 calls in a minute by this key; wait Retry-After seconds."}]}