# Quickstart

> From key to first call: create a key, then query a tool, an agent or an MCP client.

Source: https://piqline.com/docs/api

The Piqline API gives your scripts and agents access to your workspace: the same tools and the same agents as the dashboard assistant, over HTTP or MCP (Model Context Protocol). Each call acts on one workspace, with the rights of the member who created the key.

## What you need

- A Piqline workspace where you are owner or admin. Members see the keys page read-only.
- A tool that sends HTTP requests (`curl` in the examples) or an MCP client.

## 1. Create a key

1. Open [Settings → API and MCP](/settings/api).
2. Name the key, tick its scopes (start with `read`) and pick an expiry.
3. Click **Create key**, then copy the key. It is shown only once.

> **Warning.** The key acts with your rights on the workspace. Keep it in a secrets manager or an environment variable, never in code or in a repository. If it leaks, revoke it from the same page.

Store it in an environment variable:

```bash
export PIQLINE_API_KEY="piq_live_…"
```

## 2. Verify the key

```bash tab="curl"
curl -s https://piqline.com/api/v1/workspace \
  -H "Authorization: Bearer $PIQLINE_API_KEY"
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/workspace", {
  headers: { Authorization: "Bearer " + process.env.PIQLINE_API_KEY },
});
const data = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.get(
    "https://piqline.com/api/v1/workspace",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
)
data = response.json()
```

Response:

```json
{
  "workspace": { "id": "b7a1c3e0-5d2f-4c8a-9e41-2f6d0a7b1c93", "name": "Atelier" },
  "key": {
    "id": "0d4e8f2a-71c6-4b3d-8a55-c9e2b6f10d47",
    "name": "Claude Code",
    "prefix": "piq_live_Ab12Cd",
    "scopes": ["read", "agents"]
  },
  "acting_as": {
    "user_id": "3c9a52e1-8b47-4d06-a2f3-71e0b5d4c689",
    "email": "you@example.com",
    "role": "owner"
  },
  "limits": {
    "requests_per_minute": 120,
    "agent_runs_per_minute": 10,
    "requests_per_day": 20000,
    "requests_today": 1
  }
}
```

`key.scopes` lists what the key can do, and `limits` what it has left. A `401` means the key is missing, miscopied or revoked: see [Errors](/docs/api/errors).

## 3. Call a tool

A tool is one capability of the assistant: read the corpus, search live, write, act. This example reads the collection volumes of the last 7 days:

```bash tab="curl"
curl -s https://piqline.com/api/v1/tools/getCoverageStats \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"period":"7d"}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/tools/getCoverageStats", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ period: "7d" }),
});
const data = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/tools/getCoverageStats",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={"period": "7d"},
)
data = response.json()
```

The response carries the tool name and its output (shortened here):

```json
{
  "tool": "getCoverageStats",
  "output": {
    "period": "7d",
    "itemsTotal": 1842,
    "itemsPeriod": 214,
    "items24h": 37,
    "sources": 12,
    "byPlatform": [{ "platform": "rss", "items": 904, "items24h": 20 }]
  }
}
```

The 92 callable tools, their scopes and their inputs are listed in the [catalog](/docs/api/tools#catalog).

## 4. Ask an agent

An agent chains several tools and answers in natural language. The key needs the `agents` scope, plus the scopes of the tools the agent may use.

```bash tab="curl"
curl -s https://piqline.com/api/v1/agents/piqline \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"How many sources does this workspace follow, and which ones are failing?"}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/agents/piqline", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ input: "How many sources does this workspace follow, and which ones are failing?" }),
});
const data = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/agents/piqline",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={"input": "How many sources does this workspace follow, and which ones are failing?"},
)
data = response.json()
```

Response, shortened:

```json
{
  "agent": "piqline",
  "status": "completed",
  "text": "The workspace follows 12 sources, 2 of them failing: …",
  "tool_calls": [{ "tool": "listSources", "state": "output-available" }],
  "pending": []
}
```

More in [Agents](/docs/api/agents).

## 5. Connect an MCP client

With Claude Code:

```bash
claude mcp add --transport http piqline https://piqline.com/api/mcp \
  --header "Authorization: Bearer $PIQLINE_API_KEY"
```

Other clients are covered in [MCP server](/docs/api/mcp).

## Not yet available

- **Webhooks.** Nothing is pushed to your systems. To follow what comes in, poll `getSignals` or `searchItems` at a regular interval.
- **Official SDKs.** The [OpenAPI document](https://piqline.com/api/v1/openapi.json) describes every route: a client generator turns it into an SDK in your language.
- **OAuth sign-in.** Only keys are accepted. Connectors that require OAuth, such as those of claude.ai and ChatGPT, cannot connect yet.
- **Bulk export.** Tools return bounded result pages (at most 40 items for `searchItems`).
