# Écriture

> Écrire dans le workspace. 12 outils, avec leurs paramètres et des exemples d’appel.

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

Outils de l’agent Piqline qui créent ou modifient des objets du workspace. Ils demandent le scope `write`.

Chaque appel est une requête `POST` avec la clé en `Authorization: Bearer`. Le corps JSON est l’entrée de l’outil, et la réponse a la forme `{ "tool": "nom", "output": … }`. Les exemples ne portent que les paramètres requis. Les descriptions des paramètres sont celles que lisent les agents, en anglais.

### `updateWorkspaceProfile`

Enregistre le profil de besoin du workspace : objectifs, sujets, entités, langues, zones, niveau, rythme.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `needs` | `object` | Non |  |
| `stage` | `string` | Non |  |
| `onboarding_status` | `not_started \| in_progress \| done \| skipped` | Non |  |
| `summary` | `string` | Non |  |

```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`

Suit une entreprise, une marque ou un compte public (jamais une personne privée) pour lier ses items et ses mentions.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `name` | `string` | Oui |  |
| `kind` | `company \| brand \| account` | Non |  |
| `siren` | `string` | Non |  |
| `domain` | `string` | Non |  |
| `handles` | `array<object>` | Non |  |
| `role` | `self \| competitor \| client \| target \| other` | Non |  |
| `aliases` | `array<string>` | Non |  |

```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`

Arrête de suivre une entité. Ses liens existants restent.

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

Type : Suppression. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `entityId` | `string` | Oui |  |

```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`

Enregistre un signet dans le coffre du workspace. Une URL http(s) est mise en file pour lecture, persistance et vectorisation.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `title` | `string` | Oui |  |
| `href` | `string` | Oui |  |
| `kind` | `item \| source \| signal \| graph \| search \| document \| board \| chat` | Non |  |
| `subtitle` | `string` | Non |  |
| `note` | `string` | Non |  |
| `tags` | `array<string>` | Non |  |
| `origin` | `dashboard \| api \| slack \| whatsapp \| mail \| other` | Non |  |
| `originRef` | `string` | Non |  |

```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`

Pose un contrat de veille sur une source : la page de veille n’affiche plus que les items qui correspondent. Déterministe, sans modèle.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `sourceId` | `string` | Oui |  |
| `intent` | `string` | Oui | What this workspace watches on the source, in the person's words. |
| `include` | `array<string>` | Non | Keep an item only if it contains at least one of these terms (whole word, any case or accent). |
| `exclude` | `array<string>` | Non | Drop an item containing any of these terms. |
| `event` | `hiring \| funding \| launch \| expansion \| reorg \| open_to_work \| leaving \| interested_comment \| …` | Non | Business event the item must announce (hiring, funding, launch…), read from its text. |
| `sectors` | `array<string>` | Non |  |

```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`

Retire le contrat de veille d’une source : tous les items réapparaissent.

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

Type : Suppression. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `sourceId` | `string` | Oui |  |

```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`

Enregistre les deux réponses de l’entretien de lecture (essentiel ou détail, intention principale) sur le profil de lecture.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `density` | `essentiel \| detail` | Oui |  |
| `intent` | `read-arrivals \| spot-change \| watch-entities \| compare \| measure-coverage \| control-sources \| analyze-market \| prepare-output \| …` | Oui |  |

```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`

Applique à un board des modifications déjà validées.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `dashboardId` | `string` | Non |  |
| `changes` | `array<object>` | Oui |  |

```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`

Assemble un board directement, sans passer par le panneau de choix de widgets.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `spec` | `object` | Oui |  |
| `save` | `boolean` | Non | 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`

Crée une table du workspace, remplie des colonnes utiles.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `name` | `string` | Oui |  |
| `comment` | `string` | Oui |  |
| `columns` | `array<object>` | Oui |  |
| `rows` | `array<object>` | Oui |  |

```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`

Écrit un texte à partir des items des veilles du workspace (article, post LinkedIn, thread X, légende Instagram, newsletter, script vidéo, communiqué, article SEO, e-mail, synthèse), en neuf langues, chaque fait cité [n] vers sa source ; le texte rejoint les brouillons. Consomme quelques crédits.

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

Type : Écriture. Scopes : `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `instruction` | `string` | Oui | 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` | Non | Optional sample text whose style to follow. |
| `scope` | `object` | Non | 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` | Non | 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` | Non | 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`

Fait vivre une table : dès qu’un item du corpus correspond à la règle, il s’ajoute, après confirmation. status=paused arrête le remplissage.

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

Type : Action. Scopes : `act`, `write`.

| Paramètre | Type | Requis | Description |
| --- | --- | --- | --- |
| `schema` | `string` | Non |  |
| `name` | `string` | Oui |  |
| `status` | `live \| paused` | Non |  |
| `prompt` | `string` | Oui | The person's words, unchanged. |
| `summary` | `string` | Oui | What you understood, in plain French, one sentence. |
| `sourceIds` | `array<string>` | Non |  |
| `sourceLabels` | `array<string>` | Non |  |
| `query` | `string` | Non |  |
| `platform` | `string` | Non |  |
| `itemType` | `post \| video \| article \| listing \| job_offer` | Non |  |
| `alreadyMatching` | `integer` | Non | 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"]
```
