{"openapi":"3.1.0","info":{"title":"cuentalibre API","version":"1"},"security":[{"apiKey":[]}],"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"An API key (`fsk_…`) created in the app or with `POST /v1/api-keys`. The web app uses its session cookie."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["error"]}},"parameters":{}},"paths":{"/v1/health":{"get":{"tags":["Meta"],"summary":"Check that the API and its database are up","description":"`revision`: the commit this API was built from, when the build recorded one.","responses":{"200":{"description":"Healthy","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok"]},"revision":{"type":"string"}},"required":["status"]}}}},"503":{"description":"The database is unreachable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sign-in-methods":{"get":{"tags":["Meta"],"summary":"How people can sign in to this instance, besides email and password","description":"`google`: sign in with Google. `email`: the instance sends email, so people verify their address and reset a forgotten password. `billing`: the instance charges for its plan (cuentalibre Cloud). `ai`: it reads received invoices and receipts with an AI model (`POST /v1/purchases/extract`). `chat`: it has an AI help chat about using the app. `newsletter`: it sends news and offers by email to the users who opt in (`notificationPrefs`).","responses":{"200":{"description":"The sign-in methods","content":{"application/json":{"schema":{"type":"object","properties":{"google":{"type":"boolean"},"email":{"type":"boolean"},"billing":{"type":"boolean"},"ai":{"type":"boolean"},"chat":{"type":"boolean"},"newsletter":{"type":"boolean"}},"required":["google","email","billing","ai","chat","newsletter"]}}}}}}},"/v1/me":{"get":{"tags":["Account"],"summary":"The signed-in user and the organizations they belong to","responses":{"200":{"description":"The signed-in user","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"emailVerified":{"type":"boolean"},"hasPassword":{"type":"boolean"},"passwordChangedAt":{"type":["string","null"],"format":"date-time"}},"required":["id","name","email","emailVerified","hasPassword","passwordChangedAt"]},"activeOrganizationId":{"type":["string","null"],"format":"uuid"},"memberships":{"type":"array","items":{"type":"object","properties":{"organization":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"role":{"type":"string","enum":["owner","admin","member"]}},"required":["organization","role"]}},"settings":{"type":"object","properties":{"userProfile":{"type":"object","properties":{"firstName":{"type":"string","minLength":1,"maxLength":100},"lastName":{"type":"string","maxLength":200},"birthDate":{"anyOf":[{"type":"string","format":"date"},{"type":"string","enum":[""]}]},"phone":{"type":"string","maxLength":40},"gender":{"type":"string","enum":["","male","female"]},"avatarUrl":{"type":["string","null"]}},"required":["firstName","lastName","birthDate","phone","gender","avatarUrl"]},"userTour":{"type":"object","properties":{"status":{"type":"string","enum":["pending","finished","skipped"]}},"required":["status"]},"listPreferences":{"type":"object","properties":{"quote":{"type":"object","properties":{"status":{"type":"string","enum":["all","open"]},"date":{"type":"string","enum":["all","month"]}},"required":["status","date"]},"deliveryNote":{"type":"object","properties":{"status":{"type":"string","enum":["all","open"]},"date":{"type":"string","enum":["all","month"]}},"required":["status","date"]}},"required":["quote","deliveryNote"]},"notificationPrefs":{"type":"object","properties":{"promosByEmail":{"type":"boolean"}},"required":["promosByEmail"]}},"required":["userProfile","userTour","listPreferences","notificationPrefs"]}},"required":["user","activeOrganizationId","memberships","settings"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Account"],"summary":"Delete the signed-in user's account and the organizations only they belong to","description":"Erases the user, their sessions, sign-in methods and API keys, and every organization where they are the only member, with all its data and files, and cancels their subscriptions. Organizations shared with other people are kept; the user just leaves them. Needs a browser session (an API key can't do it) and the current password; users without one, who sign in with Google, need a session started in the last ten minutes instead.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"password":{"type":"string","minLength":1}}}}}},"responses":{"204":{"description":"The account is deleted"},"401":{"description":"Not signed in, or signed in with an API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The password is wrong, or the user has none and the session is not recent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The user is the only owner of an organization that has other members","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/settings/{section}":{"put":{"tags":["Account"],"summary":"Replace a section of the signed-in user's own settings","description":"The body is the whole section: `userProfile` (first and last names, birth date, phone, gender) `userTour` (whether the first-run tour was finished or skipped), `listPreferences` (the filters the quote and delivery note lists open with) or `notificationPrefs` (`promosByEmail`: whether the user wants news and offers by email). Saving the profile also renames the user. Opting in to news needs a verified email, and the instance's newsletter service must take the change.","parameters":[{"schema":{"type":"string","enum":["userProfile","userTour","listPreferences","notificationPrefs"]},"required":true,"name":"section","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"responses":{"204":{"description":"The section is saved"},"400":{"description":"The section doesn't match its schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Opting in to news with an email that isn't verified","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The newsletter service didn't take the change; nothing is saved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organization":{"get":{"tags":["Account"],"summary":"The organization requests are scoped to, and the user's role in it","responses":{"200":{"description":"The active organization","content":{"application/json":{"schema":{"type":"object","properties":{"organization":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"role":{"type":"string","enum":["owner","admin","member"]}},"required":["organization","role"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organization/members":{"get":{"tags":["Account"],"summary":"The people who belong to the active organization","description":"Oldest first, so the owner who created it leads.","responses":{"200":{"description":"The organization's members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"type":"object","properties":{"userId":{"type":"string","format":"uuid"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["owner","admin","member"]},"joinedAt":{"type":"string","format":"date-time"}},"required":["userId","name","email","role","joinedAt"]}}},"required":["members"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/password":{"post":{"tags":["Account"],"summary":"Give a password to a user who only signs in with Google","description":"Afterwards they can also sign in with their email and this password. Needs a browser session started in the last ten minutes, as there is no password to confirm it's them; users who have one change it with `/v1/auth/change-password`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"newPassword":{"type":"string","minLength":8,"maxLength":128}},"required":["newPassword"]}}}},"responses":{"204":{"description":"The password is set"},"400":{"description":"The password is too short or too long, or it has appeared in a data breach","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or signed in with an API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The session is not recent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The user has a password already","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/workspace":{"get":{"tags":["Sync"],"summary":"Everything the app keeps for the active organization","description":"Downloaded once at boot. Then follow `/sync` from the returned cursor.","responses":{"200":{"description":"The workspace","content":{"application/json":{"schema":{"type":"object","properties":{"cursor":{"type":"integer","minimum":0},"clients":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","name","taxId"]}},"suppliers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","name","taxId"]}},"salesDocuments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}},"purchaseInvoices":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}},"expenses":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}},"closedQuarters":{"type":"array","items":{"type":"object","properties":{"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"closedOn":{"type":"string","format":"date"}},"required":["period","closedOn"]}},"filedReturns":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"form":{"type":"string","enum":["130","303"]},"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"boxes":{"type":"object","additionalProperties":{"type":"number"}},"result":{"type":"integer"},"filedOn":{"type":"string","format":"date"}},"required":["id","form","period","boxes","result","filedOn"]}},"tags":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"color":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"}},"required":["id","name","color"]}},"paymentMethods":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["cash","card","transfer","directDebit","promissory","paypal"]},"name":{"type":"string","minLength":1},"number":{"type":"string"},"active":{"type":"boolean"}},"required":["id","type","name","number","active"]}},"manualPayments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","format":"uuid"},"description":{"type":"string"}},"required":["id","date","amount","paymentMethodId","description"]}},"catalogFamilies":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"parentId":{"type":["string","null"],"format":"uuid"}},"required":["id","name","parentId"]}},"products":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"familyId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string","minLength":1},"description":{"type":"string"},"privateNotes":{"type":"string"},"unit":{"type":["string","null"],"enum":["uds","dec","cent","mill","mg","g","kg","t","ml","cl","dl","l","m3","min","h","d","1/2d","jornadas","1/2j","semana","mes","trimestre","semestre","año","letra","palabra","frase","página","mm","cm","m","km",null]},"tags":{"type":"array","items":{"type":"string","minLength":1}},"active":{"type":"boolean"},"sku":{"type":"string"},"supplierRef":{"type":"string"},"price":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"cost":{"type":["number","null"]},"costVatRate":{"type":"number","minimum":0,"maximum":1},"costSurchargeRate":{"type":"number","minimum":0,"maximum":1},"custom":{"type":"array","prefixItems":[{"type":"string"},{"type":"string"},{"type":"string"},{"type":"string"}]},"stock":{"type":["object","null"],"properties":{"allowWithoutStock":{"type":"boolean"},"alarm":{"type":["object","null"],"properties":{"minUnits":{"type":"number","minimum":0}},"required":["minUnits"]}},"required":["allowWithoutStock","alarm"]}},"required":["id","familyId","name","description","privateNotes","unit","tags","active","sku","supplierRef","price","discount","vatRate","surchargeRate","cost","costVatRate","costSurchargeRate","custom","stock"]}},"stockMovements":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"productId":{"type":"string","format":"uuid"},"quantity":{"type":"number"},"at":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["invoice","deliveryNote","initial","import","settings","deleted","manual"]},"reason":{"type":"string","enum":["loss","found","purchase","sale","supplierReturn","settings","undefined"]},"comments":{"type":"string"},"documentId":{"type":"string","format":"uuid"}},"required":["id","productId","quantity","at","kind"]}},"settings":{"type":"object","properties":{"businessProfile":{"type":"object","properties":{"kind":{"type":"string","enum":["selfEmployed","company"]},"taxId":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"secondLastName":{"type":"string"},"legalName":{"type":"string"},"tradeName":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"website":{"type":"string"}},"required":["kind","taxId","firstName","lastName","secondLastName","legalName","tradeName","address","postalCode","city","province","country","email","phone","website"]},"taxSetup":{"type":"object","properties":{"region":{"type":"string","enum":["peninsula","canarias","ceutaMelilla","navarra","alava","vizcaya","guipuzcoa"]},"incomeTaxMethod":{"type":"string","enum":["simplified","normal","modules"]},"vatRegime":{"type":"string","enum":["general","cashBasis","simplified","surcharge"]},"activities":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"type":{"type":"string"},"code":{"type":"string"},"name":{"type":"string"}},"required":["id","type","code","name"]}},"defaultVatRate":{"type":"number","minimum":0,"maximum":1},"defaultWithholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"socialSecurityFee":{"type":"integer"},"variousClientsId":{"type":["string","null"],"minLength":1}},"required":["region","incomeTaxMethod","vatRegime","activities","defaultVatRate","defaultWithholding","socialSecurityFee","variousClientsId"]},"defaultPaymentMethod":{"anyOf":[{"type":"string","minLength":1},{"type":"string","enum":[""]}]},"invoiceSettings":{"type":"object","properties":{"template":{"type":"string","enum":["classic","classicTraditional","modern","modernTraditional","elegant","elegantTraditional","avantGarde"]},"font":{"type":"string","enum":["Arial","Comic Sans","Courier New","Georgia","Impact","Lucida Console","Tahoma","Times New Roman","Trebuchet MS","Verdana"]},"textColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"lineColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"backgroundColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"language":{"type":"string"},"numberFormat":{"type":"string"},"showProductUnits":{"type":"boolean"},"hideZeroTaxes":{"type":"boolean"},"showServicePeriod":{"type":"boolean"},"showOperationDate":{"type":"boolean"},"showPaymentMethod":{"type":"boolean"},"footer":{"type":"string"},"logo":{"type":"string","maxLength":524288,"pattern":"^data:image\\/png;base64,[A-Za-z0-9+/]+=*$"},"noteTemplates":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"title":{"type":"string"},"text":{"type":"string"}},"required":["id","title","text"]}},"series":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"type":{"type":"string","enum":["normal","rectifying"]},"name":{"type":"string","minLength":1},"mask":{"type":"string"},"active":{"type":"boolean"}},"required":["id","type","name","mask"]}},"defaultSeries":{"type":"object","properties":{"normal":{"type":"string"},"rectifying":{"type":"string"}}}},"required":["template","font","textColor","lineColor","backgroundColor","language","numberFormat","showProductUnits","hideZeroTaxes","showServicePeriod","showOperationDate","showPaymentMethod","footer","noteTemplates"]},"documentSettings":{"type":"object","properties":{"draft":{"type":"object","properties":{"template":{"type":"string","enum":["classic","classicTraditional","modern","modernTraditional","elegant","elegantTraditional","avantGarde"]},"font":{"type":"string","enum":["Arial","Comic Sans","Courier New","Georgia","Impact","Lucida Console","Tahoma","Times New Roman","Trebuchet MS","Verdana"]},"textColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"lineColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"backgroundColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"language":{"type":"string"},"numberFormat":{"type":"string"},"showProductUnits":{"type":"boolean"},"showServicePeriod":{"type":"boolean"},"showPrices":{"type":"boolean"},"showTaxes":{"type":"boolean"},"hideZeroTaxes":{"type":"boolean"},"footer":{"type":"string"},"keepLinesOnInvoice":{"type":"boolean"}},"required":["template","font","textColor","lineColor","backgroundColor","language","numberFormat","showProductUnits","showServicePeriod","showPrices","showTaxes","hideZeroTaxes","footer","keepLinesOnInvoice"]},"quote":{"type":"object","properties":{"template":{"type":"string","enum":["classic","classicTraditional","modern","modernTraditional","elegant","elegantTraditional","avantGarde"]},"font":{"type":"string","enum":["Arial","Comic Sans","Courier New","Georgia","Impact","Lucida Console","Tahoma","Times New Roman","Trebuchet MS","Verdana"]},"textColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"lineColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"backgroundColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"language":{"type":"string"},"numberFormat":{"type":"string"},"showProductUnits":{"type":"boolean"},"showServicePeriod":{"type":"boolean"},"showPrices":{"type":"boolean"},"showTaxes":{"type":"boolean"},"hideZeroTaxes":{"type":"boolean"},"footer":{"type":"string"},"keepLinesOnInvoice":{"type":"boolean"}},"required":["template","font","textColor","lineColor","backgroundColor","language","numberFormat","showProductUnits","showServicePeriod","showPrices","showTaxes","hideZeroTaxes","footer","keepLinesOnInvoice"]},"deliveryNote":{"type":"object","properties":{"template":{"type":"string","enum":["classic","classicTraditional","modern","modernTraditional","elegant","elegantTraditional","avantGarde"]},"font":{"type":"string","enum":["Arial","Comic Sans","Courier New","Georgia","Impact","Lucida Console","Tahoma","Times New Roman","Trebuchet MS","Verdana"]},"textColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"lineColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"backgroundColor":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"},"language":{"type":"string"},"numberFormat":{"type":"string"},"showProductUnits":{"type":"boolean"},"showServicePeriod":{"type":"boolean"},"showPrices":{"type":"boolean"},"showTaxes":{"type":"boolean"},"hideZeroTaxes":{"type":"boolean"},"footer":{"type":"string"},"keepLinesOnInvoice":{"type":"boolean"}},"required":["template","font","textColor","lineColor","backgroundColor","language","numberFormat","showProductUnits","showServicePeriod","showPrices","showTaxes","hideZeroTaxes","footer","keepLinesOnInvoice"]}}},"catalogSettings":{"type":"object","properties":{"customFieldNames":{"type":"array","prefixItems":[{"type":"string"},{"type":"string"},{"type":"string"},{"type":"string"}]},"conceptText":{"type":"string","enum":["name","codeAndName"]},"copyDescription":{"type":"boolean"},"rules":{"type":"object","properties":{"invoices":{"type":"string","enum":["never","createEdit"]},"deliveryNotes":{"type":"string","enum":["never","createEdit","invoice"]}},"required":["invoices","deliveryNotes"]},"defaults":{"type":"object","properties":{"allowWithoutStock":{"type":"boolean"},"alarm":{"type":["object","null"],"properties":{"minUnits":{"type":"number","minimum":0}},"required":["minUnits"]},"enabled":{"type":"boolean"},"alarmOn":{"type":"boolean"}},"required":["allowWithoutStock","alarm","enabled","alarmOn"]}},"required":["customFieldNames","conceptText","copyDescription","rules","defaults"]},"contactSettings":{"type":"object","properties":{"customFieldNames":{"type":"array","prefixItems":[{"type":"string"},{"type":"string"}]}},"required":["customFieldNames"]},"emailTemplates":{"type":"object","properties":{"templates":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":80},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"subject":{"type":"string","maxLength":200},"body":{"type":"string","maxLength":20000}},"required":["id","name","kind","subject","body"]},"maxItems":100},"defaults":{"type":"object","properties":{"invoice":{"type":"string","minLength":1},"draft":{"type":"string","minLength":1},"quote":{"type":"string","minLength":1},"deliveryNote":{"type":"string","minLength":1}}}},"required":["templates","defaults"]}},"required":["businessProfile","taxSetup","defaultPaymentMethod","invoiceSettings","documentSettings","catalogSettings","contactSettings","emailTemplates"]}},"required":["cursor","clients","suppliers","salesDocuments","purchaseInvoices","expenses","closedQuarters","filedReturns","tags","paymentMethods","manualPayments","catalogFamilies","products","stockMovements","settings"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sync":{"get":{"tags":["Sync"],"summary":"Records that changed after a cursor","description":"Each changed record appears once, with its latest state. Ask again with `cursor` while `hasMore`.","parameters":[{"schema":{"type":["number","null"]},"required":false,"name":"since","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":1000,"default":500},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"The changes","content":{"application/json":{"schema":{"type":"object","properties":{"cursor":{"type":"integer","minimum":0},"changes":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["clients","suppliers"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","name","taxId"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["salesDocuments"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["purchaseInvoices"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["expenses"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["closedQuarters"]},"data":{"type":"object","properties":{"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"closedOn":{"type":"string","format":"date"}},"required":["period","closedOn"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["filedReturns"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"form":{"type":"string","enum":["130","303"]},"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"boxes":{"type":"object","additionalProperties":{"type":"number"}},"result":{"type":"integer"},"filedOn":{"type":"string","format":"date"}},"required":["id","form","period","boxes","result","filedOn"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["tags"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"color":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"}},"required":["id","name","color"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["paymentMethods"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["cash","card","transfer","directDebit","promissory","paypal"]},"name":{"type":"string","minLength":1},"number":{"type":"string"},"active":{"type":"boolean"}},"required":["id","type","name","number","active"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["manualPayments"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","format":"uuid"},"description":{"type":"string"}},"required":["id","date","amount","paymentMethodId","description"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["catalogFamilies"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"parentId":{"type":["string","null"],"format":"uuid"}},"required":["id","name","parentId"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["products"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"familyId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string","minLength":1},"description":{"type":"string"},"privateNotes":{"type":"string"},"unit":{"type":["string","null"],"enum":["uds","dec","cent","mill","mg","g","kg","t","ml","cl","dl","l","m3","min","h","d","1/2d","jornadas","1/2j","semana","mes","trimestre","semestre","año","letra","palabra","frase","página","mm","cm","m","km",null]},"tags":{"type":"array","items":{"type":"string","minLength":1}},"active":{"type":"boolean"},"sku":{"type":"string"},"supplierRef":{"type":"string"},"price":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"cost":{"type":["number","null"]},"costVatRate":{"type":"number","minimum":0,"maximum":1},"costSurchargeRate":{"type":"number","minimum":0,"maximum":1},"custom":{"type":"array","prefixItems":[{"type":"string"},{"type":"string"},{"type":"string"},{"type":"string"}]},"stock":{"type":["object","null"],"properties":{"allowWithoutStock":{"type":"boolean"},"alarm":{"type":["object","null"],"properties":{"minUnits":{"type":"number","minimum":0}},"required":["minUnits"]}},"required":["allowWithoutStock","alarm"]}},"required":["id","familyId","name","description","privateNotes","unit","tags","active","sku","supplierRef","price","discount","vatRate","surchargeRate","cost","costVatRate","costSurchargeRate","custom","stock"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["stockMovements"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"productId":{"type":"string","format":"uuid"},"quantity":{"type":"number"},"at":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["invoice","deliveryNote","initial","import","settings","deleted","manual"]},"reason":{"type":"string","enum":["loss","found","purchase","sale","supplierReturn","settings","undefined"]},"comments":{"type":"string"},"documentId":{"type":"string","format":"uuid"}},"required":["id","productId","quantity","at","kind"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["settings"]},"data":{"type":"object","properties":{"section":{"type":"string","enum":["businessProfile","taxSetup","defaultPaymentMethod","invoiceSettings","documentSettings","catalogSettings","contactSettings","emailTemplates"]},"data":{}},"required":["section"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["delete"]},"entity":{"type":"string","enum":["clients","suppliers","salesDocuments","purchaseInvoices","expenses","closedQuarters","filedReturns","tags","paymentMethods","manualPayments","catalogFamilies","products","stockMovements"]},"id":{"type":"string"}},"required":["op","entity","id"]}]}},"hasMore":{"type":"boolean"}},"required":["cursor","changes","hasMore"]}}}},"400":{"description":"Invalid cursor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/commands":{"post":{"tags":["Sync"],"summary":"Apply changes, all of them or none","description":"Commands run in order in one transaction; if any is rejected, nothing is saved. Returns the resulting state of the records they touched.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"commands":{"type":"array","items":{"oneOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["clients","suppliers"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","name","taxId"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["salesDocuments"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["purchaseInvoices"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["expenses"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["tags"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"color":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"}},"required":["id","name","color"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["paymentMethods"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["cash","card","transfer","directDebit","promissory","paypal"]},"name":{"type":"string","minLength":1},"number":{"type":"string"},"active":{"type":"boolean"}},"required":["id","type","name","number","active"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["manualPayments"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","format":"uuid"},"description":{"type":"string"}},"required":["id","date","amount","paymentMethodId","description"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["catalogFamilies"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"parentId":{"type":["string","null"],"format":"uuid"}},"required":["id","name","parentId"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["products"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"familyId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string","minLength":1},"description":{"type":"string"},"privateNotes":{"type":"string"},"unit":{"type":["string","null"],"enum":["uds","dec","cent","mill","mg","g","kg","t","ml","cl","dl","l","m3","min","h","d","1/2d","jornadas","1/2j","semana","mes","trimestre","semestre","año","letra","palabra","frase","página","mm","cm","m","km",null]},"tags":{"type":"array","items":{"type":"string","minLength":1}},"active":{"type":"boolean"},"sku":{"type":"string"},"supplierRef":{"type":"string"},"price":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"cost":{"type":["number","null"]},"costVatRate":{"type":"number","minimum":0,"maximum":1},"costSurchargeRate":{"type":"number","minimum":0,"maximum":1},"custom":{"type":"array","prefixItems":[{"type":"string"},{"type":"string"},{"type":"string"},{"type":"string"}]},"stock":{"type":["object","null"],"properties":{"allowWithoutStock":{"type":"boolean"},"alarm":{"type":["object","null"],"properties":{"minUnits":{"type":"number","minimum":0}},"required":["minUnits"]}},"required":["allowWithoutStock","alarm"]}},"required":["id","familyId","name","description","privateNotes","unit","tags","active","sku","supplierRef","price","discount","vatRate","surchargeRate","cost","costVatRate","costSurchargeRate","custom","stock"]}},"required":["type","entity","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["create"]},"entity":{"type":"string","enum":["stockMovements"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"productId":{"type":"string","format":"uuid"},"quantity":{"type":"number"},"at":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["invoice","deliveryNote","initial","import","settings","deleted","manual"]},"reason":{"type":"string","enum":["loss","found","purchase","sale","supplierReturn","settings","undefined"]},"comments":{"type":"string"},"documentId":{"type":"string","format":"uuid"}},"required":["id","productId","quantity","at","kind"]}},"required":["type","entity","data"]}]},{"type":"object","properties":{"type":{"type":"string","enum":["update"]},"entity":{"type":"string","enum":["clients","suppliers","salesDocuments","purchaseInvoices","expenses","tags","paymentMethods","manualPayments","catalogFamilies","products","stockMovements"]},"id":{"type":"string","format":"uuid"},"changes":{"type":"object","additionalProperties":{}}},"required":["type","entity","id","changes"]},{"type":"object","properties":{"type":{"type":"string","enum":["delete"]},"entity":{"type":"string","enum":["clients","suppliers","salesDocuments","purchaseInvoices","expenses","tags","paymentMethods","manualPayments","catalogFamilies","products","stockMovements"]},"id":{"type":"string","format":"uuid"}},"required":["type","entity","id"]},{"type":"object","properties":{"type":{"type":"string","enum":["issue"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]},"number":{"type":"string","minLength":1}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["closeQuarter"]},"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"closedOn":{"type":"string","format":"date"},"returns":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"form":{"type":"string","enum":["130","303"]},"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"boxes":{"type":"object","additionalProperties":{"type":"number"}},"result":{"type":"integer"},"filedOn":{"type":"string","format":"date"}},"required":["id","form","period","boxes","result","filedOn"]},"maxItems":10}},"required":["type","period","closedOn"]},{"type":"object","properties":{"type":{"type":"string","enum":["reopenQuarter"]},"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"}},"required":["type","period"]},{"type":"object","properties":{"type":{"type":"string","enum":["saveSettings"]},"section":{"type":"string","enum":["businessProfile","taxSetup","defaultPaymentMethod","invoiceSettings","documentSettings","catalogSettings","contactSettings","emailTemplates"]},"data":{}},"required":["type","section"]}]},"minItems":1,"maxItems":500}},"required":["commands"]}}}},"responses":{"200":{"description":"Applied","content":{"application/json":{"schema":{"type":"object","properties":{"changes":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["clients","suppliers"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","name","taxId"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["salesDocuments"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["purchaseInvoices"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["expenses"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["closedQuarters"]},"data":{"type":"object","properties":{"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"closedOn":{"type":"string","format":"date"}},"required":["period","closedOn"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["filedReturns"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"form":{"type":"string","enum":["130","303"]},"period":{"type":"string","pattern":"^\\d{4}-T[1-4]$"},"boxes":{"type":"object","additionalProperties":{"type":"number"}},"result":{"type":"integer"},"filedOn":{"type":"string","format":"date"}},"required":["id","form","period","boxes","result","filedOn"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["tags"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"color":{"type":"string","pattern":"^#[0-9a-f]{6}$/i"}},"required":["id","name","color"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["paymentMethods"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["cash","card","transfer","directDebit","promissory","paypal"]},"name":{"type":"string","minLength":1},"number":{"type":"string"},"active":{"type":"boolean"}},"required":["id","type","name","number","active"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["manualPayments"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","format":"uuid"},"description":{"type":"string"}},"required":["id","date","amount","paymentMethodId","description"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["catalogFamilies"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"parentId":{"type":["string","null"],"format":"uuid"}},"required":["id","name","parentId"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["products"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"familyId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string","minLength":1},"description":{"type":"string"},"privateNotes":{"type":"string"},"unit":{"type":["string","null"],"enum":["uds","dec","cent","mill","mg","g","kg","t","ml","cl","dl","l","m3","min","h","d","1/2d","jornadas","1/2j","semana","mes","trimestre","semestre","año","letra","palabra","frase","página","mm","cm","m","km",null]},"tags":{"type":"array","items":{"type":"string","minLength":1}},"active":{"type":"boolean"},"sku":{"type":"string"},"supplierRef":{"type":"string"},"price":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"cost":{"type":["number","null"]},"costVatRate":{"type":"number","minimum":0,"maximum":1},"costSurchargeRate":{"type":"number","minimum":0,"maximum":1},"custom":{"type":"array","prefixItems":[{"type":"string"},{"type":"string"},{"type":"string"},{"type":"string"}]},"stock":{"type":["object","null"],"properties":{"allowWithoutStock":{"type":"boolean"},"alarm":{"type":["object","null"],"properties":{"minUnits":{"type":"number","minimum":0}},"required":["minUnits"]}},"required":["allowWithoutStock","alarm"]}},"required":["id","familyId","name","description","privateNotes","unit","tags","active","sku","supplierRef","price","discount","vatRate","surchargeRate","cost","costVatRate","costSurchargeRate","custom","stock"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["stockMovements"]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"productId":{"type":"string","format":"uuid"},"quantity":{"type":"number"},"at":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["invoice","deliveryNote","initial","import","settings","deleted","manual"]},"reason":{"type":"string","enum":["loss","found","purchase","sale","supplierReturn","settings","undefined"]},"comments":{"type":"string"},"documentId":{"type":"string","format":"uuid"}},"required":["id","productId","quantity","at","kind"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["upsert"]},"entity":{"type":"string","enum":["settings"]},"data":{"type":"object","properties":{"section":{"type":"string","enum":["businessProfile","taxSetup","defaultPaymentMethod","invoiceSettings","documentSettings","catalogSettings","contactSettings","emailTemplates"]},"data":{}},"required":["section"]}},"required":["op","entity","data"]},{"type":"object","properties":{"op":{"type":"string","enum":["delete"]},"entity":{"type":"string","enum":["clients","suppliers","salesDocuments","purchaseInvoices","expenses","closedQuarters","filedReturns","tags","paymentMethods","manualPayments","catalogFamilies","products","stockMovements"]},"id":{"type":"string"}},"required":["op","entity","id"]}]}}},"required":["changes"]}}}},"400":{"description":"A command is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"A command refers to a record that doesn't exist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A create reuses an existing ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts":{"get":{"tags":["Contacts"],"summary":"List clients and suppliers","parameters":[{"schema":{"type":"string","enum":["client","supplier"]},"required":false,"name":"role","in":"query"},{"schema":{"type":"string","description":"Only contacts with this tax ID, ignoring separators and the ES prefix"},"required":false,"description":"Only contacts with this tax ID, ignoring separators and the ES prefix","name":"taxId","in":"query"}],"responses":{"200":{"description":"The contacts","content":{"application/json":{"schema":{"type":"object","properties":{"contacts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"role":{"type":"string","enum":["client","supplier"]}},"required":["id","name","taxId","role"]}}},"required":["contacts"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Contacts"],"summary":"Create a contact","description":"`id` is optional: send a UUID to make retries safe, or let the server generate one.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"role":{"type":"string","enum":["client","supplier"]}},"required":["name","taxId","role"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"role":{"type":"string","enum":["client","supplier"]}},"required":["id","name","taxId","role"]}}}},"400":{"description":"Invalid contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The ID is already used","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts/{id}":{"get":{"tags":["Contacts"],"summary":"Get a contact","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The contact","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"role":{"type":"string","enum":["client","supplier"]}},"required":["id","name","taxId","role"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Contacts"],"summary":"Change some fields of a contact","description":"Send only the fields to change; `null` clears an optional field. The role can't change.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"variousClients":{"type":"boolean"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"fax":{"type":"string"},"website":{"type":"string"},"vies":{"type":"boolean"},"discount":{"type":"number","minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"paymentMethodId":{"type":"string","minLength":1},"language":{"type":"string"},"numberFormat":{"type":"string"},"bankAccounts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"iban":{"type":"string","pattern":"^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$"},"bic":{"type":"string"},"notes":{"type":"string"},"isDefault":{"type":"boolean"}},"required":["id","iban","isDefault"]}},"eInvoice":{"type":"object","properties":{"accountingOffice":{"type":"string"},"managementBody":{"type":"string"},"processingUnit":{"type":"string"},"proposingBody":{"type":"string"}}},"custom1":{"type":"string"},"custom2":{"type":"string"},"notes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"role":{"type":"string","enum":["client","supplier"]}},"required":["id","name","taxId","role"]}}}},"400":{"description":"Invalid contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Contacts"],"summary":"Delete a contact","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Received invoices or expenses still name the supplier","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sales-documents":{"get":{"tags":["Sales"],"summary":"List sales documents","description":"Optionally between two dates (inclusive) of their issue date.","parameters":[{"schema":{"type":"string","format":"date"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date"},"required":false,"name":"to","in":"query"}],"responses":{"200":{"description":"The records","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}},"required":["data"]}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Sales"],"summary":"Create a sales document","description":"`id` is optional: send a UUID to make retries safe, or let the server generate one. Creates drafts, quotes and delivery notes; invoices are issued with `POST /v1/invoices`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}}},"400":{"description":"Invalid sales document","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The ID is already used, or its quarter is closed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sales-documents/{id}":{"get":{"tags":["Sales"],"summary":"Get a sales document","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Sales document","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such sales document","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Sales"],"summary":"Change some fields of a sales document","description":"Send only the fields to change; `null` clears an optional field.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}}},"400":{"description":"Invalid sales document","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such sales document","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An issued invoice, or one in a closed quarter, can't take this change","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Sales"],"summary":"Delete a sales document","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such sales document","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Issued invoices, and records of a closed quarter, can't be deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchase-invoices":{"get":{"tags":["Purchases"],"summary":"List received invoices","description":"Optionally between two dates (inclusive) of their booking date, which decides the quarter.","parameters":[{"schema":{"type":"string","format":"date"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date"},"required":false,"name":"to","in":"query"}],"responses":{"200":{"description":"The records","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}}},"required":["data"]}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Purchases"],"summary":"Create a received invoice","description":"`id` is optional: send a UUID to make retries safe, or let the server generate one.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}}}},"400":{"description":"Invalid received invoice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The ID is already used, or its quarter is closed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchase-invoices/{id}":{"get":{"tags":["Purchases"],"summary":"Get a received invoice","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Received invoice","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such received invoice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Purchases"],"summary":"Change some fields of a received invoice","description":"Send only the fields to change; `null` clears an optional field.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"supplierId":{"type":"string","format":"uuid"},"number":{"type":"string"},"issuedOn":{"type":"string","format":"date"},"bookedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"vatImputation":{"type":["integer","null"],"minimum":0,"maximum":100},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","import"]},"operationOn":{"type":["string","null"],"format":"date"},"customsDocument":{"type":"string"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"asset":{"type":"object","properties":{"category":{"type":"string","enum":["buildings","installations","machinery","transport","itEquipment","software","tools","cattle","horses","citrus","olives","research","development","concessions","industrialProperty","goodwill","leaseRights"]},"condition":{"type":"string","enum":["new","used","accelerated","lowValue","free"]},"method":{"type":"string","enum":["rate","years"]},"value":{"type":"number","exclusiveMinimum":0},"identifier":{"type":"string"}},"required":["category","condition","method","value"]}},"required":["id","supplierId","number","issuedOn","bookedOn","dueOn","expenseType","imputation","vatImputation","withholding","operationType","operationOn","cashBasis","rental","lines","payments","privateNotes"]}}}},"400":{"description":"Invalid received invoice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such received invoice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An issued invoice, or one in a closed quarter, can't take this change","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Purchases"],"summary":"Delete a received invoice","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such received invoice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Issued invoices, and records of a closed quarter, can't be deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/expenses":{"get":{"tags":["Expenses"],"summary":"List expenses","description":"Optionally between two dates (inclusive) of their date.","parameters":[{"schema":{"type":"string","format":"date"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date"},"required":false,"name":"to","in":"query"}],"responses":{"200":{"description":"The records","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}}},"required":["data"]}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Expenses"],"summary":"Create a expense","description":"`id` is optional: send a UUID to make retries safe, or let the server generate one.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}}}},"400":{"description":"Invalid expense","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The ID is already used, or its quarter is closed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/expenses/{id}":{"get":{"tags":["Expenses"],"summary":"Get a expense","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Expense","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such expense","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Expenses"],"summary":"Change some fields of a expense","description":"Send only the fields to change; `null` clears an optional field.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date"},"number":{"type":"string"},"concept":{"type":"string"},"amount":{"type":"integer"},"expenseType":{"type":"string","enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422"]},"imputation":{"type":"integer","minimum":0,"maximum":100},"supplierId":{"type":["string","null"],"format":"uuid"},"otherPayee":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"}},"required":["name","taxId"]},"payment":{"type":["object","null"],"properties":{"date":{"type":"string","format":"date"},"paymentMethodId":{"type":"string","minLength":1}},"required":["date","paymentMethodId"]},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"privateNotes":{"type":"string"},"tags":{"type":"array","items":{"type":"string","minLength":1}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["id","date","number","concept","amount","expenseType","imputation","supplierId","payment","rental","privateNotes"]}}}},"400":{"description":"Invalid expense","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such expense","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An issued invoice, or one in a closed quarter, can't take this change","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Expenses"],"summary":"Delete a expense","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such expense","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Issued invoices, and records of a closed quarter, can't be deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/invoices":{"post":{"tags":["Sales"],"summary":"Issue an invoice","description":"The server gives it the next number of its series and freezes its client data and totals. Send the ID of a draft to issue it with the data sent.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100}},"required":["kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}}},"responses":{"201":{"description":"Issued","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}}},"400":{"description":"Invalid invoice","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Already issued, dated before the last invoice of its series, or in a closed quarter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sales-documents/{id}/issue":{"post":{"tags":["Sales"],"summary":"Issue a draft as it is","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"201":{"description":"Issued","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote"]},"number":{"type":["string","null"]},"series":{"type":"string","enum":["normal","rectifying"]},"seriesId":{"type":"string","format":"uuid"},"clientId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":[""]}]},"issuedOn":{"type":"string","format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"incomeType":{"type":"string","enum":["700","705","740","746","747","752","769","7098","7099"]},"withholding":{"type":"string","enum":["none","modules","farming","newProfessional","professional","rental","imageRights","ceutaNewProfessional","ceutaProfessional","ceutaRental","legacyCeutaNewProfessional2018","legacyCeutaNewProfessional2015","legacyCeutaProfessional2018","legacyNewProfessional2015","legacyCeutaProfessional2015","legacyCeutaProfessional2014","legacyRental2009","legacyRental2015","legacyRentalJuly2015","legacyProfessional2014"]},"operationType":{"type":"string","enum":["national","exempt","notSubject","reverseCharge","intraEu","export"]},"operationOn":{"type":["string","null"],"format":"date"},"cashBasis":{"type":"boolean"},"rental":{"type":"boolean"},"rentalLocation":{"type":"string","enum":["spain","basqueCountry","navarre","noCadastralRef","abroad"]},"cadastralRef":{"type":"string"},"rectifiesId":{"type":"string","format":"uuid"},"rectification":{"type":"object","properties":{"reason":{"type":"string","enum":["R1","R2","R3","R4"]},"method":{"type":"string","enum":["differences","substitution"]}},"required":["reason","method"]},"lines":{"type":"array","items":{"type":"object","properties":{"unitPrice":{"type":"number"},"quantity":{"type":"number"},"discount":{"type":"number","minimum":0,"maximum":1},"vatRate":{"type":"number","minimum":0,"maximum":1},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"id":{"type":"string","minLength":1},"concept":{"type":"string"},"detail":{"type":"string"},"serviceFrom":{"type":"string","format":"date"},"serviceTo":{"type":"string","format":"date"},"productId":{"type":"string","minLength":1},"unit":{"type":"string"}},"required":["unitPrice","quantity","discount","vatRate","id","concept"]},"maxItems":1000},"supplies":{"type":"integer"},"payments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"date":{"type":"string","format":"date"},"amount":{"type":"integer"},"paymentMethodId":{"type":"string","minLength":1}},"required":["id","date","amount","paymentMethodId"]},"maxItems":1000},"tags":{"type":"array","items":{"type":"string","minLength":1}},"language":{"type":"string"},"numberFormat":{"type":"string"},"status":{"type":"string","enum":["pending","paid","created","sent","accepted","rejected","invoiced"]},"publicNotes":{"type":"string"},"privateNotes":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0}},"required":["id","name","size"]},"maxItems":100},"issued":{"type":"object","properties":{"client":{"type":"object","properties":{"name":{"type":"string","minLength":1},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId"]},"totals":{"type":"object","properties":{"base":{"type":"integer"},"vat":{"type":"integer"},"surcharge":{"type":"integer"},"withholding":{"type":"integer"},"supplies":{"type":"integer"},"total":{"type":"integer"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"}},"required":["rate","base","vat"]}}},"required":["base","vat","surcharge","withholding","supplies","total","vatBreakdown"]},"issuedAt":{"type":"string","format":"date-time"}},"required":["client","totals"]}},"required":["id","kind","number","series","clientId","issuedOn","dueOn","incomeType","withholding","operationType","operationOn","cashBasis","rental","lines","status","publicNotes","privateNotes"]}}}},"400":{"description":"Not a draft, or not ready to issue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or the API key is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such draft","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Dated before the last invoice of its series, or in a closed quarter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchases/extract":{"post":{"tags":["Purchases"],"summary":"Read a received invoice or receipt with AI","description":"Upload the PDF or photo first (`POST /v1/files`). An AI model reads it and the answer is a draft for a received invoice (`kind: invoice`) or an expense (`kind: ticket`): nothing is saved. `issues` lists the fields to check before saving: missing ones, impossible values (a tax ID with a wrong check digit, a VAT rate Spain doesn't use) and amounts that don't add up. `supplierId` is the saved supplier with the draft's tax ID. PDFs with a text layer send their text to the model; photos and scans send the file itself. PDFs of more than 10 pages are refused, rather than read in part. Photos over 1.5 MB, HEIC ones and those stored sideways are sent as an upright JPEG of at most 2400 px. A file read before (the same bytes) isn't sent to the model again, and doesn't count towards the monthly limit, if the server has one (`GET /v1/purchases/extract/usage`); readings that fail don't count either.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"fileId":{"type":"string","format":"uuid"}},"required":["fileId"]}}}},"responses":{"200":{"description":"The draft","content":{"application/json":{"schema":{"type":"object","properties":{"draft":{"type":"object","properties":{"kind":{"type":"string","enum":["invoice","ticket"]},"supplier":{"type":"object","properties":{"name":{"type":"string"},"taxId":{"type":"string"},"address":{"type":"string"},"postalCode":{"type":"string"},"city":{"type":"string"},"country":{"type":"string"}},"required":["name","taxId","address","postalCode","city","country"]},"number":{"type":"string"},"issuedOn":{"type":["string","null"],"format":"date"},"dueOn":{"type":["string","null"],"format":"date"},"concept":{"type":"string"},"currency":{"type":"string"},"vatBreakdown":{"type":"array","items":{"type":"object","properties":{"rate":{"type":"number","minimum":0,"maximum":1},"base":{"type":"integer"},"vat":{"type":"integer"},"surchargeRate":{"type":"number","minimum":0,"maximum":1},"surcharge":{"type":"integer"}},"required":["rate","base","vat","surchargeRate","surcharge"]}},"withholding":{"type":["object","null"],"properties":{"rate":{"type":"number","minimum":0,"maximum":1},"amount":{"type":"integer"}},"required":["rate","amount"]},"total":{"type":["integer","null"]},"expenseType":{"type":["string","null"],"enum":["600","602","607","621","622","623","624","625","626","627","628","629","631","640","641","642","649","660","662","663","680","681","682","6231","6291","6292","6293","6294","6295","6297","6421","6422",null]}},"required":["kind","supplier","number","issuedOn","dueOn","concept","currency","vatBreakdown","withholding","total","expenseType"]},"supplierId":{"type":["string","null"],"minLength":1},"issues":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"code":{"type":"string","enum":["missing","invalid","mismatch"]}},"required":["field","code"]}},"source":{"type":"string","enum":["text","image","pdf"]}},"required":["draft","supplierId","issues","source"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such file","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The PDF has more than 10 pages or 50 000 characters of text (`document_too_long`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"The file isn't a PDF or a JPEG, PNG, HEIC, WebP or GIF image, or can't be read (`unsupported_file`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The organization has read this month's documents (`ai_quota_exceeded`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider failed, or its answer couldn't be read (`ai_failed`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"This server has no AI model set up (`ai_unavailable`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchases/extract/usage":{"get":{"tags":["Purchases"],"summary":"Documents read with AI this month","description":"How many documents the organization has had read with AI this calendar month (Spain's time), and the server's monthly limit, if it has one. Reading a file already read, and readings that failed, don't count.","responses":{"200":{"description":"The usage","content":{"application/json":{"schema":{"type":"object","properties":{"used":{"type":"integer","minimum":0},"limit":{"type":["integer","null"],"exclusiveMinimum":0},"month":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},"required":["used","limit","month"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"This server has no AI model set up (`ai_unavailable`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/files":{"post":{"tags":["Files"],"summary":"Upload a file","description":"Send it as `multipart/form-data`. `id` is optional: the web app sends the attachment's ID, so it can show the file before the upload ends. Name the file in a record's `attachments` afterwards.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"},"id":{"type":"string","format":"uuid"}},"required":["file"]}}}},"responses":{"201":{"description":"Uploaded","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0},"contentType":{"type":"string"}},"required":["id","name","size","contentType"]}}}},"400":{"description":"No file","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The ID is already used","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The file is too large (`file_too_large`), or the organization's files would take more than its quota (`storage_quota_exceeded`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["Files"],"summary":"List the files","description":"The organization's files, newest first, each with the records that name it in their attachments (deleted records included), and the bytes they take against the quota. A file no record names can be deleted.","responses":{"200":{"description":"The files","content":{"application/json":{"schema":{"type":"object","properties":{"files":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"size":{"type":"integer","minimum":0},"contentType":{"type":"string"},"uploadedAt":{"type":"string","format":"date-time"},"usedBy":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["invoice","draft","quote","deliveryNote","client","supplier","purchaseInvoice","asset","expense","email"]},"id":{"type":"string","format":"uuid"},"label":{"type":["string","null"]},"documentId":{"type":"string","format":"uuid"},"deleted":{"type":"boolean"}},"required":["kind","id","label","deleted"]}}},"required":["id","name","size","contentType","uploadedAt","usedBy"]}},"usedBytes":{"type":"integer","minimum":0},"quotaBytes":{"type":["integer","null"],"exclusiveMinimum":0}},"required":["files","usedBytes","quotaBytes"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/files/{id}":{"delete":{"tags":["Files"],"summary":"Delete an unused file","description":"Only a file no record names, not even a deleted one: an attached file may be a supporting document that has to be kept. To delete one, remove it from its records' attachments first. Its bytes no longer count toward the quota.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such file","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A record names the file (`file_in_use`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["Files"],"summary":"Download a file","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The file's bytes"},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such file","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/emails":{"post":{"tags":["Email"],"summary":"Send a sales document, such as an invoice to its client","description":"Upload the attachments first (`POST /v1/files`). The email is queued and sent in the background: follow its `status` with `GET /v1/emails`. It goes out as `GET /v1/emails/sender` says, replying to `replyTo` if given; `bccMe` also sends a blind copy to the sending user. Only users with a verified email can send, and each organization reaches a limited number of recipients (to, cc and bcc) a day and a month.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"documentId":{"type":"string","format":"uuid"},"to":{"type":"array","items":{"type":"string","format":"email"},"minItems":1,"maxItems":10},"cc":{"type":"array","items":{"type":"string","format":"email"},"maxItems":10,"default":[]},"replyTo":{"type":"string","format":"email"},"bccMe":{"type":"boolean","default":false},"subject":{"type":"string","minLength":1,"maxLength":200},"body":{"type":"string","maxLength":20000},"attachments":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":10,"default":[]}},"required":["documentId","to","subject","body"]}}}},"responses":{"202":{"description":"Queued","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"documentId":{"type":["string","null"],"format":"uuid"},"to":{"type":"array","items":{"type":"string","format":"email"}},"cc":{"type":"array","items":{"type":"string","format":"email"}},"bcc":{"type":"array","items":{"type":"string","format":"email"}},"replyTo":{"type":["string","null"]},"subject":{"type":"string"},"status":{"type":"string","enum":["queued","sent","failed"]},"error":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"sentAt":{"type":["string","null"],"format":"date-time"}},"required":["id","documentId","to","cc","bcc","replyTo","subject","status","error","createdAt","sentAt"]}}}},"400":{"description":"Invalid email, or an attachment that wasn't uploaded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"The organization's trial or subscription has ended: it can only read and export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, the user doesn't belong to it, or their email isn't verified","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The organization reached its daily or monthly email recipients","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"This server can't send email","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["Email"],"summary":"Emails sent from the organization, newest first","parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"documentId","in":"query"}],"responses":{"200":{"description":"The emails","content":{"application/json":{"schema":{"type":"object","properties":{"emails":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"documentId":{"type":["string","null"],"format":"uuid"},"to":{"type":"array","items":{"type":"string","format":"email"}},"cc":{"type":"array","items":{"type":"string","format":"email"}},"bcc":{"type":"array","items":{"type":"string","format":"email"}},"replyTo":{"type":["string","null"]},"subject":{"type":"string"},"status":{"type":"string","enum":["queued","sent","failed"]},"error":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"sentAt":{"type":["string","null"],"format":"date-time"}},"required":["id","documentId","to","cc","bcc","replyTo","subject","status","error","createdAt","sentAt"]}}},"required":["emails"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/emails/sender":{"get":{"tags":["Email"],"summary":"Who emails go out from","description":"The business's name at the instance's address: sending from people's own addresses would fail spam checks. Replies go to `replyTo`: the business's email, or else the user's.","responses":{"200":{"description":"The sender","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"address":{"type":"string","format":"email"},"replyTo":{"type":["string","null"]}},"required":["name","address","replyTo"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"This server can't send email","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/help-chat":{"post":{"tags":["Help chat"],"summary":"Ask the help chat how to use cuentalibre","description":"Send the conversation so far, ending with the question: the server keeps none of it. An AI model answers from cuentalibre's documentation, never from the organization's data, and gives no tax advice. The answer streams as server-sent events: `text` ones carry the next piece of it, as a JSON string; then `done`, or `error` with `{ code, message }` if the provider failed halfway. The server may limit the questions an organization asks a day (Spain's time).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["user","assistant"]},"content":{"type":"string","minLength":1,"maxLength":4000}},"required":["role","content"]},"minItems":1,"maxItems":21},"screen":{"type":"object","properties":{"device":{"type":"string","enum":["phone","desktop"]},"path":{"type":"string","maxLength":200,"pattern":"^\\/[^\\s?#\"<>]*(\\?periodo=(trimestre|año))?$"}},"required":["device","path"]}},"required":["messages"]}}}},"responses":{"200":{"description":"The answer, as it is written","content":{"text/event-stream":{"schema":{"type":"string"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"The organization has asked today's questions (`ai_quota_exceeded`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The AI provider failed (`ai_failed`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"This server has no help chat set up (`ai_unavailable`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/api-keys":{"get":{"tags":["API keys"],"summary":"Your API keys for the active organization","responses":{"200":{"description":"The keys","content":{"application/json":{"schema":{"type":"object","properties":{"apiKeys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"start":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":["string","null"],"format":"date-time"},"lastUsedAt":{"type":["string","null"],"format":"date-time"}},"required":["id","name","start","createdAt","expiresAt","lastUsedAt"]}}},"required":["apiKeys"]}}}},"401":{"description":"Not signed in, or signed in with an API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["API keys"],"summary":"Create an API key","description":"The key acts as you in the active organization. Send it as `Authorization: Bearer <key>`. Its secret is only returned now.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":32},"expiresInDays":{"type":"integer","minimum":1,"maximum":365}},"required":["name"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"start":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":["string","null"],"format":"date-time"},"lastUsedAt":{"type":["string","null"],"format":"date-time"},"key":{"type":"string"}},"required":["id","name","start","createdAt","expiresAt","lastUsedAt","key"]}}}},"400":{"description":"Invalid name or expiry","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Not signed in, or signed in with an API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Already 10 active keys in the organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/api-keys/{id}":{"delete":{"tags":["API keys"],"summary":"Revoke an API key","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Revoked"},"401":{"description":"Not signed in, or signed in with an API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing":{"get":{"tags":["Billing"],"summary":"The active organization's plan and subscription","description":"`plan` says what the organization may do: write during its trial, while it pays and while a failed charge is retried; otherwise read and export only.","responses":{"200":{"description":"The plan","content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"object","properties":{"status":{"type":"string","enum":["trial","active","pastDue","readOnly"]},"canWrite":{"type":"boolean"},"trialEndsAt":{"type":"string","format":"date-time"}},"required":["status","canWrite","trialEndsAt"]},"subscription":{"type":["object","null"],"properties":{"period":{"type":["string","null"],"enum":["monthly","quarterly","yearly",null]},"status":{"type":"string"},"currentPeriodEnd":{"type":["string","null"],"format":"date-time"},"cancelAtPeriodEnd":{"type":"boolean"}},"required":["period","status","currentPeriodEnd","cancelAtPeriodEnd"]}},"required":["plan","subscription"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user doesn't belong to it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/checkout":{"post":{"tags":["Billing"],"summary":"Start paying for the organization: a Stripe Checkout page to open","description":"Only owners and administrators, signed in. During the trial the card is taken now and the first charge lands when the trial ends. Back from Stripe, the plan changes once its webhook arrives. A new page closes any earlier one still open.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"string","enum":["monthly","quarterly","yearly"]},"returnTo":{"type":"string","enum":["plan","app"],"default":"plan"}},"required":["period"]}}}},"responses":{"200":{"description":"Where to send the person","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"401":{"description":"Not signed in, or signed in with an API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user isn't one of its owners or administrators","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The organization already has a subscription: change it in the portal","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/invoices":{"get":{"tags":["Billing"],"summary":"The invoices for the organization's plan, newest first","description":"Every charge paid, with links to its PDF and to Stripe's page for it. Stripe makes the links when asked, so ask again rather than keeping them. Only owners and administrators; read-only organizations too.","responses":{"200":{"description":"The invoices","content":{"application/json":{"schema":{"type":"object","properties":{"invoices":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"paidAt":{"type":"string","format":"date-time"},"total":{"type":"integer"},"url":{"type":"string","format":"uri"}},"required":["id","number","paidAt","total","url"]}}},"required":["invoices"]}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user isn't one of its owners or administrators","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/invoices/{id}/pdf":{"get":{"tags":["Billing"],"summary":"An invoice of the organization's plan, as a PDF","description":"Shown in the browser rather than downloaded. Only owners and administrators; read-only organizations too.","parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The invoice","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Not signed in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user isn't one of its owners or administrators","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not one of the organization's invoices","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/billing/portal":{"post":{"tags":["Billing"],"summary":"Manage the subscription: a Stripe customer portal page to open","description":"Change the period, the card or the billing details, see past invoices or cancel at the end of the period. Only owners and administrators, signed in.","responses":{"200":{"description":"Where to send the person","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"401":{"description":"Not signed in, or signed in with an API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active organization, or the user isn't one of its owners or administrators","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The organization has never subscribed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{}}