# Strokes

> GET, PUT, PATCH and DELETE /v1/strokes — manage user personalization and voice profiles.

Source: https://docs.strokes.ink/api/strokes

A stroke is what the API keeps for a `stroke_id` across requests: durable facts about the user or brand and an optional voice/style profile. See [Strokes](/guides/strokes).

## The stroke object

```json
{
  "type": "stroke",
  "id": "brand-northtrail",
  "created_at": "2026-12-01T10:02:11.000Z",
  "last_used_at": "2026-12-01T10:40:03.000Z",
  "auto_learn": false,
  "facts": [
    "Northtrail makes lightweight hiking gear for weekend backpackers."
  ],
  "voice": {
    "summary": "Plain-spoken, concrete outdoor prose with short sentences and zero hype.",
    "rules": [
      "Lead with a concrete trail detail",
      "Prefer short declarative sentences"
    ],
    "avoid": [
      "exclamation marks",
      "game-changing",
      "seamless"
    ],
    "samples": [
      "Most rain jackets trade breathability for a spec sheet. Ours vents before you notice the climb."
    ]
  }
}
```

| Field | Type | |
| --- | --- | --- |
| `type` | string | Always `stroke` |
| `id` | string | The `stroke_id` (1 to 200 of `A-Z`, `a-z`, `0-9`, `.`, `_`, `:`, `-`) |
| `created_at` | string | When the stroke was created, in RFC 3339 |
| `last_used_at` | string | When the stroke was last used or updated, in RFC 3339 |
| `auto_learn` | boolean | Whether post-request automatic fact extraction runs for this stroke (default `true`) |
| `facts` | array | Up to 30 durable facts (max 240 chars each), oldest first |
| `voice` | object or null | Voice and style profile (`summary`, `rules`, `avoid`, `samples`), or `null` when none is set |

## List strokes

```http
GET https://api.strokes.ink/v1/strokes?limit=20
```

Returns your organization's strokes ordered by `last_used_at` descending. `limit` is optional (`1` to `100`, default `20`).

```json
{
  "object": "list",
  "data": [
    {
      "type": "stroke",
      "id": "brand-northtrail",
      "created_at": "2026-12-01T10:02:11.000Z",
      "last_used_at": "2026-12-01T10:40:03.000Z",
      "auto_learn": false,
      "facts": [
        "Northtrail makes lightweight hiking gear for weekend backpackers."
      ],
      "voice": null
    }
  ],
  "has_more": false,
  "first_id": "brand-northtrail",
  "last_id": "brand-northtrail"
}
```

## Get a stroke

```http
GET https://api.strokes.ink/v1/strokes/{stroke_id}
```

```bash
curl https://api.strokes.ink/v1/strokes/user-42 \
  -H "x-api-key: $STROKES_API_KEY"
```

An id no request or write has created, or one deleted, answers `404 not_found_error` with `stroke: {stroke_id}`.

## Create or replace a stroke

```http
PUT https://api.strokes.ink/v1/strokes/{stroke_id}
```

Creates the stroke if it doesn't exist, or replaces its `facts`, `auto_learn` and `voice` fields. Any cached web pages for the stroke are kept.

| Field | Type | |
| --- | --- | --- |
| `facts` | array | Up to 30 non-empty strings (max 240 chars each). Default `[]` |
| `auto_learn` | boolean | Whether requests with this `stroke_id` automatically extract new facts. Default `true` |
| `voice` | object or null | Optional voice profile: `summary` (max 1,200 chars), `rules` (max 20 × 240 chars), `avoid` (max 30 × 120 chars), `samples` (1–5 samples, max 4,000 chars each, 16,000 total) |
| `analyze` | boolean | Analyze `voice.samples` to generate `summary`, `rules` and `avoid` (merged with any you provide). Defaults to `true` when `samples` are sent without a `summary`; pass `false` to skip analysis |

```bash
curl -X PUT https://api.strokes.ink/v1/strokes/brand-northtrail \
  -H "x-api-key: $STROKES_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "auto_learn": false,
    "facts": [
      "Northtrail makes lightweight hiking gear for weekend backpackers."
    ],
    "voice": {
      "avoid": ["exclamation marks", "game-changing"],
      "samples": [
        "Most rain jackets trade breathability for a spec sheet. Ours vents before you notice the climb."
      ]
    }
  }'
```

## Update a stroke

```http
PATCH https://api.strokes.ink/v1/strokes/{stroke_id}
```

Partially updates an existing stroke — or creates it if it doesn't exist yet. Omitted fields are left unchanged.

| Field | Type | |
| --- | --- | --- |
| `facts` | array or null | Replace the entire facts array (`null` clears it). Cannot be combined with `add_facts` or `remove_facts` |
| `add_facts` | array | Append facts to the existing list (deduplicated, capped at 30) |
| `remove_facts` | array | Remove facts by exact string match or 0-based integer index |
| `auto_learn` | boolean | Turn automatic post-request fact extraction on or off |
| `voice` | object or null | Shallow-merge into the existing voice profile; set any sub-field (`summary`, `rules`, `avoid`, `samples`) to `null` to clear it, or `"voice": null` to clear the entire profile |
| `analyze` | boolean | Re-analyze `voice.samples` (new or existing) into `summary`, `rules` and `avoid`. Defaults to `true` when new `samples` are sent without a `summary` |

```bash
curl -X PATCH https://api.strokes.ink/v1/strokes/user-42 \
  -H "x-api-key: $STROKES_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "add_facts": ["Prefers concise bullet summaries."],
    "remove_facts": [0]
  }'
```

## Delete a stroke

```http
DELETE https://api.strokes.ink/v1/strokes/{stroke_id}
```

Deletes the stroke, its facts, its voice profile and any cached pages from its requests. The next request with the id starts a new, empty one.

```json
{ "type": "stroke_deleted", "id": "user-42" }
```
