# 写入

> 写入工作区。12 个工具，附参数和调用示例。

Source: https://piqline.com/zh/docs/api/reference/write

Piqline 智能体中创建或修改工作区对象的工具。它们需要 `write` scope。

每次调用都是一个 `POST` 请求，密钥放在 `Authorization: Bearer` 中。JSON 请求体是工具的输入，响应形如 `{ "tool": "nom", "output": … }`。示例中只包含必填参数。参数说明与智能体读到的相同。

### `updateWorkspaceProfile`

保存工作区的需求档案：目标、主题、实体、语言、地区、级别、节奏。

`POST https://piqline.com/api/v1/tools/updateWorkspaceProfile`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `needs` | `object` | 否 |  |
| `stage` | `string` | 否 |  |
| `onboarding_status` | `not_started \| in_progress \| done \| skipped` | 否 |  |
| `summary` | `string` | 否 |  |

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

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

### `followEntity`

关注一家公司、一个品牌或一个公开账号（绝不关注私人个体），以关联其条目和提及。

`POST https://piqline.com/api/v1/tools/followEntity`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `name` | `string` | 是 |  |
| `kind` | `company \| brand \| account` | 否 |  |
| `siren` | `string` | 否 |  |
| `domain` | `string` | 否 |  |
| `handles` | `array<object>` | 否 |  |
| `role` | `self \| competitor \| client \| target \| other` | 否 |  |
| `aliases` | `array<string>` | 否 |  |

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

response = requests.post(
    "https://piqline.com/api/v1/tools/followEntity",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "name": "texte",
    },
)
output = response.json()["output"]
```

### `unfollowEntity`

停止关注某个实体。已有的关联保留。

`POST https://piqline.com/api/v1/tools/unfollowEntity`

类型：删除。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `entityId` | `string` | 是 |  |

```bash tab="curl"
curl -s https://piqline.com/api/v1/tools/unfollowEntity \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"entityId":"5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70"}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/tools/unfollowEntity", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "entityId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70"
  }),
});
const { output } = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/tools/unfollowEntity",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "entityId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
    },
)
output = response.json()["output"]
```

### `saveBookmark`

把书签保存到工作区收藏库。http(s) URL 会进入队列，等待读取、归档和向量化。

`POST https://piqline.com/api/v1/tools/saveBookmark`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `title` | `string` | 是 |  |
| `href` | `string` | 是 |  |
| `kind` | `item \| source \| signal \| graph \| search \| document \| board \| chat` | 否 |  |
| `subtitle` | `string` | 否 |  |
| `note` | `string` | 否 |  |
| `tags` | `array<string>` | 否 |  |
| `origin` | `dashboard \| api \| slack \| whatsapp \| mail \| other` | 否 |  |
| `originRef` | `string` | 否 |  |

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

response = requests.post(
    "https://piqline.com/api/v1/tools/saveBookmark",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "title": "texte",
        "href": "texte",
    },
)
output = response.json()["output"]
```

### `setWatchContract`

为来源设置监控合约：监控页面随后只显示匹配的条目。确定性规则，不使用模型。

`POST https://piqline.com/api/v1/tools/setWatchContract`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `sourceId` | `string` | 是 |  |
| `intent` | `string` | 是 | What this workspace watches on the source, in the person's words. |
| `include` | `array<string>` | 否 | Keep an item only if it contains at least one of these terms (whole word, any case or accent). |
| `exclude` | `array<string>` | 否 | Drop an item containing any of these terms. |
| `event` | `hiring \| funding \| launch \| expansion \| reorg \| open_to_work \| leaving \| interested_comment \| …` | 否 | Business event the item must announce (hiring, funding, launch…), read from its text. |
| `sectors` | `array<string>` | 否 |  |

```bash tab="curl"
curl -s https://piqline.com/api/v1/tools/setWatchContract \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sourceId":"5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70","intent":"texte"}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/tools/setWatchContract", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "sourceId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
    "intent": "texte"
  }),
});
const { output } = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/tools/setWatchContract",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "sourceId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
        "intent": "texte",
    },
)
output = response.json()["output"]
```

### `removeWatchContract`

移除来源的监控合约：所有条目重新显示。

`POST https://piqline.com/api/v1/tools/removeWatchContract`

类型：删除。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `sourceId` | `string` | 是 |  |

```bash tab="curl"
curl -s https://piqline.com/api/v1/tools/removeWatchContract \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sourceId":"5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70"}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/tools/removeWatchContract", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "sourceId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70"
  }),
});
const { output } = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/tools/removeWatchContract",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "sourceId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
    },
)
output = response.json()["output"]
```

### `initReaderInterview`

把阅读访谈的两个答案（只看要点还是看细节、主要意图）保存到阅读档案中。

`POST https://piqline.com/api/v1/tools/initReaderInterview`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `density` | `essentiel \| detail` | 是 |  |
| `intent` | `read-arrivals \| spot-change \| watch-entities \| compare \| measure-coverage \| control-sources \| analyze-market \| prepare-output \| …` | 是 |  |

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

response = requests.post(
    "https://piqline.com/api/v1/tools/initReaderInterview",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "density": "essentiel",
        "intent": "read-arrivals",
    },
)
output = response.json()["output"]
```

### `applyBoardChange`

把已经批准的更改应用到看板。

`POST https://piqline.com/api/v1/tools/applyBoardChange`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `dashboardId` | `string` | 否 |  |
| `changes` | `array<object>` | 是 |  |

```bash tab="curl"
curl -s https://piqline.com/api/v1/tools/applyBoardChange \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"changes":[{"id":"5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70","kind":"add","widgetId":"5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70","reason":"texte","title":"texte"}]}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/tools/applyBoardChange", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "changes": [
      {
        "id": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
        "kind": "add",
        "widgetId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
        "reason": "texte",
        "title": "texte"
      }
    ]
  }),
});
const { output } = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/tools/applyBoardChange",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "changes": [
            {
                "id": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
                "kind": "add",
                "widgetId": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
                "reason": "texte",
                "title": "texte",
            },
        ],
    },
)
output = response.json()["output"]
```

### `buildDashboard`

直接构建看板，不经过组件选择器。

`POST https://piqline.com/api/v1/tools/buildDashboard`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `spec` | `object` | 是 |  |
| `save` | `boolean` | 否 | Persist the board when the user is owner/admin. |

```bash tab="curl"
curl -s https://piqline.com/api/v1/tools/buildDashboard \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"spec":{"version":1,"title":"texte","description":"texte","period":"1h","widgets":[{"kind":"texte","title":"texte"}]}}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/tools/buildDashboard", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "spec": {
      "version": 1,
      "title": "texte",
      "description": "texte",
      "period": "1h",
      "widgets": [
        {
          "kind": "texte",
          "title": "texte"
        }
      ]
    }
  }),
});
const { output } = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/tools/buildDashboard",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "spec": {
            "version": 1,
            "title": "texte",
            "description": "texte",
            "period": "1h",
            "widgets": [
                {
                    "kind": "texte",
                    "title": "texte",
                },
            ],
        },
    },
)
output = response.json()["output"]
```

### `saveWorkspaceTable`

创建一个工作区表格，并填入有用的列。

`POST https://piqline.com/api/v1/tools/saveWorkspaceTable`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `name` | `string` | 是 |  |
| `comment` | `string` | 是 |  |
| `columns` | `array<object>` | 是 |  |
| `rows` | `array<object>` | 是 |  |

```bash tab="curl"
curl -s https://piqline.com/api/v1/tools/saveWorkspaceTable \
  -H "Authorization: Bearer $PIQLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"texte","comment":"texte","columns":[{"id":"5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70","name":"texte","type":"text"}],"rows":[{}]}'
```
```javascript tab="JavaScript"
const response = await fetch("https://piqline.com/api/v1/tools/saveWorkspaceTable", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.PIQLINE_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "texte",
    "comment": "texte",
    "columns": [
      {
        "id": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
        "name": "texte",
        "type": "text"
      }
    ],
    "rows": [
      {}
    ]
  }),
});
const { output } = await response.json();
```
```python tab="Python"
import os
import requests

response = requests.post(
    "https://piqline.com/api/v1/tools/saveWorkspaceTable",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "name": "texte",
        "comment": "texte",
        "columns": [
            {
                "id": "5a0e9c1f-2b7d-4e63-8f14-d3c8a6b92e70",
                "name": "texte",
                "type": "text",
            },
        ],
        "rows": [
            {},
        ],
    },
)
output = response.json()["output"]
```

### `writeFromWatch`

根据工作区监控的条目撰写文本（文章、LinkedIn 帖子、X 串文、Instagram 配文、新闻简报、视频脚本、新闻稿、SEO 文章、电子邮件、摘要），支持九种语言，每个事实都以 [n] 标注来源；文本进入草稿。会消耗少量积分。

`POST https://piqline.com/api/v1/tools/writeFromWatch`

类型：写入。Scope：`write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `instruction` | `string` | 是 | What to write and for whom, in plain words, e.g. « Le post de la semaine sur ce qui a bougé dans la cosmétique ». |
| `example` | `string` | 否 | Optional sample text whose style to follow. |
| `scope` | `object` | 否 | Which items of the workspace watches to write from: sources, topics, keywords, platforms, item types or item ids, period and depth. Default: the last 7 days, 15 items. |
| `pen` | `object` | 否 | Format (article, linkedin, x_thread, instagram, newsletter, video_script, press_release, seo_brief, email, summary), goal, tone, framework, length, voice, language (fr, en, es, de, it, pt, nl, he, ar), creativity, variants and options. |
| `save` | `boolean` | 否 | Keep the text in the workspace drafts (default). false: return it only. |

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

response = requests.post(
    "https://piqline.com/api/v1/tools/writeFromWatch",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "instruction": "texte",
    },
)
output = response.json()["output"]
```

### `setTableFeed`

让表格自动更新：一旦语料库中的条目符合规则，经确认后就会加入表格。status=paused 会停止填充。

`POST https://piqline.com/api/v1/tools/setTableFeed`

类型：操作。Scope：`act`, `write`。

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `schema` | `string` | 否 |  |
| `name` | `string` | 是 |  |
| `status` | `live \| paused` | 否 |  |
| `prompt` | `string` | 是 | The person's words, unchanged. |
| `summary` | `string` | 是 | What you understood, in plain French, one sentence. |
| `sourceIds` | `array<string>` | 否 |  |
| `sourceLabels` | `array<string>` | 否 |  |
| `query` | `string` | 否 |  |
| `platform` | `string` | 否 |  |
| `itemType` | `post \| video \| article \| listing \| job_offer` | 否 |  |
| `alreadyMatching` | `integer` | 否 | How many items searchItems found just now. |

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

response = requests.post(
    "https://piqline.com/api/v1/tools/setTableFeed",
    headers={"Authorization": "Bearer " + os.environ["PIQLINE_API_KEY"]},
    json={
        "name": "texte",
        "prompt": "texte",
        "summary": "texte",
    },
)
output = response.json()["output"]
```
