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

# Quickstart

> Create an agent and run its first thread with curl.

Let's get an agent running from the command line. You'll create a profile with
its model, instructions, and tools, create an agent on it, then start a thread
with your first prompt.

## Get a key

Matrices is in early access, so there's no self-serve sign-up yet. Once your
workspace exists, its owner creates API keys in the console under
**Workspace → API keys**. Keys belong to the workspace: one reaches every agent
in it, unless the owner scoped it to a single agent. This walkthrough creates
things, so use a key that isn't scoped to an agent. You'll also need **curl**
and **jq**. Export the key:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export MATRICES_API_KEY="mtx_sk_example"
```

That one key authenticates every call below.

## 1. Pick a role

An agent gets its tools from the roles in its profile. Every workspace starts
with an `Administrator` role that allows every tool (`tool:*`). Grab its ID:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export ROLE_ID="$(
  curl --fail --silent --show-error "https://api.matrices.com/v1/roles?limit=200" \
    -H "Authorization: Bearer $MATRICES_API_KEY" |
    jq -er '.roles[] | select(.name == "Administrator") | .id'
)"
```

If that comes back empty, someone renamed or deleted the role. Pick another
from `GET /v1/roles`, or create one that allows everything:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export ROLE_ID="$(
  curl --fail --silent --show-error "https://api.matrices.com/v1/roles" \
    -H "Authorization: Bearer $MATRICES_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "name": "Quickstart", "allow": ["tool:*"] }' | jq -er '.role.id'
)"
```

## 2. Create a profile

A profile is the configuration agents run on:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export PROFILE_ID="$(
  curl --fail --silent --show-error "https://api.matrices.com/v1/profiles" \
    -H "Authorization: Bearer $MATRICES_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Workspace guide",
      "configuration": {
        "models": ["matrices/auto"],
        "instructions": "Be concise. When asked about available agents, use the agents.list tool.",
        "roleIds": ["'"$ROLE_ID"'"]
      }
    }' | jq -er '.profile.id'
)"
```

* `models` lists the models it may use, in order: exact IDs, aliases like
  `matrices/auto`, or wildcards. See [Models](https://docs.matrices.com/reference/models.md).
* `instructions` is what the agent carries into every turn. See
  [Profiles](https://docs.matrices.com/model/profiles.md).
* `roleIds` is where every tool comes from. See [Roles](https://docs.matrices.com/model/roles.md).

Leaving out `hooks` gives the profile the default approval hooks, so risky
calls like sending email wait for a person. See [Hooks](https://docs.matrices.com/model/hooks.md).

## 3. Create the agent

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export AGENT_ID="$(
  curl --fail --silent --show-error "https://api.matrices.com/v1/agents" \
    -H "Authorization: Bearer $MATRICES_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Workspace guide",
      "identity": "svc:quickstart",
      "profileId": "'"$PROFILE_ID"'"
    }' | jq -er '.agent.id'
)"
```

`identity` is who the agent acts for, and it never changes. See
[Identities](https://docs.matrices.com/model/identities.md). Several agents can share one profile. You can
also send the configuration inline as `profile` instead of `profileId`, which
creates a profile just for this agent.

> [!TIP]
>
> To call your own tools, register a client or MCP [toolset](https://docs.matrices.com/model/toolsets.md),
> then grant its names in a role, such as `tool:workspace:billing.lookup_invoice`.

## 4. Start a thread

Start a thread by sending the agent its first user prompt as a text content block:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export THREAD_ID="$(
  curl --fail --silent --show-error \
    "https://api.matrices.com/v1/agents/$AGENT_ID/threads" \
    -H "Authorization: Bearer $MATRICES_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "content": [
        {
          "type": "text",
          "text": "Which agents are available in this workspace? Summarize each in one sentence."
        }
      ]
    }' | jq -er '.threadId'
)"
```

The response also includes a `turnId` and a status. The turn runs in the
background.

## 5. Stream the result

Connect to the thread's event stream to watch the agent reply:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl --no-buffer --fail --silent --show-error \
  "https://api.matrices.com/v1/threads/$THREAD_ID/events/stream" \
  -H "Authorization: Bearer $MATRICES_API_KEY"
```

The stream is Server-Sent Events, and it's for watching the turn as it
happens. The durable record is the log at `GET /v1/threads/{threadId}/events`,
which you can read back any time. See [Threads](https://docs.matrices.com/model/threads.md).

## What's next

> [card] [How it fits together](https://docs.matrices.com/model/how-it-fits-together.md)
>
> Every noun, and what owns what.

> [card] [Build a real agent](https://docs.matrices.com/guides/first-agent.md)
>
> Roles, profiles, and identity, in the order they matter.

> [card] [Narrow the permissions](https://docs.matrices.com/guides/narrow-permissions.md)
>
> Cut an agent down to the tools it should have.

> [card] [Connect a service](https://docs.matrices.com/guides/connect-a-service.md)
>
> Give an agent credentials without showing the model a secret.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.