{"openapi":"3.1.0","info":{"title":"MIL — Machine Intelligence Layer","description":"Machine-first verified intelligence for Swedish companies. Discover companies without prior knowledge of their identifier, then retrieve full intelligence (attributes, knowledge state, provenance, distress signals) by organisation number. Unknown data is returned explicitly as unknown — never invented. Products: basic (free, fair-use limited), verified (0.02 USDC/company) and intelligence (0.08 USDC/company), paid with x402 v2 on Base Mainnet (eip155:8453) when payment is enforced; see /api/payment/status.","version":"0.4","x-x402":{"version":2,"network":"eip155:8453","asset":"USDC","scheme":"exact","status":"/api/payment/status","request_header":"PAYMENT-SIGNATURE","challenge_header":"PAYMENT-REQUIRED","receipt_header":"PAYMENT-RESPONSE"}},"servers":[{"url":"https://www.milquery.com","description":"MIL production"}],"paths":{"/v1/companies":{"get":{"operationId":"searchCompanies","summary":"Discover Swedish companies without knowing their identifier","description":"Search and browse companies. All parameters are optional — omit them all to browse. Returns summary cards, each containing the organisation_number needed to call getCompany for full intelligence. Start here when you have no organisation number.","parameters":[{"name":"name","in":"query","required":false,"description":"Partial company name (case-insensitive substring match).","schema":{"type":"string"}},{"name":"organisation_number","in":"query","required":false,"description":"Canonical Swedish organisation number.","schema":{"type":"string"}},{"name":"locality","in":"query","required":false,"description":"City combined with any matching registered SNI code (e.g. Malmö).","schema":{"type":"string"}},{"name":"industry_code","in":"query","required":false,"description":"SNI code or 2–5 digit prefix, matching any registered primary or additional code.","schema":{"type":"string"}},{"name":"has_signals","in":"query","required":false,"description":"If true, only companies with active distress signals.","schema":{"type":"boolean"}},{"name":"max_age_seconds","in":"query","required":false,"description":"Only companies whose classification was verified within this many seconds.","schema":{"type":"integer","minimum":1}},{"name":"limit","in":"query","required":false,"description":"Page size (default 20, max 100).","schema":{"type":"integer","default":20,"minimum":1,"maximum":100}},{"name":"offset","in":"query","required":false,"description":"Page offset. Use pagination.next_offset from the previous page.","schema":{"type":"integer","default":0,"minimum":0}}],"responses":{"200":{"description":"Matching company summary cards.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/company/{organisation_number}":{"get":{"operationId":"getCompany","summary":"Full intelligence for one company by organisation number","description":"Retrieve machine-readable intelligence for a Swedish company: current attribute values, resolved knowledge, active distress signals, change events, provenance and data freshness. Every value is traceable to a source observation.","parameters":[{"name":"organisation_number","in":"path","required":true,"description":"Swedish organisation number, 10 or 12 digits (e.g. '5595282079').","schema":{"type":"string","pattern":"^\\d{10,12}$"}},{"name":"tier","in":"query","required":false,"description":"Product tier. basic (free, fair-use limited): identity. verified (0.02 USDC/company): current state, each value with verification status, provenance and freshness. intelligence (0.08 USDC/company): verified plus history, material events, annual-report financials, trends and deterministic signals. Omitted: the legacy v0.3 response in the free preview, basic once payment is enforced. Paid tiers answer HTTP 402 with an x402 v2 PaymentRequired until the request is retried with a PAYMENT-SIGNATURE header. meta.product_tier and meta.billable_units say what was served.","schema":{"type":"string","enum":["basic","verified","intelligence"]}}],"responses":{"200":{"description":"Company intelligence payload.","content":{"application/json":{"schema":{"type":"object"}}}},"402":{"description":"x402 v2 PaymentRequired (verified/intelligence while payment is enforced). Retry with PAYMENT-SIGNATURE.","content":{"application/json":{"schema":{"type":"object"}}}},"429":{"description":"Basic fair use exceeded (30 company units a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies/batch":{"post":{"operationId":"batchGetCompanies","summary":"Resolve up to 50 companies in one request","description":"Resolve many companies in a single call instead of one round trip each. Every requested identifier is returned with an explicit status — resolved, not_found or invalid_organisation_number — so absence is never signalled by omission. Billed as one unit per company.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["organisation_numbers"],"properties":{"organisation_numbers":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"string","pattern":"^\\d{10,12}$"}},"tier":{"type":"string","enum":["basic","verified","intelligence"],"description":"Optional product tier; billed per company found at the tier."}}}}}},"responses":{"200":{"description":"One result per requested identifier.","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Malformed request or batch too large.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/company/{organisation_number}/history":{"get":{"operationId":"getCompanyHistory","summary":"What changed about a company","description":"Attribute-change events for one company, optionally limited to a recent window and a single attribute. meta.status distinguishes no_changes_in_window from not_found.","parameters":[{"name":"organisation_number","in":"path","required":true,"description":"Swedish organisation number, 10 or 12 digits.","schema":{"type":"string","pattern":"^\\d{10,12}$"}},{"name":"days","in":"query","required":false,"description":"Only changes within the last N days (e.g. 7, 30, 90, 365).","schema":{"type":"integer","minimum":1}},{"name":"attribute_key","in":"query","required":false,"description":"Restrict to one attribute, e.g. 'legal_name' or 'sni'.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Change history.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/company/{organisation_number}/related":{"get":{"operationId":"findRelatedCompanies","summary":"Companies linked by evidence MIL holds","description":"Industry and address clusters, each relation carrying its evidence. Relation types MIL has no source data for (board_member, ownership) return meta.status = 'unavailable' with a reason rather than an empty list: 'no data' and 'no relationships' are different answers.","parameters":[{"name":"organisation_number","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d{10,12}$"}},{"name":"relation_type","in":"query","required":false,"schema":{"type":"string","enum":["industry_cluster","address_cluster","board_member","ownership"]}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":10,"minimum":1,"maximum":50}}],"responses":{"200":{"description":"Related companies with evidence.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/freshness":{"get":{"operationId":"getFreshness","summary":"How fresh MIL's data is","description":"Per-source freshness status and the age distribution across the register. Freshness describes age, not correctness. Retired source channels (replaced by another source) are listed in retired_sources and are not counted in summary.","responses":{"200":{"description":"Freshness report.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/workplaces/search":{"get":{"operationId":"searchWorkplaces","summary":"Find companies by operating workplace presence","description":"Intelligence (0.08 USDC per distinct matching company). ANY workplace SNI with physical location filters; results deduplicate companies. municipality is a four-digit code (1281) or a municipality name (Lund); locality is the workplace's physical post town. Sole traders (enskild näringsidkare) are never listed; see /v1/privacy.","parameters":[{"name":"municipality","in":"query","required":false,"schema":{"type":"string"}},{"name":"locality","in":"query","required":false,"schema":{"type":"string"}},{"name":"industry_code","in":"query","required":false,"schema":{"type":"string"}},{"name":"cfar_number","in":"query","required":false,"schema":{"type":"integer"}},{"name":"status","in":"query","required":false,"schema":{"type":"integer"}},{"name":"workplace_type","in":"query","required":false,"schema":{"type":"integer"}},{"name":"employee_band","in":"query","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Intelligence companies and deduplicated paging"},"402":{"description":"x402 payment required when enforcement is active"}}}}},"components":{"securitySchemes":{"ApiKeyBearer":{"type":"http","scheme":"bearer","description":"API key as 'Authorization: Bearer <key>'."},"ApiKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key","description":"API key as 'X-API-Key: <key>'."}},"schemas":{"Error":{"type":"object","description":"Every failure uses this envelope. Branch on error.code; error.message may be reworded and must not be parsed. error.retriable says whether the identical request could succeed later.","properties":{"error":{"type":"object","required":["code","message","retriable","http_status"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"retriable":{"type":"boolean"},"http_status":{"type":"integer"},"detail":{"type":"object"},"documentation":{"type":"string"}}},"meta":{"type":"object"}}}}}}