# API a0: scripts,  e9tapes et dossiers

_API · Lecture de 5 min · Mis à jour 2026-10-22 · https://lanachat.ai/guides/fr/api-scripts/_

Un **script** est une s e9quence fixe d' e9tapes pour une cr e9atrice a0: chaque  e9tape est un texte, des m e9dias optionnels du Vault, un prix en Stars et un d e9lai avant la suivante. Les scripts sont rang e9s dans des dossiers. Un seul script par cr e9atrice peut  eatre marqu e9 **first** a0: il s'ex e9cute sur les nouvelles conversations.

## Endpoints

| Method | Path | Description | Permission | Status |
|---|---|---|---|---|
| GET | `/scripts` | Lister les scripts (`creator_id=` obligatoire, `folder_id=`, `active=true`) | `can_setup` | Planned |
| POST | `/scripts` | Cr e9er un script avec ses  e9tapes | `can_setup` | Planned |
| GET | `/scripts/{id}` | Un script et ses  e9tapes | `can_setup` | Planned |
| PUT | `/scripts/{id}` | Remplacer un script (nom,  e9tapes, dossier, comptes) | `can_setup` | Planned |
| PATCH | `/scripts/{id}` | Activer ou d e9sactiver, marquer first, d e9placer dans un dossier | `can_setup` | Planned |
| POST | `/scripts/{id}/duplicate` | Copier un script (la copie n'est jamais first) | `can_setup` | Planned |
| DELETE | `/scripts/{id}` | Supprimer un script | `can_setup` | Planned |
| GET | `/scripts/folders` | Dossiers d'une cr e9atrice (`creator_id=`) | `can_setup` | Planned |
| POST | `/scripts/folders` | Cr e9er un dossier | `can_setup` | Planned |
| PATCH | `/scripts/folders/{id}` | Renommer un dossier | `can_setup` | Planned |
| DELETE | `/scripts/folders/{id}` | Supprimer un dossier a0; ses scripts vont dans "No folder" | `can_setup` | Planned |
| POST | `/conversations/{id}/script` | Lancer un script sur une conversation (voir [Conversations](https://lanachat.ai/guides/fr/api-conversations/)) | `can_chat` | Planned |

## The script object

```json
{
  "id": "scr_204",
  "creator_id": "cr_lea",
  "name": "Welcome message",
  "goal": "First sale within the first day",
  "folder_id": "fld_12",
  "active": true,
  "first": true,
  "account_ids": null,
  "steps": [
    { "id": "st_1", "name": "Hello", "text": "Hey you 😊 glad you found me here", "media": [], "wait_minutes": 0, "pricing": { "mode": "free" } },
    { "id": "st_2", "name": "First set", "text": "Made this one this morning…", "media": ["med_5521", "med_5522"], "wait_minutes": 20, "pricing": { "mode": "paid", "stars": 250, "discount_stars": 200 } }
  ],
  "created_at": "2026-09-30T10:00:00Z",
  "updated_at": "2026-10-05T16:22:00Z"
}
```

| Field | Type | Description |
|---|---|---|
| `id` | string | Commence par `scr_` |
| `creator_id` | string | La cr e9atrice dont les fans le re e7oivent |
| `name` | string | Son nom dans la Console |
| `goal` | string or null | L'objectif du script, avec vos mots |
| `folder_id` | string or null | Son dossier a0; `null` signifie "No folder" |
| `active` | boolean | `false` signifie qu'il ne s'ex e9cute jamais |
| `first` | boolean | `true` signifie qu'il s'ex e9cute sur les nouvelles conversations |
| `account_ids` | array or null | `null` signifie tous les comptes Telegram de la cr e9atrice a0; un tableau signifie uniquement ceux-l e0 (au moins un) |
| `steps` | array | Les  e9tapes, dans l'ordre (voir ci-dessous) |
| `created_at`, `updated_at` | string | ISO 8601, UTC |

Chaque  e9tape contient a0:

| Field | Type | Description |
|---|---|---|
| `id` | string | Commence par `st_` |
| `name` | string | Son nom dans l' e9diteur |
| `text` | string | Le message re e7u par le fan |
| `media` | array of strings | IDs m e9dias du [Vault](https://lanachat.ai/guides/fr/api-vault/) de la cr e9atrice |
| `wait_minutes` | number | D e9lai avant l'envoi de cette  e9tape |
| `pricing.mode` | string | `free`, `vault` (chaque m e9dia  e0 son prix Vault) ou `paid` (un prix pour toute l' e9tape) |
| `pricing.stars` | number | Le prix en Stars, si `mode` est `paid` |
| `pricing.discount_stars` | number | Prix r e9duit en Stars, optionnel |

Mettre `first: true` sur un script le retire des autres scripts de la cr e9atrice.

## Scripts

### List scripts

`GET /scripts` · `can_setup`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `creator_id` | string | Yes | La cr e9atrice |
| `folder_id` | string | No | Uniquement les scripts de ce dossier |
| `active` | boolean | No | `true` liste uniquement les scripts actifs |
| `limit`, `cursor` | number, string | No | [Pagination](https://lanachat.ai/guides/fr/api-overview/) |

```bash
curl "https://api.lanachat.ai/v1/scripts?creator_id=cr_lea&active=true" \
  -H "Authorization: Bearer $LANACHAT_TOKEN"
```

La r e9ponse est une page de script objects dans `data`, avec `next_cursor`. Sans `creator_id` l'API r e9pond `400`.

### Create a script

`POST /scripts` · `can_setup`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `creator_id` | string | Yes | La cr e9atrice |
| `name` | string | Yes | Son nom |
| `steps` | array | Yes | Les  e9tapes, comme dans l'objet ci-dessus (sans `id`) |
| `goal` | string | No | Son objectif |
| `folder_id` | string | No | Un dossier de la m eame cr e9atrice |
| `account_ids` | array of strings | No | Uniquement ces comptes a0; laissez vide pour tous |

```bash
curl -X POST https://api.lanachat.ai/v1/scripts \
  -H "Authorization: Bearer $LANACHAT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"creator_id": "cr_lea", "name": "Win back", "steps": [{"name": "Miss you", "text": "Hey stranger, where did you go?", "wait_minutes": 0, "pricing": {"mode": "free"}}]}'
```

```json
{
  "id": "scr_231",
  "creator_id": "cr_lea",
  "name": "Win back",
  "goal": null,
  "folder_id": null,
  "active": true,
  "first": false,
  "account_ids": null,
  "steps": [ { "id": "st_1", "name": "Miss you", "text": "Hey stranger, where did you go?", "media": [], "wait_minutes": 0, "pricing": { "mode": "free" } } ],
  "created_at": "2026-10-06T14:30:00Z",
  "updated_at": "2026-10-06T14:30:00Z"
}
```

La r e9ponse est le nouveau script (`201`), actif, pas first, sans dossier. Un ID m e9dia d'un autre Vault de cr e9atrice est refus e9 (`400`).

### Get a script

`GET /scripts/{id}` · `can_setup`

```bash
curl https://api.lanachat.ai/v1/scripts/scr_204 \
  -H "Authorization: Bearer $LANACHAT_TOKEN"
```

La r e9ponse est le script object avec toutes ses  e9tapes.

### Replace a script

`PUT /scripts/{id}` · `can_setup`

Envoyez tout le script a0: `name`, `steps`, `folder_id` et `account_ids`, comme dans Create a script. Les  e9tapes omises sont supprim e9es.

```bash
curl -X PUT https://api.lanachat.ai/v1/scripts/scr_231 \
  -H "Authorization: Bearer $LANACHAT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Win back", "folder_id": "fld_12", "account_ids": null, "steps": [{"name": "Miss you", "text": "Hey stranger, where did you go?", "wait_minutes": 0, "pricing": {"mode": "free"}}, {"name": "Gift", "text": "Kept this one for you", "media": ["med_5522"], "wait_minutes": 30, "pricing": {"mode": "paid", "stars": 200}}]}'
```

La r e9ponse est le script mis  e0 jour. Un tableau `account_ids` vide r e9pond `400` a0: utilisez `null` pour tous les comptes.

### Turn on, mark first, move

`PATCH /scripts/{id}` · `can_setup`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `active` | boolean | No | Activer ou d e9sactiver |
| `first` | boolean | No | `true` le rend script des nouvelles conversations |
| `folder_id` | string or null | No | D e9placer a0; `null` signifie "No folder" |

```bash
curl -X PATCH https://api.lanachat.ai/v1/scripts/scr_231 \
  -H "Authorization: Bearer $LANACHAT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"first": true}'
```

La r e9ponse est le script mis  e0 jour. L'ancien script first de la cr e9atrice perd `first`.

### Duplicate a script

`POST /scripts/{id}/duplicate` · `can_setup`

```bash
curl -X POST https://api.lanachat.ai/v1/scripts/scr_204/duplicate \
  -H "Authorization: Bearer $LANACHAT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"
```

La r e9ponse est la copie (`201`). La copie n'est jamais first.

### Delete a script

`DELETE /scripts/{id}` · `can_setup`

```bash
curl -X DELETE https://api.lanachat.ai/v1/scripts/scr_231 \
  -H "Authorization: Bearer $LANACHAT_TOKEN"
```

## Folders

### List folders

`GET /scripts/folders` · `can_setup`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `creator_id` | string | Yes | La cr e9atrice |

```bash
curl "https://api.lanachat.ai/v1/scripts/folders?creator_id=cr_lea" \
  -H "Authorization: Bearer $LANACHAT_TOKEN"
```

### Create a folder

`POST /scripts/folders` · `can_setup`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `creator_id` | string | Yes | La cr e9atrice |
| `name` | string | Yes | Nom du dossier |

```bash
curl -X POST https://api.lanachat.ai/v1/scripts/folders \
  -H "Authorization: Bearer $LANACHAT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"creator_id": "cr_lea", "name": "Win back"}'
```

### Rename a folder

`PATCH /scripts/folders/{id}` · `can_setup`

```bash
curl -X PATCH https://api.lanachat.ai/v1/scripts/folders/fld_12 \
  -H "Authorization: Bearer $LANACHAT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Welcome"}'
```

### Delete a folder

`DELETE /scripts/folders/{id}` · `can_setup`

```bash
curl -X DELETE https://api.lanachat.ai/v1/scripts/folders/fld_12 \
  -H "Authorization: Bearer $LANACHAT_TOKEN"
```

Ses scripts sont conserv e9s et vont dans "No folder".

## Run a script on a conversation

`POST /conversations/{id}/script` · `can_chat`

Lance un script sur la conversation d'un fan a0: `state` devient `script` jusqu' e0 la fin. Corps, exemple et r e8gles dans [Conversations](https://lanachat.ai/guides/fr/api-conversations/).

## Articles liés

- [API LanaChat : démarrage rapide, authentification et erreurs](https://lanachat.ai/guides/fr/api-overview/)
- [Scripts : écrivez, organisez et utilisez-les](https://lanachat.ai/guides/fr/scripts/)
- [Scripts vs IA : quand le bot suit un script](https://lanachat.ai/guides/fr/scripts-vs-ai/)
