{"openapi":"3.1.0","info":{"title":"Sidcom Platform API","version":"1"},"components":{"securitySchemes":{"clientToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"An access token from https://id.sidcom.ai/token with grant_type=client_credentials (client_secret_basic). Five minutes; fetch a new one on expiry or on a 401."}},"schemas":{"MemberOrganization":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"orgNumber":{"type":["string","null"],"description":"The organization's Swedish organisation number, ten digits without a hyphen, or null when it has none (or a foreign one)","example":"5591234567"},"role":{"type":"string","enum":["owner","member"],"description":"The member's role: an owner administers the organization, a member uses it"}},"required":["id","name","orgNumber","role"]},"Organization":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"orgNumber":{"type":["string","null"],"description":"The organization's Swedish organisation number, ten digits without a hyphen, or null when it has none (or a foreign one)","example":"5591234567"}},"required":["id","name","orgNumber"]},"Error":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]},"Company":{"type":"object","properties":{"orgNumber":{"type":"string","description":"Ten digits, normalised","example":"5591234567"},"name":{"type":"string","description":"The registered company name, in the register's casing"},"city":{"type":["string","null"],"description":"The town of the registered postal address"}},"required":["orgNumber","name","city"]},"OrganizationCompany":{"type":"object","properties":{"key":{"type":"string","description":"A stable id for the row: `org:<number>` for the row that stands for a number (the primary row for the organization's own; else the one row carrying it, else the company keyed on it), else `entity:<externalId>` (a Fortnox tenant id, the same on every fortnox-* product)","example":"org:5591234567"},"orgNumber":{"type":["string","null"],"description":"Ten digits, normalised; null when no product says what the company's number is. Several rows may carry the same number (Fortnox sandbox tenants)","example":"5591234567"},"name":{"type":"string","description":"The newest product label (what the person knows the tenant as), else the organization's name (primary row), else the register's cached name (Bolagsverket), else the number formatted, else the entity's externalId"},"city":{"type":["string","null"],"description":"The register's city, from the cache; null when the register has not been asked for this number"},"primary":{"type":"boolean","description":"True for the organization's own organisation number"},"products":{"type":"array","items":{"type":"string"},"description":"The products that report it as a company entity, sorted; empty for an own number no product reports"},"id":{"type":["string","null"],"format":"uuid","description":"The row's company in the organization's register: what a product sends as `companyId` on its entities. The company the row's entities are linked to, else the one backfilled for this key. Null when the register has none yet (or the entities point at two): create one with POST, `reuse: true`"}},"required":["key","orgNumber","name","city","primary","products","id"]},"CompanyEntity":{"type":"object","properties":{"product":{"type":"string","description":"The product that reports it"},"type":{"type":"string","description":"The product's own type for it, for example `company` for a Fortnox tenant"},"externalId":{"type":"string","description":"The product's own id for it, for example the Fortnox tenant id"},"label":{"type":["string","null"],"description":"What the product calls it"},"state":{"type":"string","enum":["active","inactive"],"description":"Does the customer still have it? Deleted entities are not listed"},"grantStatus":{"type":["string","null"],"description":"Can the product still reach it (`attributes.grantStatus`); null when the product does not say"}},"required":["product","type","externalId","label","state","grantStatus"]},"ProductHeld":{"type":"object","properties":{"product":{"type":"string","description":"The product id"},"name":{"type":["object","null"],"properties":{"en":{"type":"string"},"sv":{"type":"string"}},"required":["en","sv"],"description":"The catalog's name; null for a product with no catalog row"},"source":{"type":["string","null"],"description":"Where the subscription row comes from: stripe, marketplace (Fortnox) or admin (set by staff, a comp or a trial)"},"verdict":{"type":["object","null"],"properties":{"allow":{"type":"boolean"},"reason":{"type":"string"},"message":{"type":"string"},"basis":{"type":"object","properties":{"status":{"type":"string"},"gatePolicy":{"type":["string","null"]},"seats":{"type":"number"},"assigned":{"type":"number"},"licensed":{"type":"boolean"},"source":{"type":["string","null"]},"pricedPer":{"type":["string","null"],"enum":["org","company","seat",null]},"trialEndsAt":{"type":["string","null"]},"cancelAt":{"type":["string","null"]}}}},"required":["allow","reason","message","basis"],"description":"The user's verdict, as GET /v1/entitlement answers it; null without `userId`"}},"required":["product","name","source","verdict"]},"Trial":{"type":"object","properties":{"started":{"type":"boolean"},"reason":{"type":"string","enum":["no_trial","exists","inactive_organization"],"description":"Only when nothing was started. no_trial: the product's trial_days is 0. exists: the organization already has a row for the product; trialEndsAt is its trial end, if it has one. inactive_organization: merged into another, or not active"},"trialEndsAt":{"type":["string","null"],"description":"ISO time the trial ends; null when there is none"},"days":{"type":"integer","description":"The product's trial length in days"}},"required":["started","trialEndsAt","days"]},"Admit":{"type":"object","properties":{"allow":{"type":"boolean"},"reason":{"type":"string","enum":["fits","raised","needs_approval","limit","not_subscribed"]},"needsApproval":{"type":"boolean"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/ChangeLine"},"description":"The subscription lines that rise; empty when nothing does"},"addedOre":{"type":"integer","description":"What the rises add per interval, öre before VAT"},"interval":{"type":["string","null"],"enum":["monthly","yearly",null]},"prorationOre":{"type":["integer","null"],"description":"On the next invoice for the rest of this period, from Stripe's preview"},"approveUrl":{"type":["string","null"],"description":"Where the person approves, on billing.sidcom.ai; add `return=<your https url>`"},"message":{"type":["object","null"],"properties":{"en":{"type":"string"},"sv":{"type":"string"}},"required":["en","sv"]}},"required":["allow","reason","needsApproval","lines","addedOre","interval","prorationOre","approveUrl","message"]},"ChangeLine":{"type":"object","properties":{"unit":{"type":"string","description":"`base` for the tier itself, else the add-on's unit, e.g. bank@banking"},"name":{"type":"string"},"from":{"type":"integer"},"to":{"type":"integer"},"amountOre":{"type":"integer","description":"Per piece and interval, öre before VAT"},"approval":{"type":"boolean","description":"The customer approves this line before it is billed"}},"required":["unit","name","from","to","amountOre","approval"]},"Approved":{"type":"object","properties":{"approved":{"type":"boolean","enum":[true]},"lines":{"type":"array","items":{"$ref":"#/components/schemas/ChangeLine"}},"addedOre":{"type":"integer"},"prorationOre":{"type":["integer","null"]}},"required":["approved","lines","addedOre","prorationOre"]},"ApproveRefused":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"object","properties":{"en":{"type":"string"},"sv":{"type":"string"}},"required":["en","sv"]}},"required":["error"]},"ApproveConflict":{"type":"object","properties":{"error":{"type":"string"},"admit":{"$ref":"#/components/schemas/Admit"}},"required":["error"]},"RejectedLink":{"type":"object","properties":{"externalId":{"type":"string","description":"The entity whose link was refused. The entity itself was written"},"field":{"type":"string","enum":["companyId","parentExternalId"],"description":"Which link"},"value":{"type":"string","description":"What was sent"},"reason":{"type":"string","enum":["unknown_company","unknown_parent","ambiguous_parent","cycle"],"description":"unknown_company: no company with that id in this organization's register. unknown_parent: no live entity of this product with that externalId. ambiguous_parent: more than one (the same externalId under two types). cycle: the parent is the entity itself or one of its descendants"}},"required":["externalId","field","value","reason"]},"RejectedEntity":{"type":"object","properties":{"externalId":{"type":"string","description":"The entity that was not written"},"reason":{"type":"string","enum":["id_in_use"],"description":"id_in_use: a live entity of another type of this product has this externalId"},"heldBy":{"type":"string","description":"The type that holds the externalId"}},"required":["externalId","reason","heldBy"]},"Entity":{"type":"object","properties":{"externalId":{"type":"string","minLength":1,"maxLength":512,"description":"The product's own id for the thing; unique within the product across all its types, per organization. One a live entity of another type of this product already holds is not written: listed in `rejectedEntities`"},"label":{"type":"string","maxLength":200,"description":"What staff see. Never matched on"},"state":{"type":"string","enum":["active","inactive"],"description":"Does the customer still have it? A thing it no longer has is left out of the snapshot, which retires it"},"grantStatus":{"type":"string","enum":["active","expired","revoked","broken"],"description":"Can the product still reach it? Stored as attributes.grantStatus"},"attributes":{"type":"object","additionalProperties":{},"description":"The product's own fields, at most 8 KB as JSON. Merged into what earlier snapshots stored"},"companyId":{"type":["string","null"],"maxLength":100,"description":"The company in the organization's register this entity belongs to: an `id` from /v1/organizations/{orgId}/companies. Omitted leaves the link as it is; null clears it. One that is not this organization's is not an error: the entity is written, its link left as it was, and it is listed in `rejectedLinks`. A new `company` entity sent without it inherits the link of the same product's entity keyed on its organisation number (`attributes.orgNumber`). A retired entity keeps its link","example":"3f1c2a9e-6b1d-4c3e-9a51-2f7d8e0b4c6a"},"parentExternalId":{"type":["string","null"],"maxLength":512,"description":"The parent entity's externalId, of this product and organization (any type: an externalId is unique within a product, across its types): an account's bank. Never another product's. Omitted leaves the parent as it is; null clears it. Resolved after the whole snapshot is written. No live match, two matches, or a loop is not an error: listed in `rejectedLinks`, the parent left as it was","example":"seb"}},"required":["externalId","label","state"]},"RegisterCompany":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"The company's id: what a product sends as `companyId` on its entities"},"name":{"type":"string","description":"The organization's name for the company. Its own: the register suggests one at creation and never overwrites it"},"orgNumber":{"type":["string","null"],"description":"Ten digits, normalised; null when unknown or foreign. One company per number within an organization (task-48)","example":"5591234567"},"state":{"type":"string","enum":["active","archived"],"description":"archived: kept, and still linkable, but no longer offered"}},"required":["id","name","orgNumber","state"]},"CompanyInUse":{"type":"object","properties":{"error":{"type":"string","enum":["company_in_use"]},"products":{"type":"array","items":{"type":"string"},"description":"The products whose active entities point at the company, sorted"}},"required":["error","products"]},"CompaniesShadow":{"type":"object","properties":{"orgId":{"type":"string","format":"uuid","description":"The organization answering: the one asked, or the survivor it was merged into"},"matches":{"type":"boolean","description":"True when both answer the same rows: the same keys, each with the same organisation number"},"today":{"type":"integer","description":"Rows today's GET /companies answers"},"register":{"type":"integer","description":"Rows the register would answer"},"onlyToday":{"type":"array","items":{"type":"string"},"description":"Keys only today's answer has: a company the register lacks"},"onlyRegister":{"type":"array","items":{"type":"string"},"description":"Keys only the register has"},"numberDiffers":{"type":"array","items":{"type":"string"},"description":"Keys both have, with a different organisation number"}},"required":["orgId","matches","today","register","onlyToday","onlyRegister","numberDiffers"]},"CompaniesBackfill":{"type":"object","properties":{"orgId":{"type":"string","format":"uuid","description":"The organization the companies were written to: the one asked, or its survivor"},"created":{"type":"integer","description":"Companies created"},"reused":{"type":"integer","description":"Rows that already had their company: an earlier run, or a product's link"},"linked":{"type":"integer","description":"`company` entities given a companyId"},"conflicts":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"companyIds":{"type":"array","items":{"type":"string"}}},"required":["key","companyIds"]},"description":"Rows left alone because their entities already point at different companies; a backfill never overrules a product's link"},"elsewhere":{"type":"integer","description":"Entities of an organization aggregated into this one, left for that organization's own backfill"}},"required":["orgId","created","reused","linked","conflicts","elsewhere"]}},"parameters":{}},"paths":{"/v1/users/{userId}/organizations":{"get":{"security":[{"clientToken":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"The user's organizations; empty if none","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MemberOrganization"}}}}}}}},"/v1/users/{userId}/organizations/{orgId}":{"get":{"security":[{"clientToken":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"userId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The user, the organization, and the user's role in it","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":"string"}},"required":["id","name","email"]},"organization":{"$ref":"#/components/schemas/Organization"},"role":{"type":"string","enum":["owner","member"],"description":"The member's role: an owner administers the organization, a member uses it"}},"required":["user","organization","role"]}}}},"404":{"description":"not_a_member","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations":{"post":{"security":[{"clientToken":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1,"maxLength":120}},"required":["userId","name"]}}}},"responses":{"201":{"description":"Created; the user is its owner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}}},"404":{"description":"unknown_user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"security":[{"clientToken":[]}],"description":"Every organization that is not merged into another, by id: what staff tooling walks to run the companies backfill and shadow on each. Staff only: answers 403 not_allowed unless the calling client is listed in the api's COMPANY_REGISTER_STAFF_CLIENTS var, which is empty by default.","responses":{"200":{"description":"Every organization, ordered by id","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]}}}}},"403":{"description":"not_allowed: the calling client is not staff tooling","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/entitlement":{"get":{"security":[{"clientToken":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"userId","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"query"},{"schema":{"type":"string","minLength":1},"required":true,"name":"product","in":"query"}],"responses":{"200":{"description":"May this member use this product? The verdict and the facts it was made from; the product decides whether to stop the call or only warn.","content":{"application/json":{"schema":{"type":"object","properties":{"allow":{"type":"boolean"},"reason":{"type":"string"},"message":{"type":"string"},"basis":{"type":"object","properties":{"status":{"type":"string"},"gatePolicy":{"type":["string","null"]},"seats":{"type":"number"},"assigned":{"type":"number"},"licensed":{"type":"boolean"},"source":{"type":["string","null"]},"pricedPer":{"type":["string","null"],"enum":["org","company","seat",null]},"trialEndsAt":{"type":["string","null"]},"cancelAt":{"type":["string","null"]}}}},"required":["allow","reason","message","basis"]}}}}}}},"/v1/products":{"put":{"security":[{"clientToken":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"products":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":100},"name":{"type":"object","properties":{"en":{"type":"string","minLength":1},"sv":{"type":"string","minLength":1}},"required":["en","sv"]}},"required":["id","name"]}}},"required":["products"]}}}},"responses":{"200":{"description":"The calling client's complete list; absent products are retired","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"403":{"description":"not_your_product: another client registered one of the ids","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies/{orgNumber}":{"get":{"security":[{"clientToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":40,"description":"Any common spelling: 5591234567, 559123-4567, 16559123-4567","example":"559123-4567"},"required":true,"description":"Any common spelling: 5591234567, 559123-4567, 16559123-4567","name":"orgNumber","in":"path"}],"responses":{"200":{"description":"The company, by Bolagsverket's register","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"400":{"description":"invalid_org_number: not ten digits once normalised, or the register says the check digit is wrong","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_company: the register says nobody has this number","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"lookup_unavailable: the register could not be asked; try again later","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/companies":{"get":{"security":[{"clientToken":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Every company the organization's products know: every non-deleted `company` entity of the organization and of the organizations merged into it, plus its own organisation number (primary). One row per entity, by externalId across products (a Fortnox tenant is one row with all its fortnox-* products), NOT per organisation number: Fortnox sandbox tenants all carry Sidcom's own number, and each is a company the person picks. A company keyed on its number (banking) joins the tenant carrying that number when exactly one does, else stays its own row. The organization's own number is one primary row: the row carrying it named as the organization (or as the register's cached name), case and spacing aside; else one carrying it with no label; else the company keyed on it; else a row of its own. The primary row first, then by name (Swedish collation). A merged organization answers as its survivor. Never calls the register.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/OrganizationCompany"}}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"security":[{"clientToken":[]}],"description":"Add a company to the organization's register (task-35). A merged organization's companies are its survivor's. Give a name, a number, or both: with a number and no name, Bolagsverket names it (else the number formatted). A number belongs to one company of the organization (task-48): send `reuse: true` to get the one that has it; without it, a number already held answers 409 org_number_taken.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200,"description":"The organization's name for the company"},"orgNumber":{"type":"string","minLength":1,"maxLength":40,"description":"Any common spelling: 5591234567, 559123-4567, 16559123-4567. Stored as ten digits","example":"559123-4567"},"reuse":{"type":"boolean","description":"With orgNumber: when exactly one active company of the organization has that number, answer it (200) instead of creating another"}}}}}},"responses":{"200":{"description":"reuse: the one company that already has this number; nothing written","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterCompany"}}}},"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterCompany"}}}},"400":{"description":"invalid_org_number: not ten digits once normalised, or the register says the check digit is wrong","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"org_number_taken: another company of the organization has this number (task-48); send reuse, or create it without the number","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/companies/{companyRef}/entities":{"get":{"security":[{"clientToken":[]}],"description":"Which entities point at one company of the organization: every non-deleted entity linked to it (`companyId`, any type) plus the `company` entities its row in GET /v1/organizations/{orgId}/companies was built from, so the two never disagree. One company can have several Fortnox tenants. Includes organizations merged into this one; a merged organization answers as its survivor. Sorted by product, type, externalId. Never calls the register.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":220,"description":"The company's id in the organization's register (a uuid), or the `key` of its row in GET /v1/organizations/{orgId}/companies (`org:<number>`, `entity:<externalId>`), URL-encoded","example":"org:5591234567"},"required":true,"description":"The company's id in the organization's register (a uuid), or the `key` of its row in GET /v1/organizations/{orgId}/companies (`org:<number>`, `entity:<externalId>`), URL-encoded","name":"companyRef","in":"path"}],"responses":{"200":{"description":"The company's entities; empty when none","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CompanyEntity"}}}}},"404":{"description":"unknown_organization, or unknown_company: neither a register company of this organization nor a row key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/products":{"get":{"security":[{"clientToken":[]}],"description":"The products the organization HOLDS: those with a subscription row in its family (any status; a cancelled one is listed and its verdict says so). Unlike GET /v1/entitlement, this tells who has an `external` product (the Fortnox connectors), which answers every member allow. With `userId`, each carries that user's verdict; whether the user holds a seat is `verdict.basis.licensed`. Sorted by product id.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","format":"uuid","description":"Answer each product's verdict for this user"},"required":false,"description":"Answer each product's verdict for this user","name":"userId","in":"query"}],"responses":{"200":{"description":"The products held; empty when none","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ProductHeld"}}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/products/{product}/trial":{"post":{"security":[{"clientToken":[]}],"description":"Start the organization's trial of your product (task-41). The product decides whether and when; the platform stores it, for the product's `trial_days` (7 when not set; a product with 0 has no trial). Never extends or overwrites: an organization that already has a trial, a purchase or a comp for the product keeps it, and the answer says so. The entitlement verdict then answers `trial` until `trialEndsAt`, `trial_expired` after.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":100,"description":"A product the calling client registered"},"required":true,"description":"A product the calling client registered","name":"product","in":"path"}],"responses":{"200":{"description":"What the organization holds now. `started` is true only when this call wrote the trial","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Trial"}}}},"403":{"description":"not_your_product: the calling client did not register this product","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/products/{product}/admit":{"post":{"security":[{"clientToken":[]}],"description":"Ask before a person connects one more unit (task-37): a bank, a company. Several at once (a bank on a company the organization does not have yet) go in `units` and are quoted as one change, so the bank the new company includes covers it. Read against the organization's paid subscription and the product's price book tier. `fits`: within what is paid or included. `raised`: allowed; lines that need no approval are raised when you report the unit, prorated onto the next invoice. `needs_approval`: not yet; send the person to `approveUrl` (billing.sidcom.ai), and ask again after. `limit`: the tier sells no more of the unit; show `message`. `not_subscribed`: no paid subscription (a trial, or none); allowed. `message` is for the person, EN and SV. Asking changes nothing.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":100,"description":"A product the calling client registered"},"required":true,"description":"A product the calling client registered","name":"product","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"unit":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","description":"The entity type you report, e.g. bank or company; or use `units`","example":"bank"},"add":{"type":"integer","minimum":1,"maximum":100,"default":1,"description":"How many more of `unit`; 1 when left out"},"units":{"type":"object","additionalProperties":{"type":"integer","minimum":1,"maximum":100},"description":"Several entity types added together, as one change; in place of `unit` and `add`","example":{"company":1,"bank":1}}}}}}},"responses":{"200":{"description":"Whether and on what terms","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Admit"}}}},"403":{"description":"not_your_product: the calling client did not register this product","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"billing_unavailable: the platform could not answer; do not connect on a guess","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/products/{product}/approve":{"post":{"security":[{"clientToken":[]}],"description":"The person in front of your page approves what admit quoted (task-37): every line it needs is raised in Stripe now, prorated onto the next invoice. Show admit's `lines`, `addedOre` and `prorationOre` first, then call this when they press approve. Send the person's id_token from id.sidcom.ai in `Sidcom-Id-Token`: issued to your client, at most five minutes old (refresh it with `prompt=none`). Only an owner of the organization may approve. `addedOre` is the amount the person was shown: if the quote has changed since, nothing is raised and the new admit answer comes back to show again. Approving again once raised is 200 with no lines. billing.sidcom.ai's `approveUrl` stays the fallback.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":100,"description":"A product the calling client registered"},"required":true,"description":"A product the calling client registered","name":"product","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"units":{"type":"object","additionalProperties":{"type":"integer","minimum":1,"maximum":100},"description":"What admit was asked with","example":{"company":1,"bank":1}},"addedOre":{"type":"integer","minimum":0,"description":"admit's `addedOre`: the amount the person was shown"}},"required":["units","addedOre"]}}}},"responses":{"200":{"description":"Approved and raised; `lines` empty when it already was","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Approved"}}}},"401":{"description":"invalid_person_token: the id_token is missing, expired or not issued to your client","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"not_your_product, or not_owner: the person is not an owner of the organization; `message` asks them to ask one","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApproveRefused"}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"quote_changed: `admit` is the answer now, show it again; or not_subscribed: no paid subscription, nothing to approve","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApproveConflict"}}}},"503":{"description":"billing_unavailable or stripe_failed: nothing was raised; try again","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/entities":{"put":{"security":[{"clientToken":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"product":{"type":"string","minLength":1,"maxLength":100,"description":"A product the calling client registered"},"orgId":{"type":"string","format":"uuid"},"type":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-z][a-z0-9_]*$","description":"The product's word for what these are. Opaque to the platform"},"entities":{"type":"array","items":{"$ref":"#/components/schemas/Entity"},"maxItems":1000,"description":"The COMPLETE list for (product, type, organization). Empty retires them all"}},"required":["product","orgId","type","entities"]}}}},"responses":{"200":{"description":"The snapshot applied: what it names is upserted, what it leaves out becomes deleted (kept, never removed)","content":{"application/json":{"schema":{"type":"object","properties":{"upserted":{"type":"integer","description":"Entities inserted or updated"},"retired":{"type":"integer","description":"Entities the snapshot left out, now deleted (kept as a state)"},"rejectedLinks":{"type":"array","items":{"$ref":"#/components/schemas/RejectedLink"},"description":"Links asked for and not made; empty when every link held. The entities were written either way"},"rejectedEntities":{"type":"array","items":{"$ref":"#/components/schemas/RejectedEntity"},"description":"Entities named and NOT written, because a live entity of another type of this product already holds their externalId; empty when every one was written. Their rows are left as they were. The rest of the snapshot was applied"}},"required":["upserted","retired","rejectedLinks","rejectedEntities"]}}}},"403":{"description":"not_your_product: the calling client did not register this product","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/companies/{companyId}":{"patch":{"security":[{"clientToken":[]}],"description":"Rename a company, set or clear its number, archive or restore it. Only the fields given change. Links from products are untouched.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","format":"uuid","description":"The company's id in the organization's register"},"required":true,"description":"The company's id in the organization's register","name":"companyId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200,"description":"The organization's name for the company"},"orgNumber":{"type":["string","null"],"minLength":1,"maxLength":40,"description":"Any common spelling; null clears it","example":"559123-4567"},"state":{"type":"string","enum":["active","archived"],"description":"archived: kept and still linkable, no longer offered"}}}}}},"responses":{"200":{"description":"The company as it now is","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterCompany"}}}},"400":{"description":"invalid_org_number: not ten digits once normalised","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_organization, or unknown_company: no such company in this organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"org_number_taken: another company of the organization has this number (task-48)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"security":[{"clientToken":[]}],"description":"Delete a company no active entity points at. Products must not be broken by another product's or the customer's action, so while any does, the answer is 409 with the products to disconnect first. Retired and inactive entities lose their link and do not block.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","format":"uuid","description":"The company's id in the organization's register"},"required":true,"description":"The company's id in the organization's register","name":"companyId","in":"path"}],"responses":{"204":{"description":"Deleted"},"404":{"description":"unknown_organization, or unknown_company: no such company in this organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"company_in_use: active entities of these products point at it","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyInUse"}}}}}}},"/v1/organizations/{orgId}/companies/shadow":{"get":{"security":[{"clientToken":[]}],"description":"Today's GET /companies answer compared with what the register would answer (task-35). GET /companies switches source only once every organization matches. Read-only. Staff only: answers 403 not_allowed unless the calling client is listed in the api's COMPANY_REGISTER_STAFF_CLIENTS var, which is empty by default.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The comparison","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompaniesShadow"}}}},"403":{"description":"not_allowed: the calling client is not staff tooling","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/organizations/{orgId}/companies/backfill":{"post":{"security":[{"clientToken":[]}],"description":"The one-off backfill for one organization (task-35): a company for every row today's GET /companies answers, with its key kept, and the company entities behind each row linked to it. Never merges by number. Safe to run again; never overrules a product's link. Staff only: answers 403 not_allowed unless the calling client is listed in the api's COMPANY_REGISTER_STAFF_CLIENTS var, which is empty by default.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"What it did","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompaniesBackfill"}}}},"403":{"description":"not_allowed: the calling client is not staff tooling","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"unknown_organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{}}