> ## Documentation Index
> Fetch the complete documentation index at: https://slovakapi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Data models

> Types, fields, and the conventions that apply across the entire API.

***

## Key concepts

RPO responses are built around two concepts that explain almost everything:

1. **Validity**: most fields are *timed*, which means they carry a validity window.
2. **Codes**: most categorical values link to a codelist entry — see [Codelists](/rpo/concepts/codelists).

<Tip>
  Internalize these two concepts before reading the individual type docs — they appear on nearly every field in the API.
</Tip>

***

## Type hierarchy

RPO's type system is shallow by design. A handful of primitives compose into the types you'll work with directly.

```mermaid theme={null}
flowchart TD
  CV["CodeValue"]
  TVE["TimedValueEntry"]
  TCVE["TimedCodeValueEntry"]
  ADDR["Address"]
  ACT["Activity"]
  PN["PersonName"]
  SH["Stakeholder"]
  SB["StatutoryBody"]
  PO["PO (entity)"]

  TCVE -. "value is a CodeValue" .-> CV
  ADDR --> SH
  PN --> SH
  ADDR --> SB
  PN --> SB
  TCVE -.-> PO
  ADDR -.-> PO
  ACT -.-> PO
  SH -.-> PO
  SB -.-> PO
```

***

## Embedded types

<ResponseField name="CodeValue" type="object">
  A categorical value pairing a human-readable label with its codelist reference. Used wherever a field belongs to a controlled vocabulary.

  <Warning>
    `code` can be an empty string — not `null`, not absent — when no matching codelist entry exists. Always guard against `""` before using it as a lookup key.
  </Warning>

  <Expandable title="properties">
    <ResponseField name="value" type="string" required>
      Human-readable label (in Slovak). Always use this for display.
    </ResponseField>

    <ResponseField name="code" type="string" required>
      Codelist entry key. Empty string if no matching entry exists.
    </ResponseField>

    <ResponseField name="codelistCode" type="string" required>
      Identifies the codelist, e.g. `CL000056`. See [Codelists](/rpo/concepts/codelists).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="TimedValueEntry" type="object">
  A string value with a validity window. The building block for any scalar field that can change over time — names, identifiers, and similar.

  <Expandable title="properties">
    <ResponseField name="value" type="string" required>
      The scalar value for this time period.
    </ResponseField>

    <ResponseField name="validFrom" type="string">
      Validity start (`YYYY-MM-DD`). Absent if the start date is unknown.
    </ResponseField>

    <ResponseField name="validTo" type="string">
      Validity end (`YYYY-MM-DD`). **Absent means this is the current value** — not a data gap.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="TimedCodeValueEntry" type="object">
  The timed variant of a codelist-backed value. Wraps a `CodeValue` in a validity window so you can track when a classification like legal form or legal status changed.

  <Tip>
    Note the double `.value` — the outer one is the timed entry property, the inner one is the human-readable label on the `CodeValue`.
  </Tip>

  <Expandable title="properties">
    <ResponseField name="value" type="CodeValue" required>
      The categorical value for this period. Has its own `.value`, `.code`, and `.codelistCode`.
    </ResponseField>

    <ResponseField name="validFrom" type="string">
      Validity start (`YYYY-MM-DD`).
    </ResponseField>

    <ResponseField name="validTo" type="string">
      Validity end. Absent if current.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="Address" type="object">
  A structured postal address with a validity window. Use `formatedAddress` for display; parse the sub-fields only when filtering or grouping by location.

  <Expandable title="properties">
    <ResponseField name="formatedAddress" type="string">
      Pre-formatted full address string. Use for display.
    </ResponseField>

    <ResponseField name="validFrom" type="string">
      Validity start (`YYYY-MM-DD`).
    </ResponseField>

    <ResponseField name="validTo" type="string">
      Validity end. Absent if current address.
    </ResponseField>

    <ResponseField name="street" type="string">
      Street name.
    </ResponseField>

    <ResponseField name="regNumber" type="number">
      Registry number (súpisné číslo).
    </ResponseField>

    <ResponseField name="buildingNumber" type="string">
      Orientation number (orientačné číslo).
    </ResponseField>

    <ResponseField name="postalCodes" type="string[]">
      Array of postal codes. Usually one entry.
    </ResponseField>

    <ResponseField name="municipality" type="CodeValue">
      Municipality from codelist `CL000025` or `UCE`.
    </ResponseField>

    <ResponseField name="district" type="CodeValue">
      City quarter from codelist `CL010141` or `UCE`.
    </ResponseField>

    <ResponseField name="country" type="CodeValue">
      Country from codelist `CL000086` or `STA`.
    </ResponseField>

    <ResponseField name="buildingIndex" type="string">
      Building identifier from the Address Register.
    </ResponseField>
  </Expandable>
</ResponseField>

***

## Entity types

<ResponseField name="Activity" type="object">
  A registered economic activity. Activities can be individually suspended without being terminated — giving three distinct states to check.

  <Warning>
    Active = no `validTo` and not suspended. Suspended = `suspendedFrom` set, `suspendedTo` absent. Deregistered = `validTo` set.
  </Warning>

  <Expandable title="properties">
    <ResponseField name="economicActivityDescription" type="string">
      Free-text description of the activity.
    </ResponseField>

    <ResponseField name="validFrom" type="string">
      Date from which the activity is registered.
    </ResponseField>

    <ResponseField name="validTo" type="string">
      Date the activity was deregistered. Absent if still registered.
    </ResponseField>

    <ResponseField name="suspendedFrom" type="string">
      Suspension start date.
    </ResponseField>

    <ResponseField name="suspendedTo" type="string">
      Suspension end date. Absent if currently suspended.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="PersonName" type="object">
  A structured name for a natural person. All components are arrays — a person may have multiple given names or titles.

  <Expandable title="properties">
    <ResponseField name="formatedName" type="string">
      Pre-formatted full name. Use for display.
    </ResponseField>

    <ResponseField name="givenNames" type="string[]">
      First name(s).
    </ResponseField>

    <ResponseField name="familyNames" type="string[]">
      Current family name(s).
    </ResponseField>

    <ResponseField name="givenFamilyNames" type="string[]">
      Birth family name(s).
    </ResponseField>

    <ResponseField name="prefixes" type="CodeValue[]">
      Titles before the name (e.g. `Ing.`, `JUDr.`) from codelist `CL000062`.
    </ResponseField>

    <ResponseField name="postfixes" type="CodeValue[]">
      Titles after the name (e.g. `PhD.`) from codelist `CL000063`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="Stakeholder" type="object">
  A person or organisation with a formal relationship to the entity — shareholders, partners, members, and similar roles. May be a natural person (FO) or a legal entity (PO/OZ).

  <Expandable title="properties">
    <ResponseField name="stakeholderType" type="CodeValue">
      Role from codelist `CL010109` (e.g. shareholder, partner).
    </ResponseField>

    <ResponseField name="validFrom" type="string">
      Relationship start date.
    </ResponseField>

    <ResponseField name="validTo" type="string">
      Relationship end date. Absent if current.
    </ResponseField>

    <ResponseField name="address" type="Address">
      Address of the stakeholder.
    </ResponseField>

    <ResponseField name="personName" type="PersonName">
      Name of the natural person. Present for FO only.
    </ResponseField>

    <ResponseField name="identifier" type="string">
      IČO of the legal entity or organisational unit. Present for PO/OZ only.
    </ResponseField>

    <ResponseField name="fullName" type="string">
      Full name of the legal entity. Present for PO/OZ only.
    </ResponseField>

    <ResponseField name="establishment" type="string">
      Date of incorporation. Present for PO/OZ only.
    </ResponseField>

    <ResponseField name="termination" type="string">
      Date of dissolution. Present for PO/OZ only.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="StatutoryBody" type="object">
  A person or organisation authorised to act on behalf of the entity. Structurally identical to `Stakeholder` with one addition: `statutoryBodyMember` captures the specific role within a collective board.

  <Expandable title="properties">
    <ResponseField name="stakeholderType" type="CodeValue">
      Type of statutory body from codelist `CL010113`.
    </ResponseField>

    <ResponseField name="statutoryBodyMember" type="CodeValue">
      Role within a collective body from codelist `CL010470` (e.g. chairman, member).
    </ResponseField>

    <ResponseField name="validFrom" type="string">
      Appointment start date.
    </ResponseField>

    <ResponseField name="validTo" type="string">
      Appointment end date. Absent if current.
    </ResponseField>

    <ResponseField name="address" type="Address">
      Address of the statutory body.
    </ResponseField>

    <ResponseField name="personName" type="PersonName">
      Name of the natural person. Present for FO only.
    </ResponseField>

    <ResponseField name="identifier" type="string">
      IČO of the legal entity. Present for PO/OZ only.
    </ResponseField>

    <ResponseField name="fullName" type="string">
      Full name of the legal entity. Present for PO/OZ only.
    </ResponseField>

    <ResponseField name="establishment" type="string">
      Date of incorporation. Present for PO/OZ only.
    </ResponseField>

    <ResponseField name="termination" type="string">
      Date of dissolution. Present for PO/OZ only.
    </ResponseField>
  </Expandable>
</ResponseField>

***

## Timed values

Instead of a single current value, most fields return an array of time-scoped entries. The **current value is always the entry where `validTo` is absent**. Entries with both `validFrom` and `validTo` set are historical.

<CodeGroup>
  ```json Default theme={null}
  {
    "fullNames": [
      { "value": "Acme s.r.o.", "validFrom": "2021-03-15" }
    ]
  }
  ```

  ```json With history theme={null}
  {
    "fullNames": [
      { "value": "Acme s.r.o.", "validFrom": "2021-03-15" },
      { "value": "Beta s.r.o.", "validFrom": "2010-01-01", "validTo": "2021-03-14" }
    ]
  }
  ```
</CodeGroup>

<Info>
  Historical data is opt-in. Pass `showHistoricalData=true` on the detail endpoint — without it, all entries with a `validTo` are omitted.
</Info>

***

## Examples

<AccordionGroup>
  <Accordion title="Get the current value of a timed field">
    The current entry is the one with no `validTo`. Safe to use on any timed array — `fullNames`, `identifiers`, `legalForms`, etc.

    ```js theme={null}
    const current = entity.fullNames.find(e => !e.validTo);
    console.log(current.value); // "Acme s.r.o."
    ```
  </Accordion>

  <Accordion title="Look up a value at a specific past date">
    Useful for reconstructing entity state at a point in time — auditing, historical reports, or change detection.

    ```js theme={null}
    function valueAt(entries, date) {
      return entries.find(e =>
        e.validFrom <= date && (!e.validTo || e.validTo >= date)
      );
    }

    const nameIn2015 = valueAt(entity.fullNames, "2015-06-01");
    console.log(nameIn2015?.value); // "Beta s.r.o."
    ```
  </Accordion>

  <Accordion title="List the full history of a field, newest first">
    Sort by `validFrom` descending to get a chronological changelog of any timed field.

    ```js theme={null}
    const history = [...entity.fullNames]
      .sort((a, b) => b.validFrom.localeCompare(a.validFrom));

    history.forEach(e => {
      const to = e.validTo ?? "present";
      console.log(`${e.validFrom} → ${to}: ${e.value}`);
    });
    // 2021-03-15 → present:     Acme s.r.o.
    // 2010-01-01 → 2021-03-14:  Beta s.r.o.
    ```
  </Accordion>
</AccordionGroup>
