---
title: POST /api/articles/import
description: Create an article from one Medium export HTML file. Parses to Scripto's semantic HTML, preserves the original publish date, and defaults to a draft.
---

<Note>

The CLI equivalent is `scripto articles import <path>`, which reads the export files and calls this route per story (with `--dry-run`, `--publish`, and skip flags). See [Import from Medium](/guides/medium-import).

</Note>

Creates an article from **one** Medium export HTML file — the contents of a single `posts/*.html` from Medium's "Download your information" export. Parses it into Scripto's semantic HTML, preserves the original Medium publish date, and defaults to a draft.

## Endpoint

```text
POST https://scripto.codika.io/api/articles/import
```

## Auth

`Authorization: Bearer scripto_…`

## Request

| Field | Type | Meaning |
|---|---|---|
| `html` | string | The raw contents of one Medium export `posts/*.html`. |
| `publish` | boolean | Optional. Publish immediately (ignored for Medium drafts). Default `false`. |

```json
{ "html": "<!doctype html><html>…</html>", "publish": false }
```

## Response (201)

A draft import returns the article row; a published import also returns the public `url`:

```json
{
  "success": true,
  "data": {
    "article": { "id": "0a1b2c3d-…", "title": "My imported story", "status": "draft", "…": "…" },
    "url": "https://scripto.codika.io/story/my-imported-story"
  }
}
```

`createdAt` / `publishedAt` carry the original Medium date; `updatedAt` is set to now so the import surfaces at the top of the library list.

## Errors

| HTTP | `code` | Cause | `nextAction` |
|---|---|---|---|
| 400 | `invalid-argument` | Missing/empty `html`. | Pass the contents of one Medium export `posts/*.html`. |
| 400 | `invalid-argument` | The file is a response/comment, not a story. | Only import published or drafted stories. |
| 401 | `unauthenticated` | Missing or invalid key. | — |
| 500 | `internal` | Backend error. | — |

## curl

```bash
curl -sS -X POST https://scripto.codika.io/api/articles/import \
  -H "Authorization: Bearer $SCRIPTO_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @<(jq -Rs '{html: .}' < ./posts/2024-06-25_My-Story-abc123.html)
```

## Next

- **[Import from Medium](/guides/medium-import)** — the batch CLI workflow.
- **[Articles](/concepts/articles)** — the fields an imported story populates.
