# Update a post (/docs/api/cms/posts/updatePost)

`PATCH https://api.tintage.com/v1/cms/projects/{projectId}/posts/{postId}`

Changes the fields sent. A draft is changed in place. A live post's edits are pending changes (`?version=working`, created by the first edit) until an editor makes them live; editors can write the live version with `?live=true`. Send the version you edited in `If-Match`. Needs `post:create` (your own drafts) or `post:publish`.

Parameters:
- `projectId` (path, required)
- `postId` (path, required)
- `locale` (query): Language tag of the row to read (`fr`, `fr-CA`). Defaults to the site's language.
- `version` (query): Secret keys: `working` reads a live post with its pending changes and their version (0 before there are any), which a write to them sends in `If-Match`. `live` (the default) is the post itself.
- `live` (query): Editors (`post:publish`): write a live post's live version instead of its pending changes.
- `if-match` (header): The version this write was made against (`"7"`, from `ETag`). Without it the last write wins.

JSON request body:
- `title` (string)
- `body` (object or null): A Tiptap JSON document (`@tintage/document`).
- `featureImage` (object): `{ file: 'file_...', alt }`, or null.
- `slug` (string)
- `authorIds` (array): Author ids (`author_...`) in byline order.
- `publishedAt` (string): Editors: the publish date of a published post.
- `seo` (object)
- `og` (object)
- `twitter` (object)
- `canonicalUrl` (string or null)
- `noindex` (boolean)
- `excerpt` (string or null)
- `tags` (array): Tag names; new ones are created.

```json
{
  "title": "string",
  "body": "string",
  "featureImage": "string",
  "slug": "string",
  "authorIds": [
    "string"
  ],
  "publishedAt": "string",
  "seo": {},
  "og": {},
  "twitter": {},
  "canonicalUrl": "string",
  "noindex": false,
  "excerpt": "string",
  "tags": [
    "string"
  ]
}
```

Responses:
- 200: The post, or its pending changes with `?version=working`.

  ```json
  {
    "id": "string",
    "locale": "string",
    "alternates": [
      {
        "locale": "string",
        "slug": "string"
      }
    ],
    "slug": "string",
    "status": "draft",
    "title": "string",
    "excerpt": "string",
    "body": "string",
    "featureImage": "string",
    "tags": [
      {
        "id": "string",
        "slug": "string",
        "name": "string",
        "description": "string",
        "image": "string",
        "seo": {
          "title": "string",
          "description": "string"
        },
        "visibility": "public",
        "count": {
          "posts": 0
        }
      }
    ],
    "authors": [
      {
        "id": "string",
        "slug": "string",
        "name": "string",
        "bio": "string",
        "image": "string",
        "website": "string",
        "social": {
          "x": "string",
          "bluesky": "string",
          "mastodon": "string",
          "linkedin": "string",
          "instagram": "string",
          "github": "string",
          "youtube": "string"
        },
        "count": {
          "posts": 0
        }
      }
    ],
    "seo": {
      "title": "string",
      "description": "string"
    },
    "og": {
      "title": "string",
      "description": "string",
      "image": "string"
    },
    "twitter": {
      "card": "summary",
      "title": "string",
      "description": "string",
      "image": "string"
    },
    "canonicalUrl": "string",
    "noindex": false,
    "fields": {},
    "publishedAt": "string",
    "createdAt": "string",
    "updatedAt": "string",
    "version": 0
  }
  ```
- 400: The request is malformed: `invalid_input`, `unknown_parameter`, `invalid_cursor` or `unsupported_api_version`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 401: Missing or invalid credential: `unauthorized`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 402: A plan limit: `plan_limit`, `spend_cap_reached` or `plan_inactive`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 403: The credential may not do this here: `forbidden`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 404: No such item, or one this credential cannot see: `not_found`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 409: `conflict` or `idempotency_in_progress`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 412: `If-Match` named an old version: `precondition_failed` with `currentVersion`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 422: `limit_exceeded`, `query_not_supported`, `query_timeout` or `idempotency_key_reused`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 429: Too many requests: `rate_limited`, with `Retry-After`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
- 500: Something failed on our side: `internal_error`.

  ```json
  {
    "error": {
      "code": "invalid_input",
      "message": "string",
      "field": "string",
      "hint": "string",
      "issues": [
        {
          "field": "string",
          "message": "string",
          "hint": "string"
        }
      ]
    },
    "requestId": "string"
  }
  ```
