Quickstart
Make your first call in five minutes: create a token, read your projects, write a note into a project's memory and read it back.
You need an internal member account in a Youniton workspace with the right "Memory write" on one project. Client guests cannot create tokens.
#Create a personal access token
In Youniton, open Account › Sessions & apps › API tokens and select Create token. Youniton asks you to confirm who you are first.
- Give the token a name, for example Quickstart.
- Select the abilities
projects:read,memory:readandmemory:write. - Select an expiry: 30, 90 or 365 days, never above your workspace's maximum.
Youniton shows the secret one time. Copy it now. It starts with
kanso_pat_.#Keep the token in an environment variable
Terminal export YOUNITON_TOKEN="kanso_pat_…" # the secret from step 1 export YOUNITON_API="https://app.youniton.example/api/v1" # your workspace's app host + /api/v1#Make your first call
Read the projects that you can see. The token names its tenant, so you do not send a tenant header.
curl -s "$YOUNITON_API/projects" \ -H "Authorization: Bearer $YOUNITON_TOKEN" \ -H "Accept: application/json"const res = await fetch(`${process.env.YOUNITON_API}/projects`, { headers: { Authorization: `Bearer ${process.env.YOUNITON_TOKEN}`, Accept: "application/json" }, }); const { data, meta } = await res.json(); console.log(data.map((p) => p.key), meta.page);import os, requests res = requests.get( f"{os.environ['YOUNITON_API']}/projects", headers={"Authorization": f"Bearer {os.environ['YOUNITON_TOKEN']}", "Accept": "application/json"}, ) res.raise_for_status() print([p["key"] for p in res.json()["data"]])<?php $client = new GuzzleHttp\Client(['base_uri' => getenv('YOUNITON_API') . '/']); $res = $client->get('projects', ['headers' => [ 'Authorization' => 'Bearer ' . getenv('YOUNITON_TOKEN'), 'Accept' => 'application/json', ]]); $projects = json_decode((string) $res->getBody(), true)['data'];The answer is one page of projects in
data, with the page totals inmeta. Note thekeyof a project, for exampleORB. Reference: GET/projects#Write a note into the project's memory
Write a Markdown entry by its path. The first call creates it (
201), with the missing directories. Youniton adds.mdto the name.curl -s -X PUT "$YOUNITON_API/projects/ORB/memory/entries/by-path?path=quickstart/hello" \ -H "Authorization: Bearer $YOUNITON_TOKEN" \ -H "Content-Type: application/json" \ --data '{"body": "# Hello\n\nMy first entry from the API.", "source": {"kind": "agent", "name": "Quickstart script"}}'const url = new URL(`${process.env.YOUNITON_API}/projects/ORB/memory/entries/by-path`); url.searchParams.set("path", "quickstart/hello"); const res = await fetch(url, { method: "PUT", headers: { Authorization: `Bearer ${process.env.YOUNITON_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ body: "# Hello\n\nMy first entry from the API.", source: { kind: "agent", name: "Quickstart script" } }), }); const { data, meta } = await res.json(); console.log(res.status, data.path, meta.outcome); // 201 "quickstart/hello.md" "created"res = requests.put( f"{os.environ['YOUNITON_API']}/projects/ORB/memory/entries/by-path", params={"path": "quickstart/hello"}, headers={"Authorization": f"Bearer {os.environ['YOUNITON_TOKEN']}"}, json={"body": "# Hello\n\nMy first entry from the API.", "source": {"kind": "agent", "name": "Quickstart script"}}, ) print(res.status_code, res.json()["meta"]["outcome"])$res = $client->put('projects/ORB/memory/entries/by-path', [ 'query' => ['path' => 'quickstart/hello'], 'headers' => ['Authorization' => 'Bearer ' . getenv('YOUNITON_TOKEN')], 'json' => ['body' => "# Hello\n\nMy first entry from the API.", 'source' => ['kind' => 'agent', 'name' => 'Quickstart script']], ]); $outcome = json_decode((string) $res->getBody(), true)['meta']['outcome'];Send the same call again: the answer is
200withmeta.outcomeunchanged. A new body givesupdated. Reference: PUT/projects/{projectKey}/memory/entries/by-path#Read it back
Read the entry by its path. This proves that the write is saved — never trust a "saved" message alone.
GET /projects/{projectKey}/memory/entries/by-path curl -s "$YOUNITON_API/projects/ORB/memory/entries/by-path?path=quickstart/hello.md" \ -H "Authorization: Bearer $YOUNITON_TOKEN"The answer holds the body, the path, the source and the
version. TheETagheader carries the same version for If-Match. Reference: GET/projects/{projectKey}/memory/entries/by-path
#Next steps
Was this helpful?