# CSV import

`POST https://wyroapi.com/v1/posts/bulk` creates one post per row of a CSV, each through the same path as `POST /v1/posts` (validation, duplicate guard, queue). Send the file with `Content-Type: text/csv`, or JSON `{"csv": "…"}`. Up to **200 rows** and **1 MB**. [Download the template](https://wyroapi.com/csv/posts-template.csv).

## Columns

| Column | Required | Description |
| --- | --- | --- |
| `text` | yes | The post's text. |
| `platforms` | one of the two | Networks separated by `\|`: `instagram\|linkedin`. |
| `account_ids` | one of the two | Account ids separated by `\|`. |
| `scheduled_at` | no | ISO 8601 with time zone (`2026-12-01T10:00:00-03:00`). Empty: publish now. `queue`: the next free slot of the [queue](https://wyroapi.com/en/docs/queue). |
| `media_urls` | no | Public URLs separated by `\|`. |
| `first_comment` | no | [First comment](https://wyroapi.com/en/docs/per-network-text) where the network supports it. |

Standard CSV: fields with commas, quotes or line breaks go in double quotes, and a quote inside is written twice (`""`). The first line is the header; a UTF-8 BOM (Excel) is fine. Unknown columns are an error, so a typo does not go unnoticed.

```csv
text,platforms,scheduled_at,media_urls,first_comment
"Lanzamos algo nuevo",instagram|linkedin,2026-12-01T10:00:00-03:00,https://example.com/a.jpg,"Link: https://example.com"
"Texto con comas, ""comillas"" y
dos líneas",linkedin|x,2026-12-02T19:00:00-03:00,,
"Al próximo horario libre",facebook,queue,,
```

## 1. Dry run

```
curl -X POST "https://wyroapi.com/v1/posts/bulk?dry_run=true" -H "Authorization: Bearer $WYRO_API_KEY" \
  -H "Content-Type: text/csv" \
  --data-binary @posts.csv
```

Checks every row and creates nothing: `{ "dry_run": true, "total", "valid", "failed", "rows": [...] }`. Each row has `row`, `line` (in the file), `status` (`valid` or `error`), the networks, `scheduled_at` (the queue slot it would take) and, on error, `error.code`, `error.message` and `error.details`. Duplicates inside the same file are caught too.

## 2. Create

```
curl -X POST "https://wyroapi.com/v1/posts/bulk" -H "Authorization: Bearer $WYRO_API_KEY" \
  -H "Content-Type: text/csv" \
  -H "Idempotency-Key: 2f6c1d0a-campaign-december" \
  --data-binary @posts.csv
```

Rows are independent: a row that fails does not stop the rest. Each row returns `post_id` and `preview_url`, or its error. With `Idempotency-Key`, row N uses the key `<key>:row:N`: sending the same file again with the same key creates nothing twice and returns the same results.

A file that is not valid CSV, has no `text` column or is too large fails as a whole (`validation_error` or `bulk_too_large`) before any row runs. With a test key, every row is simulated.

## In the panel

Publicaciones → **Import CSV**: choose the file, check the preview with each row's errors, and confirm.
