# Get started with Platform

> See the keys your realm signs and seals with, then give the engineering team a realm of its own beneath yours, with every call.

In this walkthrough you look at what your realm `foobar` stands on, then hand a team a realm of its own. First you list
the keys `foobar` signs its tokens and seals its data with, and see the public half apps verify against. Then you
create the sub-realm `engineering` beneath `foobar`, with a host name and a first administrator of its own. At the
end, the engineering team runs its realm, and you still reach into it from yours.

## Before you begin

- You are a realm administrator of `foobar`, in a group that holds `RealmOwner`, with your session in
  `$CVYUH_SESSION`: [Call the API](/develop/api/) shows how to get it.
- Sub-realms are turned on for `foobar`. If creating one answers `403`, "sub-realms are not turned on", ask Cvyūh.
- Admin calls go to `https://foobar.cvyuh.com/api/v0/am`, and calls about realms to
  `https://foobar.cvyuh.com/api/v0/am/global/realms/v1`.

## See your realm's keys

<Steps>

1. **List the keys.** Every version of every key the realm holds, and never what's in them:

   ```sh
   curl https://foobar.cvyuh.com/api/v0/am/keys/v1 \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

   ```json
   {
     "data": [
       { "key": "oauth2/signing", "version": 1, "alg": "ES256", "state": "valid", "validFrom": "<RFC 3339 time>" },
       { "key": "oauth2/signing", "version": 2, "alg": "RS256", "state": "valid", "validFrom": "<RFC 3339 time>" },
       { "key": "oauth2/signing", "version": 3, "alg": "PS256", "state": "valid", "validFrom": "<RFC 3339 time>" },
       { "key": "oauth2/signing/cluster-local", "version": 1, "alg": "ES256", "state": "valid", "validFrom": "<RFC 3339 time>" },
       { "key": "store/encryption", "version": 1, "alg": "chacha20poly1305", "state": "valid", "validFrom": "<RFC 3339 time>" }
     ]
   }
   ```

   `oauth2/signing` holds one signing key for each algorithm, `store/encryption` is the key the realm seals its stored
   data with, and `oauth2/signing/cluster-local` is the internal signing key, for tokens that never leave Cvyūh, which
   you never need to touch. A `valid` version is in use; a `retained` one is kept only to verify, or open, what it
   signed or sealed.

2. **See what apps verify against.** The public halves of the signing keys are published, for anyone:

   ```sh
   curl -i https://foobar.cvyuh.com/oauth2/jwks
   ```

   Each key's `kid` is its thumbprint. The answer's `Cache-Control: public, max-age=300` is how long apps may keep it,
   and why a new key is published an hour before it signs anything: see [Signing keys](/platform/keys/signing-keys/).

</Steps>

## Hand a team its own realm

<Steps>

1. **Find your realm.** The realms list shows your realm and every realm beneath it. The answer, in part:

   ```sh
   curl https://foobar.cvyuh.com/api/v0/am/global/realms/v1 \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

   ```json
   {
     "data": [
       { "id": "<realm id>", "name": "foobar", "path": "/foobar", "parentPath": "/", "status": "active",
         "hostnames": ["foobar.cvyuh.com"], "rev": 3, "createTime": "<RFC 3339 time>", "products": ["…"] }
     ]
   }
   ```

   A new realm names its parent by the parent's `path`: here `/foobar`.

2. **Create the sub-realm.** Name it, place it beneath `foobar`, give it a host name of its own, and set the password
   of its first administrator:

   ```sh
   curl -i https://foobar.cvyuh.com/api/v0/am/global/realms/v1 \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "name": "engineering",
           "parentPath": "/foobar",
           "hostnames": ["foobar-engineering.cvyuh.com"],
           "password": "<a strong first password>",
           "mailId": "maya@example.com" }'
   ```

   The realm answers `202 Accepted` with the new realm's `id`, its `status` `creating`, and a `Location` to poll. Its
   keys, settings, first administrator and host name are being made, usually within seconds.

3. **Wait until it's active.**

   ```sh
   curl https://foobar.cvyuh.com/api/v0/am/global/realms/v1/<realm id> \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
   ```

   Poll until `status` is `active`. If it shows `failed`, with a `code` and `reason`, resume it with
   `curl -X POST https://foobar.cvyuh.com/api/v0/am/global/realms/v1/<realm id>/resume` and the same headers, and
   `-d '{}'`.

4. **Hand it over.** Give the engineering team its address and its first administrator: they sign in at
   `https://foobar-engineering.cvyuh.com` as `admin@engineering`, with the password you set, and should change it at
   once. That user is in the group `engineering_admins`, which holds the realm's `RealmOwner`: from there, the team
   adds its own users and administrators, and creates realms of its own beneath.

</Steps>

## Check it worked

Your reach runs down into the new realm. With your own session, list who administers it, on its host:

```sh
curl https://foobar-engineering.cvyuh.com/api/v0/am/privilege/v1 \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

```json
{
  "privileges": [
    { "name": "RealmOwner", "groups": ["engineering_admins"], "allAuthenticated": false },
    { "name": "RealmViewer", "groups": [], "allAuthenticated": false }
  ]
}
```

The team's reach never climbs: signed in to `engineering`, `admin@engineering` is refused every change to `foobar`.

<Aside type="tip" title="Undo it">
  Suspend the realm with `curl -X PATCH https://foobar.cvyuh.com/api/v0/am/global/realms/v1/<realm id>`, your session,
  `-H "Content-Type: application/json"` and `-d '{ "status": "suspended" }'`. Nothing in it is lost, and setting
  `status` back to `active` brings it all back.

  Deleting it (`curl -X DELETE` with `-H 'If-Match: *'`) is for good: a deleted realm can't be restored, by you or by
  Cvyūh. See [Deleting a realm](/platform/realms/sub-realms/#deleting-a-realm) before you do.
</Aside>

## Next steps

<CardGrid>
  <LinkCard title="Delegated administration" description="Who may read, change or hand on a realm, and how far their reach goes." href="/platform/realms/delegated-administration/" />
  <LinkCard title="Rotate signing keys" description="Move to a new key without any app refusing a token." href="/platform/guides/rotate-signing-keys/" />
  <LinkCard title="Host names" description="The host names a realm answers on, with certificates handled for you." href="/platform/realms/hostnames/" />
</CardGrid>
