# Projects and ideas

A project is one website in Unspar. With these endpoints, your code creates projects, changes their settings and turns on Project Auto. It can also let Unspar find ideas for new articles.

Web version: https://www.unspar.com/docs/api/projects/

Everything you write in Unspar belongs to a project. A project stores who your site is for along with the defaults for new articles, such as language and template. Any article you start through the [article endpoints](https://www.unspar.com/docs/api/articles/) inherits these settings unless you override them for that specific article.

These same projects appear under [Projects](https://app.unspar.com/projects) in the web app. To see how each setting affects the final article, read [Projects and site context](https://www.unspar.com/docs/guides/projects-and-site-context/).

## Create a project

`POST /projects` requires a `name` and the website's `url`. If you leave out `language` and `timezone`, they default to `en-US` and `UTC`, so send both if your site targets another language or region. Only an API token with access to all projects can create a new one.

```sh
curl -X POST https://app.unspar.com/api/v1/projects \
  -H "Authorization: Bearer $UNSPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My blog",
    "url": "https://example.com",
    "language": "en-GB",
    "timezone": "Europe/London",
    "context": {
      "background": "Guides for people who repair their own bikes. Readers are in the UK, so prices are in pounds. We do not recommend specific shops."
    }
  }'
```

The response returns the new project inside `data`, including its `id`.

## Change the settings

`PATCH /projects/{project}` updates only the fields you include in the request. This also works for individual keys inside `context`. For example, this request updates the form of address and leaves everything else untouched:

```sh
curl -X PATCH https://app.unspar.com/api/v1/projects/<project-id> \
  -H "Authorization: Bearer $UNSPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": {"address_form": "formal"}}'
```

Here are the fields that shape new articles:

| Field                       | What it sets                                                                                                    |
| --------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `language`                  | The language of new articles, as a tag like `en-US` or `de-DE`.                                                 |
| `timezone`                  | The time zone for publishing times, like `Europe/Berlin`.                                                       |
| `status`                    | `active`, `paused` or `archived`. New articles only start in an `active` project.                               |
| `context.background`        | The site context: two to four plain sentences on who reads the site and what it covers. Up to 5,000 characters. |
| `context.address_form`      | `formal`, `informal` or `auto`. This matters in languages like German or French.                                |
| `context.target_word_count` | The default length. One of `1000`, `2000`, `3000`, `5000`, `7500` or `10000`. `null` lets the topic decide.     |
| `defaults.content_template` | The template for new articles.                                                                                  |
| `defaults.voice`            | The voice for new articles.                                                                                     |
| `defaults.outlet`           | The outlet new articles go to.                                                                                  |

Send `null` to clear any of the `defaults`. Leave writing style instructions out of `context.background`, since the template and voice handle that.

Target length affects the price. Starting at 3,000 words, an article is at least In-depth (4 credits). Starting at 7,500 words, it becomes a Report (15 credits).

## Delete a project

`DELETE /projects/{project}` removes the project permanently, and the API has no way to restore it. If you want to stop new articles without losing the project, set `status` to `paused` or `archived` instead.

## Turn on Project Auto

Project Auto writes articles for a project every day without you having to start each one manually. It pulls from your project's best ideas first, and when those run out, it starts a new idea run on its own. Keep in mind that it spends credits automatically for every article and idea run without asking first.

Use `PUT /projects/{project}/auto` to turn it on or update its settings:

```sh
curl -X PUT https://app.unspar.com/api/v1/projects/<project-id>/auto \
  -H "Authorization: Bearer $UNSPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled": true, "daily_article_goal": 2, "template_reference": "template:builtin:general_guide"}'
```

| Field                 | What it does                                                                                                      |
| --------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `enabled`             | `true` turns Auto on. Required.                                                                                   |
| `daily_article_goal`  | How many articles Auto starts per day.                                                                            |
| `template_reference`  | The template Auto writes with. Required when you turn Auto on.                                                    |
| `stop_condition`      | `until_turned_off` (the default), `until_date` with `stop_at`, or `after_article_count` with `stop_article_goal`. |
| `confirm_media_spend` | Send `true` if the template makes images. Each image costs 1 credit.                                              |

Auto doesn't start immediately; it picks up during one of its next regular checks. It also needs to know what to do with finished articles, which you configure on the project's **Edit** page under **Publishing automation**.

Call `GET /projects/{project}/auto` to view the current settings and see if Auto is paused. Call `DELETE /projects/{project}/auto` to turn it off. Any articles already in progress will still finish. Read [Project Auto and ideas](https://www.unspar.com/docs/guides/project-auto-and-ideas/) to see why Auto might pause and how to handle it.

## Find ideas

An idea is a suggested article that includes a title and a reason to write it. Unspar generates these in an idea run, which you start with `POST /projects/{project}/idea-runs`. Each run costs 1 credit, even if it finds nothing new.

```sh
curl -X POST https://app.unspar.com/api/v1/projects/<project-id>/idea-runs \
  -H "Authorization: Bearer $UNSPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"workflow_type": "research_topic", "topic": "Bike repair at home"}'
```

The `workflow_type` field sets the kind of run. While the web app only offers the first and third options, the API supports all five:

| `workflow_type`   | What Unspar does                                                | Fields                                                 |
| ----------------- | --------------------------------------------------------------- | ------------------------------------------------------ |
| `analyze_site`    | Reads the website and suggests topics it doesn't have yet.      | `project_url`, which defaults to the project's website |
| `competitor_gaps` | Suggests topics a competitor covers and you don't.              | `competitor_url` (required)                            |
| `research_topic`  | Researches a topic on the web.                                  | `topic` (required), `audience`                         |
| `refresh_content` | Suggests which finished articles in the project need an update. | `focus_area`                                           |
| `plan_series`     | Plans a series of articles on one subject.                      | `series_brief` (required), `series_length`, `audience` |

Send only the fields that belong to your chosen `workflow_type`. Any extra field triggers a `422` response naming the invalid field.

## Read the ideas

An idea run takes about a minute. You can track it in three steps:

1. Call `GET /idea-runs/{run}` every 10 to 30 seconds while `should_poll` is `true`.
2. Check `status`. With `completed`, the ideas are ready. With `completed_empty`, the run found nothing new, and `diagnostics` says why.
3. Call `GET /idea-runs/{run}/appearances` to list the ideas. Each one has a `title` and a `rationale`. Many also have a `template_suggestion`.

Unspar skips topics your project already covers, whether in Unspar or on your live site, as well as ideas that are still open or were previously dismissed. Check `counts.left_out` to see how many were filtered out.

In the API, an idea inside a run is called an appearance. For the endpoints below, pass the item's `id` as `{appearance}`, rather than its `idea_id` (the two are easy to mix up).

## Queue or hide an idea

Use these endpoints to act on a single idea or on the run as a whole:

| Request                                        | What happens                                                                                                                                                 |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `POST /idea-appearances/{appearance}/queue`    | Unspar starts the article with the project's settings. It costs the article's normal price. Send `"confirm_media_spend": true` if the template makes images. |
| `POST /idea-appearances/{appearance}/decision` | Sets `decision` to `shortlisted`, `dismissed` or `new`. Dismissed ideas don't come back in later runs. Free.                                                 |
| `POST /idea-runs/{run}/find-more`              | Adds more ideas to the run. 1 credit.                                                                                                                        |
| `POST /idea-runs/{run}/refresh`                | Repeats the run with the same input. 1 credit.                                                                                                               |

You can call `POST /articles/{article}/unqueue` to move an article queued from an idea back to `draft`. Note that runs Unspar started on its own can't be extended or repeated.

You also can't queue ideas from a `refresh_content` run; the API returns `409 idea_queue_mode_unsupported`. Start those refreshes in the web app instead, as shown in [Refresh](https://www.unspar.com/docs/guides/refresh/).

## Set the look of the images

A project can use a visual identity, which gives all of its generated images a consistent look. You pick one from three generated options, just as you do in the web app.

1. Call `POST /projects/{project}/visual-identity/rounds`. Unspar makes three options. You can send an image style from `GET /image-presets` as `preset`, plus `notes` or a `palette`.
2. Call `GET /projects/{project}/visual-identity` until `latest_round.status` is `ready`. `latest_round.candidates` holds the three options, each with an `index` and a preview `url`.
3. Call `PUT /projects/{project}/visual-identity` with `latest_round.id` as `round` and your chosen `index` as `candidate`.

Rounds are free, with a daily limit of 5 per project and 15 per team (resetting at midnight UTC). Once a look is active, you can send a `PUT` request with only `palette` or `notes` to update them without starting a new round.

Call `DELETE /projects/{project}/visual-identity` to turn the visual identity off for new images. Existing images stay as they are. Using a visual identity adds no extra cost, so each image still costs 1 credit. See [Images](https://www.unspar.com/docs/guides/images/) for examples of what it changes.

## Endpoint reference

### GET /api/v1/projects

`listProjects`: List visible projects.

Permission: `unspar:projects:read`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `page` | query | integer | no | Minimum 1. |
| `per_page` | query | integer | no | Minimum 1. Maximum 100. |
| `status` | query | string | no |  |
| `q` | query | string | no |  |
| `sort` | query | "created_at", "-created_at", "updated_at", "-updated_at", "name", "-name", "status", "-status" | no |  |

Responses: 200 Visible project list.

### POST /api/v1/projects

`createProject`: Create a project.

Creates a project in the caller's team. Omitted settings take the same defaults as the app. Requires an API key that covers all projects; project-scoped keys cannot create projects.

Permission: `unspar:projects:create`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | Up to 255 characters. |
| `url` | string (uri) | yes | The website the project writes for. |
| `language` | string | no | Locale tag such as en-US or de-DE. |
| `status` | "active", "paused", "archived" | no |  |
| `timezone` | string | no | IANA timezone name, for example Europe/Berlin. |
| `limit` | integer | no | Monthly article limit; 0 means unlimited. Minimum 0. |
| `automate` | boolean | no | Legacy app automation flag. It does not enable Project Auto; use `/api/v1/projects/{project}/auto`. |
| `defaults` | object | no |  |
| `context` | object | no | Site context for the project. Only the keys you send change. |

Responses: 201 Visible project.; 422 The request body failed validation; `error.details` lists the fields.

### GET /api/v1/projects/{project}/visual-identity

`getProjectVisualIdentity`: Show the current look and latest options.

Images: set each project's look once with its visual identity (show three options, pick one). New illustrations, or new photos if the look is a photo style, then follow it. Do not describe image styles or colors in briefs. Candidate rounds are free, limited to 5 per project and 15 per team per UTC day. Responses include remaining rounds and the next UTC midnight reset time. Approve with both round (its public id) and candidate (1 to 3). Omit both to update only palette or notes. Reference files remain available for in-flight images.

Permission: `unspar:projects:read`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |

Responses: 200 The current look, latest round and remaining daily allowance.; 409 Round in progress, daily limit reached, look inactive or round no longer available. The error details include reason and allowance with remaining rounds and resets_at.; 422 The request body failed validation; `error.details` lists the fields.

### PUT /api/v1/projects/{project}/visual-identity

`approveProjectVisualIdentity`: Use an option from an exact round, or change colors and notes.

Images: set each project's look once with its visual identity (show three options, pick one). New illustrations, or new photos if the look is a photo style, then follow it. Do not describe image styles or colors in briefs. Candidate rounds are free, limited to 5 per project and 15 per team per UTC day. Responses include remaining rounds and the next UTC midnight reset time. Approve with both round (its public id) and candidate (1 to 3). Omit both to update only palette or notes. Reference files remain available for in-flight images.

Permission: `unspar:projects:update`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `round` | string | no | Exact round public id returned by generate or show. |
| `candidate` | integer | no | Minimum 1. Maximum 3. |
| `palette` | array of string | no |  |
| `notes` | string | no | Up to 300 characters. |

Responses: 200 The current look, latest round and remaining daily allowance.; 409 Round in progress, daily limit reached, look inactive or round no longer available. The error details include reason and allowance with remaining rounds and resets_at.; 422 The request body failed validation; `error.details` lists the fields.

### DELETE /api/v1/projects/{project}/visual-identity

`clearProjectVisualIdentity`: Turn off the look for future images.

Images: set each project's look once with its visual identity (show three options, pick one). New illustrations, or new photos if the look is a photo style, then follow it. Do not describe image styles or colors in briefs. Candidate rounds are free, limited to 5 per project and 15 per team per UTC day. Responses include remaining rounds and the next UTC midnight reset time. Approve with both round (its public id) and candidate (1 to 3). Omit both to update only palette or notes. Reference files remain available for in-flight images.

Permission: `unspar:projects:update`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

Responses: 200 The current look, latest round and remaining daily allowance.; 409 Round in progress, daily limit reached, look inactive or round no longer available. The error details include reason and allowance with remaining rounds and resets_at.; 422 The request body failed validation; `error.details` lists the fields.

### POST /api/v1/projects/{project}/visual-identity/rounds

`generateProjectVisualIdentity`: Show three free look options. Daily limits apply.

Images: set each project's look once with its visual identity (show three options, pick one). New illustrations, or new photos if the look is a photo style, then follow it. Do not describe image styles or colors in briefs. Candidate rounds are free, limited to 5 per project and 15 per team per UTC day. Responses include remaining rounds and the next UTC midnight reset time. Approve with both round (its public id) and candidate (1 to 3). Omit both to update only palette or notes. Reference files remain available for in-flight images.

Permission: `unspar:projects:update`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `preset` | string | no | Public image preset id from GET /api/v1/image-presets. Choose a photo or illustration style. Defaults to the project's image style, then clean editorial illustration. |
| `palette` | array of string | no |  |
| `notes` | string | no | Up to 300 characters. |

Responses: 202 The current look, latest round and remaining daily allowance.; 409 Round in progress, daily limit reached, look inactive or round no longer available. The error details include reason and allowance with remaining rounds and resets_at.; 422 The request body failed validation; `error.details` lists the fields.

### GET /api/v1/projects/{project}/auto

`getProjectAuto`: Show Project Auto configuration for one project.

Permission: `unspar:projects:automate`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |

Responses: 200 Project Auto configuration.

### PUT /api/v1/projects/{project}/auto

`setProjectAuto`: Enable or update Project Auto configuration.

Enabling Project Auto requires `daily_article_goal` and `template_reference`. Set `confirm_media_spend` to true when the selected template requires media spend acknowledgement.

Permission: `unspar:projects:automate`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean | yes |  |
| `daily_article_goal` | integer | no | Minimum 1. Maximum 65535. |
| `template_reference` | string | no | `template:builtin:<key>` or a team template id from reads. Required when enabling. |
| `stop_condition` | "until_turned_off", "until_date", "after_article_count", null | no |  |
| `stop_at` | string (date) | no |  |
| `stop_article_goal` | integer | no | Minimum 1. Maximum 65535. |
| `confirm_media_spend` | boolean | no | Default false. |

Responses: 200 Project Auto configuration.; 409 The request conflicts with current resource state or required confirmation.; 422 The request body failed validation; `error.details` lists the fields.

### DELETE /api/v1/projects/{project}/auto

`disableProjectAuto`: Disable Project Auto for one project.

Permission: `unspar:projects:automate`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

Responses: 200 Project Auto configuration.

### GET /api/v1/projects/{project}

`getProject`: Show one visible project.

Permission: `unspar:projects:read`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |

Responses: 200 Visible project.

### PATCH /api/v1/projects/{project}

`updateProject`: Update a project.

Partial update. Only the fields present in the JSON body change, and inside `context` only the keys you send change.

Permission: `unspar:projects:update`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | Up to 255 characters. |
| `url` | string (uri) | yes | The website the project writes for. |
| `language` | string | no | Locale tag such as en-US or de-DE. |
| `status` | "active", "paused", "archived" | no |  |
| `timezone` | string | no | IANA timezone name, for example Europe/Berlin. |
| `limit` | integer | no | Monthly article limit; 0 means unlimited. Minimum 0. |
| `automate` | boolean | no | Legacy app automation flag. It does not enable Project Auto; use `/api/v1/projects/{project}/auto`. |
| `defaults` | object | no |  |
| `context` | object | no | Site context for the project. Only the keys you send change. |

Responses: 200 Visible project.; 422 The request body failed validation; `error.details` lists the fields.

### DELETE /api/v1/projects/{project}

`deleteProject`: Delete a project.

Permission: `unspar:projects:delete`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

Responses: 200 Deleted project.

### GET /api/v1/projects/{project}/idea-runs

`listIdeaRuns`: List idea discovery runs for one visible project.

Permission: `unspar:ideas:read`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `page` | query | integer | no | Minimum 1. |
| `per_page` | query | integer | no | Minimum 1. Maximum 100. |

Responses: 200 Idea run list.

### POST /api/v1/projects/{project}/idea-runs

`startIdeaRun`: Start an idea discovery run for one project.

Permission: `unspar:ideas:write`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `workflow_type` | "analyze_site", "competitor_gaps", "research_topic", "refresh_content", "plan_series" | yes |  |
| `project_url` | string | no | analyze_site only. Defaults to the project website. Up to 2000 characters. |
| `competitor_url` | string | no | competitor_gaps only, required there. Up to 2000 characters. |
| `topic` | string | no | research_topic only, required there. Up to 2000 characters. |
| `focus_area` | string | no | refresh_content only. For research_topic, put the focus into topic or audience. Up to 2000 characters. |
| `series_brief` | string | no | plan_series only, required there. Up to 2000 characters. |
| `series_length` | integer | no | plan_series only. Minimum 1. |
| `audience` | string | no | research_topic and plan_series only. Up to 500 characters. |

Responses: 202 Idea run mutation response.; 402 The team does not have enough credits for this operation.; 409 The request conflicts with current resource state or required confirmation.; 422 The request body failed validation; `error.details` lists the fields.

### GET /api/v1/idea-runs/{run}

`getIdeaRun`: Show one idea discovery run.

Permission: `unspar:ideas:read`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `run` | path | string | yes |  |

Responses: 200 Idea run.

### GET /api/v1/idea-runs/{run}/appearances

`listIdeaAppearances`: List public idea appearances produced by one run.

Permission: `unspar:ideas:read`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `run` | path | string | yes |  |
| `page` | query | integer | no | Minimum 1. |
| `per_page` | query | integer | no | Minimum 1. Maximum 100. |

Responses: 200 Idea appearance list.

### POST /api/v1/idea-runs/{run}/find-more

`findMoreIdeas`: Start an expansion pass for an ordinary idea run.

Permission: `unspar:ideas:write`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `run` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

Responses: 202 Idea run mutation response.; 409 The request conflicts with current resource state or required confirmation.

### POST /api/v1/idea-runs/{run}/refresh

`refreshIdeaRun`: Refresh an idea run from its stored input.

Permission: `unspar:ideas:write`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `run` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

Responses: 202 Idea run mutation response.; 409 The request conflicts with current resource state or required confirmation.; 422 The request body failed validation; `error.details` lists the fields.

### POST /api/v1/idea-appearances/{appearance}/decision

`decideIdeaAppearance`: Set an idea appearance decision state.

Permission: `unspar:ideas:write`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `appearance` | path | string | yes |  |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | "new", "shortlisted", "dismissed" | yes |  |

Responses: 200 Idea appearance.; 422 The request body failed validation; `error.details` lists the fields.

### POST /api/v1/idea-appearances/{appearance}/queue

`queueIdeaAppearance`: Queue one idea appearance as an article.

Permission: `unspar:generation:write`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `appearance` | path | string | yes |  |
| `Idempotency-Key` | header | string | no | Optional client key that makes a repeated POST replay the first response instead of running twice. Up to 255 characters. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `confirm_media_spend` | boolean | no | Default false. |

Responses: 202 Queued idea article.; 402 The team does not have enough credits for this operation.; 409 The request conflicts with current resource state or required confirmation.
